This page is still under construction.

Parts of this page are still being built. What you see may change.

Eunki's DNA Molecules

Time limit5sMemory limit256 MB

Summary
For every pair of N DNA strings, decide whether four two-way substring swaps can rewrite one into the other.
Level

Hard8 of 10

Topics
Math, String, Hash map
Solved
No attempts yet

Problem

A DNA string uses A, C, G, T. Apply these bidirectional substring replacements:

  • A ↔ TC
  • C ↔ AG
  • G ↔ CT
  • T ↔ GA

For NN strings, output whether each pair can transform from the first to the second.

Input

Line 1: NN (2≤N≤1002 \le N \le 100). Next NN DNA strings (length ≤50 000\le 50\,000).

Output

NN lines of NN 0/1 chars; 1 at (i,j)(i,j) means string ii can become string jj.

Examples3

  1. Example 1

    Input
    4
    AA
    TAT
    C
    CGTAC
    
    Expected output
    1100
    1100
    0011
    0011
    
  2. Example 2

    Input
    4
    A
    C
    G
    T
    
    Expected output
    1000
    0100
    0010
    0001
    
  3. Example 3

    Input
    4
    AAA
    CCC
    TATA
    CACA
    
    Expected output
    1111
    1111
    1111
    1111