#include <cstdio>
#include <cctype>
#include <map>
struct istream{
template <typename T>
istream &operator>>(T &x){
x = 0;
char c = getchar_unlocked();
while (!isdigit(c)) c = getchar_unlocked();
while (isdigit(c)) x = x * 10 + c - '0',c = getchar_unlocked();
return *this;
}
}cin;
int main(){
int n,q,ans = 0;
std::map <std::pair <int,int>,int> a;
cin >> n >> q;
for (int i = 1;i <= n;i++){
int s;
cin >> s;
for (int j = 1;j <= s;j++) cin >> a[std::make_pair(i,j)];
}
while (q--){
int x,y;
cin >> x >> y;
ans ^= a[std::make_pair(x,y)];
}
printf("%d\n",ans);
return 0;
}
注意cin已经是快读了!!!