Game

시간 제한25초메모리 제한2048 MB

요약
일관된 정답 문자열이 없는 n개의 질의와 고정 응답이 주어질 때, i번째 턴 직후 처음으로 모순을 알아차리는 순열의 수를 각 i마다 구한다.
난이도

보통10점 중 7점

유형
조합론, 해시맵, 비트 연산, 구현
정답자
아직 제출이 없습니다

문제

A new game called Boundle works as follows. In each turn, the player tells the host a string of length 55 consisting of uppercase English alphabets. Then, the host should respond with a string of length 55 consisting of <, =, >, indicating the alphabetical order compared to the answer string in the host's mind in each position. The answer string should be the same throughout the game, and should also consist of uppercase English alphabets.

Two sisters, Yui and Ui are going to play a game of Boundle. The elder sister Yui will be the host, and the younger sister Ui will be the player. Ui has a set of nn strings she would use as queries, and for each of the nn strings in Ui's set, Yui has already set a fixed response. Here's the twist though: as Yui is careless, it is guaranteed that there actually does not exist a string that matches all of her fixed responses.

Every turn, Ui randomly and uniformly chooses a string in her set that has not yet been chosen, and receives the fixed response for that string. For each ii from 11 to nn, calculate the number of ways the game is played if Ui realizes just after the ii-th turn that the responses given by her elder sister Yui are not consistent. Ui is smart enough, so, when the responses don't add up, she immediately sees that Yui does not actually have an answer string in her mind.

Note that it is guaranteed that if Ui finishes all the strings in the set, the results she gets will not be consistent.

Also, for some mysterious reasons, unlike the original game, even if the responses have already narrowed the possible answer strings down to one possibility, the game would still continue until all the strings in the set have been chosen, or the responses become inconsistent.

입력

The first line contains an integer nn (1≤n≤1051 \leq n \leq 10^5).

Subsequently, there are nn lines, with each line containing two strings. The first string belongs to the set of strings from Ui, and the second string represents Yui's response to it.

All strings in Ui's set are distinct and consist of five uppercase English alphabets. Yui's responses are strings of length 55, containing only the characters "<", "=", and ">".

It is guaranteed that there does not exist a string that matches all of Yui's responses.

출력

Print a line with nn integers, the ii-th of which should be the number of ways the game can be played if Ui realizes Yui is lying just after the ii-th turn.

Print all numbers modulo 998,244,353998\\,244\\,353.

예제4

  1. 예제 1

    입력
    2
    FAKER >>>>>
    CHOVY =====
    
    예상 출력
    0 2
    
  2. 예제 2

    입력
    3
    BVHUQ ><>><
    YJCEQ <<><<
    SXXWZ >>==>
    
    예상 출력
    1 4 0
    
  3. 예제 3

    입력
    8
    IFSXA >><<=
    ZAKDA <>=>=
    UZVAA <<<>=
    MTACA <>>>=
    RJKVA <><<=
    IOXOA >=<<=
    MRMHA ><<<=
    BYFWA ==<>=
    
    예상 출력
    0 16 108 396 816 720 0 0
    
  4. 예제 4

    입력
    8
    BRKPR ><=<>
    VUCTO <<=<=
    PTCDB <<=>>
    PHMGV <><><
    FGWHD >><>>
    SUSFH <<<<>
    IOLDD <<<<>
    WJPXX <><<<
    
    예상 출력
    0 14 120 444 744 360 0 0