| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1168059 | Faisal_Saqib | Walk (POI13_spa) | C++17 | 0 ms | 0 KiB | 
#include <iostream>
#include <map>
#include <queue>
using namespace std;
#define ll long long
int n,k;
char c;
ll asp=0;
bitset<1000069> banned;
ll read()
{
    asp=0;
    for(int i=0;i<n;i++)
    {
        cin>>c;
        asp<<=1;
        asp+=c-'0';
    }
    return asp;
}
ll gcost(ll x,ll y)
{
    return __builtin_popcountll(x^y);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    ll st=read(),ed=read();
    for(int i=0;i<k;i++)
    {
        banned[read()]=1;
    }
    queue<ll>pq;
    banned[st]=1;
    pq.push(st);
    while(pq.size())
    {
        ll x=pq.front();
        pq.pop();
        if(x==ed)
        {
            cout<<"TAK"<<endl;
            return 0;
        }
        ll pw=1;
        for(int bi=0;bi<n;bi++)
        {
            ll y=x^pw;
            if(!banned[y])
            {
                banned[y]=1;
                pq.push(y);
            }
            pw<<=1;
        }
    }
    cout<<"NIE"<<endl;
    return 0;
}
