1-2-3

题意翻译

**题面** Ilya 从事机器人制作这一行业。Ilya 为娱乐机器人编程,目前他工作的项目是 "Bob",新一代的游戏机器人。Ilya 的老板最近想知道他的进展如何,特别是如果 Bob 比以前的 Alice 更擅长玩不同的游戏,他会对此很感兴趣。 现在,Ilya 想知道他的机器人在一个简单的叫“ 1-2-3 ”的游戏中的表现。这个游戏类似于“石头、剪刀、布”的游戏:两个机器人同时 $3}$ 中选择一个数字,如果他们选择相同的数字,那么这是平局,没有人得分。但是,如果这两个数字不同,那么其中一个机器人能得一分。$3$ 能打败 $2$,而 $2$ 能打败 $1,1$ 能打败 $3$。 这两个机器人的程序使得他们在第 $(i+1)$ 局中的选择只依赖于第 $i$ 局的选择。 Ilya 知道机器人将会玩 $k$ 局游戏,Alice 机器人将会在第一局选择数字 $a$,而 Bob 机器人会选择数字 $b$。他也知道两个机器人的程序,可以根据他们在前一场比赛中的选择来判断每个机器人会选择什么。但 Ilya 太懒了不想等到机器人把那 $k$ 局游戏玩完,所以他请你来预测在最后一场比赛后每个机器人的得分。 **输入格式** 第一行有三个整数 $k(1 \le k \le 10^{18}),a$ 和 $b(1 \le a,b \le 3)$。接下来三行,第 $i$ 行有 $A_{i,1}$ 以及 $A_{i,2}$ 和 $A_{i,3}$。$A_{i,j}$ 表示如果 Alice 选择了 $i$ 而 Bob 选择了 $j$ 时 Alice 的选择。下面又有 $3$ 行:第 $i$ 行有 $B_{i,1}$ 以及 $B_{i,2}$ 和 $B_{i,3}$。$B_{i,j}$ 表示如果 Alice 选择了 $i$ 而 Bob 选择了 $j$ 时 Bob 的选择。 **输出格式** 两个整数,分别表示 Alice 的分数和 Bob 的分数。 感谢 @x義x 提供的翻译

题目描述

Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model, "Alice". So now Ilya wants to compare his robots' performance in a simple game called "1-2-3". This game is similar to the "Rock-Paper-Scissors" game: both robots secretly choose a number from the set $ {1,2,3} $ and say it at the same moment. If both robots choose the same number, then it's a draw and noone gets any points. But if chosen numbers are different, then one of the robots gets a point: $ 3 $ beats $ 2 $ , $ 2 $ beats $ 1 $ and $ 1 $ beats $ 3 $ . Both robots' programs make them choose their numbers in such a way that their choice in $ (i+1) $ -th game depends only on the numbers chosen by them in $ i $ -th game. Ilya knows that the robots will play $ k $ games, Alice will choose number $ a $ in the first game, and Bob will choose $ b $ in the first game. He also knows both robots' programs and can tell what each robot will choose depending on their choices in previous game. Ilya doesn't want to wait until robots play all $ k $ games, so he asks you to predict the number of points they will have after the final game.

输入输出格式

输入格式


The first line contains three numbers $ k $ , $ a $ , $ b $ ( $ 1<=k<=10^{18} $ , $ 1<=a,b<=3 $ ). Then $ 3 $ lines follow, $ i $ -th of them containing $ 3 $ numbers $ A_{i,1} $ , $ A_{i,2} $ , $ A_{i,3} $ , where $ A_{i,j} $ represents Alice's choice in the game if Alice chose $ i $ in previous game and Bob chose $ j $ ( $ 1<=A_{i,j}<=3 $ ). Then $ 3 $ lines follow, $ i $ -th of them containing $ 3 $ numbers $ B_{i,1} $ , $ B_{i,2} $ , $ B_{i,3} $ , where $ B_{i,j} $ represents Bob's choice in the game if Alice chose $ i $ in previous game and Bob chose $ j $ ( $ 1<=B_{i,j}<=3 $ ).

输出格式


Print two numbers. First of them has to be equal to the number of points Alice will have, and second of them must be Bob's score after $ k $ games.

输入输出样例

输入样例 #1

10 2 1
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
2 2 2

输出样例 #1

1 9

输入样例 #2

8 1 1
2 2 1
3 3 1
3 1 3
1 1 1
2 1 1
1 2 3

输出样例 #2

5 2

输入样例 #3

5 1 1
1 2 2
2 2 2
2 2 2
1 2 2
2 2 2
2 2 2

输出样例 #3

0 0

说明

In the second example game goes like this: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF863C/9f94a5b445d423cedbf110836cdce388646bd126.png) The fourth and the seventh game are won by Bob, the first game is draw and the rest are won by Alice.