#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define sp " "
#define endl "\n"
#define mod 1000000007
const ll INF = 9e18;
#define debug(x) cout << #x << ":" << x << endl;
#define vi vector<ll>
ll grid[1005][1005];
void solve()
{
ll n, m, k;
cin >> n >> m >> k;
for (ll r = 1; r <= n; r++)
{
for (ll c = 1; c <= m; c++)
cin >> grid[r][c];
}
while (k--)
{
ll col;
cin >> col;
ll row = 1;
while (true)
{
if (row == n + 1)
{
cout << col << " ";
break;
}
if (grid[row][col] == 2)
row++;
else if (grid[row][col] == 1)
{
grid[row][col] = 2;
col++;
}
else
{
grid[row][col] = 2;
col--;
}
}
}
cout << endl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll test = 1;
// cin >> test;
while (test--)
{
solve();
}
return 0;
}
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |
Divisibility | A. Movement |
Numbers in a matrix | Sequences |
Split houses | Divisible |
Three primes | Coprimes |
Cost of balloons | One String No Trouble |
Help Jarvis! | Lift queries |
Goki and his breakup | Ali and Helping innocent people |