Walk

No attempts yetTime limit5sMemory limit256 MB

Problem

The names of towns in Byteotia are distinct binary strings of exactly nn bits. There are 2nk2^n - k towns in Byteotia, so exactly kk of the length-nn bit sequences name no town.

Some pairs of towns are directly connected by roads. Precisely, two towns are directly linked by a road if and only if their names differ in exactly one bit. Roads never cross outside of towns.

Byteasar wants to take a stroll from town xx to town yy, walking only along existing roads. Write a program that decides whether such a walk from xx to yy is possible.

Input

The first line contains two integers nn and kk separated by a single space (1n601 \le n \le 60, 0k1,000,0000 \le k \le 1{,}000{,}000, k2n1k \le 2^n - 1, nk5,000,000n \cdot k \le 5{,}000{,}000). Here nn is the length of a town name in bits and kk is the number of length-nn bit sequences that name no town.

The second line contains two strings separated by a single space, each a name of length nn over the characters 0 and 1. These are the names of towns xx and yy.

Each of the next kk lines contains one length-nn bit sequence that names no town, one per line, each a string of 0 and 1. Neither xx nor yy appears among these kk sequences.

Output

Print TAK (Polish for yes) on a single line if a walk from town xx to town yy is possible, and NIE (Polish for no) otherwise.

Hint

For instance, here are two possible walks from 00000000 to 10111011:

  • 0000100011001110111110110000 \to 1000 \to 1100 \to 1110 \to 1111 \to 1011
  • 0000010011001110111110110000 \to 0100 \to 1100 \to 1110 \to 1111 \to 1011