← Home
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,m,k;cin>>n>>m>>k;k++;
	map<int,int>mp;
	for(int i=1;i<=m;i++){
		int r,c,x;cin>>r>>c>>x;r%=k,x%=k;
		mp[r]^=x;
	}
	for(auto _:mp) if(_.second) return cout<<"Anda\n",void();
	cout<<"Kamu\n";
}
int main(){
	ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	int T;cin>>T;
	while(T--) solve();
	return 0;
}