#include<iostream>
#include<cstdio>
using namespace std;
int Honloan,Trattu;
int DEF[7] = { 0, 3, 27, 99, 729, 6561, 59049 };
int ATT[7] = { 0, 9, 54, 162, 1458, 13112, 118008 };
int a[12][32],b[12][32];
void Welcometosummonerrift(){
for(int i = 0;i <= 10; i++){
for(int j = 0;j <= 28; j++){
b[i][j] = 0;
}
}
}
int attack(int i,int j){
int Point = 0;
//HANG NGANG
int ystop = 0,rvtop = 0, ysbot = 0,rvbot = 0;
//Trai
for(int m = 1; m < 6 && j - 2 * m >= 0; m++){
if(a[i][j - 2 * m] == Honloan)ystop++;
if(a[i][j - 2 * m] == Trattu){
rvtop++;
break;
}
if(a[i][j - 2 * m]==0){
break;
}
}
//Phai
for(int m = 1 ;m < 6 && j + 2 * m <= 28; m++){
if(a[i][j + 2 * m] == Honloan)ysbot++;
if(a[i][j + 2 * m] == Trattu){
rvbot++;
break;
}
if(a[i][j + 2 * m]==0){
break;
}
}
//Cheo huyen
int xayahtop=0,rakantop=0,xayahbot=0,rakanbot=0;
//Duoi len
for(int m = 1; m < 6 && i - m >= 0 && j - m >= 0;m++){
if(a[i - m][j - m ] == Honloan) xayahtop++;
if(a[i - m][j - m ] == Trattu){
rakantop++;
break;
}
if(a[i - m][j - m] == 0){
break;
}
}
//Tren xuong
for(int m = 1; m < 6 && i + m <= 10 && j + m <= 28; m++){
if(a[i + m][j + m] == Honloan) xayahbot++;
if(a[i + m][j + m] == Trattu){
rakanbot++;
break;
}
if(a[i + m][j + m] == 0){
break;
}
}
//Cheo sac
int leetop=0,yitop=0,leebot=0,yibot=0,luxmid1=0,luxmid2=0;
for(int m = 1; m < 6 && i - m >= 0 && j + m <= 28 ; m++){
if(a[i - m][j + m] == Honloan)leetop++;
if(a[i - m][j + m] == Trattu){
yitop++;
break;
}
if(a[i - m][j + m]==0){
break;
}
}
for(int m = 1; m < 6 && i + m <= 10 && j - m >= 0 ; m++){
if(a[i + m][j - m] == Honloan)leebot++;
if(a[i + m][j - m] == Trattu){
yibot++;
break;
}
if(a[i + m][j - m] == 0){
break;
}
}
if(rvtop + rvbot == 2) Point = 0;
else{
Point += ATT[ystop + ysbot];
}
if(rakantop + rakanbot == 2) Point = 0;
else{
Point += ATT[xayahtop + xayahbot];
}
if(yitop + yibot == 2) Point = 0;
else{
Point += ATT[leetop + leebot];
}
if(ystop == 2 && xayahtop == 2 && ysbot == 0 && xayahbot == 0 ){
if(rvbot == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && xayahbot == 2 && ysbot == 0 && xayahtop == 0 ){
if(rvbot == 0 && rakantop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && leetop == 2 && ysbot == 0 && leebot == 0 ){
if(rvbot == 0 && yibot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yibot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && leebot == 2 && ysbot == 0 && leetop == 0 ){
if(rvbot == 0 && yitop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yitop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && xayahtop == 2 && ystop == 0 && xayahbot == 0 ){
if(rvtop == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && xayahbot == 2 && ystop == 0 && xayahtop == 0 ){
if(rvtop == 0 && rakantop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && leetop == 2 && ystop == 0 && leebot == 0 ){
if(rvtop == 0 && yibot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yibot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && leebot == 2 && ystop == 0 && leetop == 0 ){
if(rvtop == 0 && yitop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yitop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 2 && xayahtop == 2 && leebot == 0 && xayahbot == 0 ){
if(yibot == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 2 && xayahbot == 2 && leetop == 0 && xayahtop == 0 ){
if(yitop == 0 && rakantop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 2 && xayahbot == 2 && leebot == 0 && xayahtop == 0 ){
if(yibot == 0 && rakantop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 2 && xayahtop == 2 && leetop == 0 && xayahbot == 0 ){
if(yitop == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 1 && xayahtop == 2 && ysbot == 1 && xayahbot == 0 ){
if(rvbot == 0 && rakanbot == 0 && rvtop == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakanbot == 1 || rvtop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 1 && xayahbot == 2 && ysbot == 1 && xayahtop == 0 ){
if(rvbot == 0 && rakantop == 0 && rvtop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakantop == 1 || rvtop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 1 && leetop == 2 && ysbot == 1 && leebot == 0 ){
if(rvbot == 0 && yibot == 0 && rvtop == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yibot == 1 || rvtop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 1 && leebot == 2 && ysbot == 1 && leetop == 0 ){
if(rvbot == 0 && yitop == 0 && rvtop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yitop == 1 || rvtop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 1 && xayahtop == 2 && ystop == 1 && xayahbot == 0 ){
if(rvtop == 0 && rakanbot == 0 && rvbot == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakanbot == 1 || rvbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 1 && xayahbot == 2 && ystop == 1 && xayahtop == 0 ){
if(rvtop == 0 && rakantop == 0 && rvbot == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakantop == 1 || rvbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 1 && leetop == 2 && ystop == 1 && leebot == 0 ){
if(rvtop == 0 && yibot == 0 && rvbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yibot == 1 || rvbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 1 && leebot == 2 && ystop == 1 && leetop == 0 ){
if(rvtop == 0 && yitop == 0 && rvbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yitop == 1 || rvbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 1 && xayahtop == 2 && leebot == 1 && xayahbot == 0 ){
if(yibot == 0 && rakanbot == 0 && yitop == 0){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakanbot == 1 || yitop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 1 && xayahbot == 2 && leetop == 1 && xayahtop == 0 ){
if(yitop == 0 && rakantop == 0 && yibot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakantop == 1 || yibot == 1 ){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 1 && xayahbot == 2 && leebot == 1 && xayahtop == 0 ){
if(yibot == 0 && rakantop == 0 && yitop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakantop == 1 || yitop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 1 && xayahtop == 2 && leetop == 1 && xayahbot == 0 ){
if(yitop == 0 && rakanbot == 0 && yibot == 0){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakanbot == 1 || yibot == 1){
Point = Point + 2 * Point / 3;
}
}
if(ystop == 2 && xayahtop == 1 && ysbot == 0 && xayahbot == 1 ){
if(rvbot == 0 && rakanbot == 0 && rakantop == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakanbot == 1 || rakantop == 1 ){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && xayahbot == 1 && ysbot == 0 && xayahtop == 1 ){
if(rvbot == 0 && rakantop == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || rakantop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && leetop == 1 && ysbot == 0 && leebot == 1 ){
if(rvbot == 0 && yibot == 0 && yitop == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yibot == 1 || yitop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ystop == 2 && leebot == 1 && ysbot == 0 && leetop == 1 ){
if(rvbot == 0 && yitop == 0 && yibot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvbot == 1 || yitop == 1 || yibot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && xayahtop == 1 && ystop == 0 && xayahbot == 1 ){
if(rvtop == 0 && rakanbot == 0 && rakantop == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakanbot == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && xayahbot == 1 && ystop == 0 && xayahtop == 1 ){
if(rvtop == 0 && rakantop == 0 && rakanbot == 0 ){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || rakantop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && leetop == 1 && ystop == 0 && leebot == 1 ){
if(rvtop == 0 && yibot == 0 && yitop == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yibot == 1 && yitop == 1 ){
Point = Point + 3 * Point / 4;
}
}
if(ysbot == 2 && leebot == 1 && ystop == 0 && leetop == 1 ){
if(rvtop == 0 && yitop == 0 && yibot == 0){
Point = Point + 5 * Point / 6 ;
}
if(rvtop == 1 || yitop == 1 || yibot == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 2 && xayahtop == 1 && leebot == 0 && xayahbot == 1 ){
if(yibot == 0 && rakanbot == 0 && rakantop == 0){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakanbot == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 2 && xayahbot == 1 && leetop == 0 && xayahtop == 1 ){
if(yitop == 0 && rakantop == 0 && rakanbot == 0){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakantop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop == 2 && xayahbot == 1 && leebot == 0 && xayahtop == 1 ){
if(yibot == 0 && rakantop == 0 && rakanbot == 0){
Point = Point + 5 * Point / 6 ;
}
if(yibot == 1 || rakantop == 1 || rakanbot == 1){
Point = Point + 3 * Point / 4;
}
}
if(leebot == 2 && xayahtop == 1 && leetop == 0 && xayahbot == 1 ){
if(yitop == 0 && rakanbot == 0 && rakantop == 0){
Point = Point + 5 * Point / 6 ;
}
if(yitop == 1 || rakanbot == 1 || rakantop == 1){
Point = Point + 3 * Point / 4;
}
}
if(leetop + leebot == 3){
if(yitop == 0 && yibot == 0){
Point *= 3;
}
if(yitop == 1|| yibot == 1){
Point /=4 ;
}
}
if(xayahtop + xayahbot == 3){
if(rakantop == 0 && rakanbot == 0){
Point *= 3;
}
if(rakantop == 1|| rakanbot == 1){
Point /=4 ;
}
}
if(ystop + ysbot == 3){
if(rvtop == 0 && rvbot == 0){
Point *= 3;
}
if(rvtop == 1|| rvbot == 1){
Point /= 4 ;
}
}
if(ystop + ysbot == 2){
if(rvtop == 1|| rvbot == 1){
Point /=3 ;
}
}
if(xayahtop + xayahbot == 2){
if(rakantop == 1|| rakanbot == 1){
Point /=3 ;
}
}
if(leetop + leebot == 2){
if(yitop == 1|| yibot == 1){
Point /= 3 ;
}
}
if(ystop + ysbot >= 5) Point = 0;
if(ystop + ysbot == 4) Point *=4;
if(ystop + ysbot == 3) Point *= 3;
if(xayahtop + xayahbot >= 5) Point = 0;
if(xayahtop + xayahbot == 4) Point *= 4;
if(xayahtop + xayahbot == 3) Point *= 3;
if(leetop + leebot >= 5) Point = 0;
if(leetop + leebot == 4) Point *= 4;
if(leetop + leebot == 3) Point *= 3;
return Point;
}
int defend(int i,int j){
int Point=0;
//HANG NGANG
int ystop = 0, rvtop = 0, ysbot = 0, rvbot = 0;
//Trai
for(int m = 1; m < 6 && j - 2 * m >= 0; m++){
if(a[i][j - 2 * m] == Honloan){
ystop++;
break;
}
if(a[i][j - 2 * m] == Trattu){
rvtop++;
}
if(a[i][j - 2 * m] == 0){
break;
}
}
//Phai
for(int m = 1; m < 6 && j + 2 * m <= 28;m++){
if(a[i][j + 2 * m] == Honloan){
ysbot++;
break;
}
if(a[i][j + 2 * m] == Trattu){
rvbot++;
}
if(a[i][j + 2 * m] == 0){
break;
}
}
//Cheo huyen
int xayahtop = 0, rakantop = 0, veigarmid = 0, xayahbot = 0, rakanbot = 0;
//Duoi len
for(int m = 1; m < 6 && i - m >= 0 && j - m >= 0;m++){
if(a[i - m][j - m] == Honloan) {
xayahtop++;
break;
}
if(a[i - m][j - m] == Trattu){
rakantop++;
}
if(a[i - m][j - m] == 0){
break;
}
}
//Tren xuong
for(int m = 1; m < 6 && i + m <= 10 && j + m <= 28; m++){
if(a[i + m][j + m] == Honloan) {
xayahbot++;
break;
}
if(a[i + m][j + m] == Trattu){
rakanbot++;
}
if(a[i + m][j + m] == 0){
break;
}
}
//Cheo sac
int leetop = 0, yitop = 0, leebot = 0, yibot = 0;
//Duoilen
for(int m = 1; m < 6 && i - m >= 0 && j + m <= 28 ; m++){
if(a[i - m][j + m] == Honloan){
leetop++;
break;
}
if(a[i - m][j + m] == Trattu){
yitop++;
}
if(a[i - m][j + m] == 0){
break;
}
}
//Trenxuong
for(int m = 1; m < 6 && i + m <= 10 && j - m >= 0; m++){
if(a[i + m][j - m] == Honloan){
leebot++;
break;
}
if(a[i + m][j - m] == Trattu){
yibot++;
}
if(a[i + m][j - m] == 0){
break;
}
}
if(ystop + ysbot == 2){
Point += 0;
}
else{
Point += DEF[rvtop + rvbot];
}
if(leetop + leebot == 2){
Point += 0;
}
else{
Point += DEF[yitop + yibot];
}
if(xayahtop + xayahbot == 2){
Point += 0;
}
else{
Point += DEF[rakantop + rakanbot];
}
if(rvtop == 2 && rakantop == 2 && rvbot == 0 && rakanbot == 0 ){
if(ysbot == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && rakanbot == 2 && rvbot == 0 && rakantop == 0 ){
if(ysbot == 0 && xayahtop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && yitop == 2 && rvbot == 0 && yibot == 0 ){
if(ysbot == 0 && leebot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leebot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && yibot == 2 && rvbot == 0 && yitop == 0 ){
if(ysbot == 0 && leetop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leetop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && rakantop == 2 && rvtop == 0 && rakanbot == 0 ){
if(ystop == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && rakanbot == 2 && rvtop == 0 && rakantop == 0 ){
if(ystop == 0 && xayahtop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && yitop == 2 && rvtop == 0 && yibot == 0 ){
if(ystop == 0 && leebot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leebot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && yibot == 2 && rvtop == 0 && yitop == 0 ){
if(ystop == 0 && leetop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leetop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 2 && rakantop == 2 && yibot == 0 && rakanbot == 0 ){
if(leebot == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 2 && rakanbot == 2 && yitop == 0 && rakantop == 0 ){
if(leetop == 0 && xayahtop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 2 && rakanbot == 2 && yibot == 0 && rakantop == 0 ){
if(leebot == 0 && xayahtop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 2 && rakantop == 2 && yitop == 0 && rakanbot == 0 ){
if(leetop == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 1 && rakantop == 2 && rvbot == 1 && rakanbot == 0 ){
if(ysbot == 0 && xayahbot == 0 && ystop == 0){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahbot == 1 || ystop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 1 && rakanbot == 2 && rvbot == 1 && rakantop == 0 ){
if(ysbot == 0 && xayahtop == 0 && ystop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahtop == 1 || ystop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 1 && yitop == 2 && rvbot == 1 && yibot == 0 ){
if(ysbot == 0 && leebot == 0 && ystop == 0){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leebot == 1 || ystop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 1 && yibot == 2 && rvbot == 1 && yitop == 0 ){
if(ysbot == 0 && leetop == 0 && ystop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leetop == 1 || ystop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 1 && rakantop == 2 && rvtop == 1 && rakanbot == 0 ){
if(ystop == 0 && xayahbot == 0 && ysbot == 0){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahbot == 1 || ysbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 1 && rakanbot == 2 && rvtop == 1 && rakantop == 0 ){
if(ystop == 0 && xayahtop == 0 && ysbot == 0){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahtop == 1 || ysbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 1 && yitop == 2 && rvtop == 1 && yibot == 0 ){
if(ystop == 0 && leebot == 0 && ysbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leebot == 1 || ysbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 1 && yibot == 2 && rvtop == 1 && yitop == 0 ){
if(ystop == 0 && leetop == 0 && ysbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leetop == 1 || ysbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 1 && rakantop == 2 && yibot == 1 && rakanbot == 0 ){
if(leebot == 0 && xayahbot == 0 && leetop == 0){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahbot == 1 || leetop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 1 && rakanbot == 2 && yitop == 1 && rakantop == 0 ){
if(leetop == 0 && xayahtop == 0 && leebot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahtop == 1 || leebot == 1 ){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 1 && rakanbot == 2 && yibot == 1 && rakantop == 0 ){
if(leebot == 0 && xayahtop == 0 && leetop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahtop == 1 || leetop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 1 && rakantop == 2 && yitop == 1 && rakanbot == 0 ){
if(leetop == 0 && xayahbot == 0 && leebot == 0){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahbot == 1 || leebot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && rakantop == 1 && rvbot == 0 && rakanbot == 1 ){
if(ysbot == 0 && xayahbot == 0 && xayahtop == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahbot == 1 || xayahtop == 1 ){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && rakanbot == 1 && rvbot == 0 && rakantop == 1 ){
if(ysbot == 0 && xayahtop == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || xayahtop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && yitop == 1 && rvbot == 0 && yibot == 1 ){
if(ysbot == 0 && leebot == 0 && leetop == 0){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leebot == 1 || leetop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvtop == 2 && yibot == 1 && rvbot == 0 && yitop == 1 ){
if(ysbot == 0 && leetop == 0 && leebot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ysbot == 1 || leetop == 1 || leebot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && rakantop == 1 && rvtop == 0 && rakanbot == 1 ){
if(ystop == 0 && xayahbot == 0 && xayahtop == 0){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahbot == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && rakanbot == 1 && rvtop == 0 && rakantop == 1 ){
if(ystop == 0 && xayahtop == 0 && xayahbot == 0 ){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || xayahtop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && yitop == 1 && rvtop == 0 && yibot == 1 ){
if(ystop == 0 && leebot == 0 && leetop == 0){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leebot == 1 && leetop == 1 ){
Point = Point + 2 * Point / 3;
}
}
if(rvbot == 2 && yibot == 1 && rvtop == 0 && yitop == 1 ){
if(ystop == 0 && leetop == 0 && leebot == 0){
Point = Point + 4 * Point / 5 ;
}
if(ystop == 1 || leetop == 1 || leebot == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 2 && rakantop == 1 && yibot == 0 && rakanbot == 1 ){
if(leebot == 0 && xayahbot == 0 && xayahtop == 0){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahbot == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 2 && rakanbot == 1 && yitop == 0 && rakantop == 1 ){
if(leetop == 0 && xayahtop == 0 && xayahbot == 0){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahtop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop == 2 && rakanbot == 1 && yibot == 0 && rakantop == 1 ){
if(leebot == 0 && xayahtop == 0 && xayahbot == 0){
Point = Point + 4 * Point / 5 ;
}
if(leebot == 1 || xayahtop == 1 || xayahbot == 1){
Point = Point + 2 * Point / 3;
}
}
if(yibot == 2 && rakantop == 1 && yitop == 0 && rakanbot == 1 ){
if(leetop == 0 && xayahbot == 0 && xayahtop == 0){
Point = Point + 4 * Point / 5 ;
}
if(leetop == 1 || xayahbot == 1 || xayahtop == 1){
Point = Point + 2 * Point / 3;
}
}
if(yitop + yibot == 3){
if(leetop == 0 && leebot == 0){
Point *= 2;
}
if(leetop == 1|| leebot == 1){
Point /=4 ;
}
}
if(rakantop + rakanbot == 3){
if(xayahtop == 0 && xayahbot == 0){
Point *= 2;
}
if(xayahtop == 1|| xayahbot == 1){
Point /=4 ;
}
}
if(rvtop + rvbot == 3){
if(ystop == 0 && ysbot == 0){
Point *= 2;
}
if(ystop == 1|| ysbot == 1){
Point /= 4 ;
}
}
if(yitop + yibot > 0){
Point -= ATT[leetop + leebot];
}
if(rvtop + rvbot > 0){
Point -= ATT[ystop + ysbot];
}
if(rakantop + rakanbot > 0){
Point -= ATT[xayahtop + xayahbot];
}
return Point;
}
void Fight(){
for(int m = 0;m <= 10; m++){
if(m % 2 == 0){
for(int n = 0;n <= 28; n += 2){
if(a[m][n] != 0){
b[m][n] = 0;
}
else{
b[m][n]+=attack(m,n)+defend(m,n);
}
}
}
else{
for(int n = 1;n <= 27;n += 2){
if(a[m][n] != 0){
b[m][n] = 0;
}
else{
b[m][n]+=attack(m,n)+defend(m,n);
}
}
}
}
}
void showdiem(){
for(int i=0;i<=10;i++){
if(i%2==0){
for(int j=0;j<=28;j+=2){
if(b[i][j]==0){
}
printf("%3d ",b[i][j]);
}
}
else{
for(int j=1;j<=27;j+=2){
printf(" %3d",b[i][j]);
}
}
cout<<endl;
}
}
int bestYS(){
int x = 0,y = 0,gg = 0;
for(int i = 0; i <= 10; i++){
if(i % 2 == 0){
for(int j = 0;j <= 28; j+=2){
if(b[i][j] >= gg){
x = i;y = j;gg = b[i][j];
}
}
}
else{
for(int j = 1;j <= 27; j+=2){
if(b[i][j] >= gg){
x = i;y = j;gg = b[i][j];
}
}
}
}
a[x][y]=Honloan;
return x*15+y/2;
}
void showdiem2(){
for(int i=0;i<=10;i++){
if(i%2==0){
for(int j=0;j<=28;j+=2){
printf("%3d ",a[i][j]);
}
}
else{
for(int j=1;j<=27;j+=2){
printf(" %3d",a[i][j]);
}
}
cout<<endl;
}
}
int main(){
int Move = 0;
for(int i = 0;i <= 10; i++){
if(i % 2 == 0){
for(int j = 0;j <= 28; j+=2){
cin>>a[i][j];
if(a[i][j] > 0) Move++;
}
}
else{
for(int j = 0;j <= 26; j+=2){
cin>>a[i][j + 1];
if(a[i][j + 1] > 0) Move++;
}
}
}
if(Move == 0){
cout<<"82";
return 0;
}
else{
if(Move % 2 == 0){
Honloan = 1;
Trattu = 2;
}
else{
Honloan = 2;
Trattu = 1;
}
}
Welcometosummonerrift();
Fight();
//showdiem();
cout<<bestYS()<<endl;
showdiem2();
}