#include<bits/stdc++.h>
using namespace std;

int main(){

    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
   int Test;
   cin>>Test;
   while(Test--){
       int n,k; cin>>n>>k;
       if(k){
           if(n%4==0) cout<<"On"<<endl;
           else cout<<"Ambiguous"<<endl;
       }
       else{
           if(n%4==0) cout<<"Off"<<endl;
           else cout<<"On"<<endl;
       }
   }

   return 0;
}
/*

*/