#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";
}
}
}
I2luY2x1ZGU8Yml0cy9zdG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ICAgICB7CiAgICAgICAgICAgIGYoaiwwLG0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNpbj4+YVtpXVtqXTsKICAgICAgICAgICAgICAgIGRwW2l8al1ePWFbaV1bal07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZihpLDAsMjIpCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IG1hc2s9MDttYXNrPE47bWFzaysrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihtYXNrJigxPDxpKSkKICAgICAgICAgICAgICAgICAgICBkcFttYXNrXV49ZHBbbWFza14oMTw8aSldOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGludCBwcmV2PTA7CiAgICAgICAgd2hpbGUocS0tKQogICAgICAgIHsKICAgICAgICAgICAgaW50IGs7CiAgICAgICAgICAgIGNpbj4+azsKICAgICAgICAgICAga149cHJldixrJj1OLTE7CiAgICAgICAgICAgIHByZXY9ZHBba107CiAgICAgICAgICAgIGNvdXQ8PHByZXY8PCJcbiI7CiAgICAgICAgfQogICAgfSAgICAgICAKfSAgIA==