#include<bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC optimize("no-stack-protector")
// #define ll __int128
#define ll long long
// #define ll int
#define f(i,a,b) for(int i=a;i<b;i++)
// #define mod 1000000007
#define mod 998244353
#define mp make_pair
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define ff first
#define ss second
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%lld",&a)
#define pf printf
#define sz(a) (int)(a.size())
#define psf push_front
#define ppf pop_front
#define ppb pop_back
#define pb push_back
#define pq priority_queue
#define all(s) s.begin(),s.end()
#define sp(a) setprecision(a)
#define rz resize
#define ld long double
#define inf (ll)1e18
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define eb emplace_back
const double pi = acos(-1);
// ll binpow(ll a, ll b){ll res=1;while(b!=0){if(b&1)res*=a;a*=a;b>>=1;}return res;}
ll binpow(ll a, ll b, ll md){ll res=1;a%=mod;while(b!=0){if(b&1)res*=a,res%=md;a*=a,a%=md;b>>=1;}return res%md;}
using namespace std;
const int N=(1<<22);
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("xortransform.in","r",stdin);
freopen("xortransform.out","w",stdout);
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
int z=1;
// cin>>z;
f(i,1,z+1)
{
int n,m,q;
cin>>n>>m>>q;
int dp[N]={},a[n][m];
f(i,0,n)
{
f(j,0,m)
{
cin>>a[i][j];
dp[i|j]^=a[i][j];
}
}
f(i,0,22)
{
for(int mask=0;mask<N;mask++)
{
if(mask&(1<<i))
dp[mask]^=dp[mask^(1<<i)];
}
}
int prev=0;
while(q--)
{
int k;
cin>>k;
k^=prev,k&=N-1;
prev=dp[k];
cout<<prev<<"\n";
}
}
}
CQojaW5jbHVkZTxiaXRzL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TsKICAgICAgICBmKGksMCxuKQogICAgICAgIHsKICAgICAgICAgICAgZihqLDAsbSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY2luPj5hW2ldW2pdOwogICAgICAgICAgICAgICAgZHBbaXxqXV49YVtpXVtqXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmKGksMCwyMikKICAgICAgICB7CiAgICAgICAgICAgIGZvcihpbnQgbWFzaz0wO21hc2s8TjttYXNrKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKG1hc2smKDE8PGkpKQogICAgICAgICAgICAgICAgICAgIGRwW21hc2tdXj1kcFttYXNrXigxPDxpKV07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaW50IHByZXY9MDsKICAgICAgICB3aGlsZShxLS0pCiAgICAgICAgewogICAgICAgICAgICBpbnQgazsKICAgICAgICAgICAgY2luPj5rOwogICAgICAgICAgICBrXj1wcmV2LGsmPU4tMTsKICAgICAgICAgICAgcHJldj1kcFtrXTsKICAgICAgICAgICAgY291dDw8cHJldjw8IlxuIjsKICAgICAgICB9CiAgICB9ICAgICAgIAp9