Hanoi

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Rikka has nn disks of distinct sizes on three rods. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack. No disk can be placed on top of a smaller disk.

Given the configuration of disks SS and TT, find the number of ways can Rikka transform from SS to TT in no more than mm moves.
As the number of ways can be very large, find it modulo 998,244,353998\\,244\\,353.

Two sequences of moves are different if they have different lengths, or the configurations are different after some moves.

입력

The first line contains two integers nn and mm (1n1001 \leq n \leq 100, 0m1000 \leq m \leq 100). 

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n, the configuration SS (1a_i31 \le a\_i \le 3). These mean that the ii-th smallest disk is on rod a_ia\_i.

The third line contains nn integers b_1,b_2,,b_nb\_1, b\_2, \ldots, b\_n, the configuration TT given in the same format (1b_i31 \le b\_i \le 3).

출력

Print one integer: the number of ways modulo 998,244,353998\\,244\\,353.