#include <bits/stdc++.h>
using namespace std;
#define int long long
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n) - 1, 0, i)
#define upto(f, t, i) for(int i##0_to = (t), i = (f); i <= i##0_to; i++)
#define uptil(f, t, i) for(int i##0_to = (t), i = (f); i < i##0_to; i++)
#define downto(f, t, i) for(int i##0_to = (t), i = (f); i >= i##0_to; i--)
#define downtil(f, t, i) for(int i##0_to = (t), i = (f); i > i##0_to; i--)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#endif
#define ln << '\n'
#define tb << '\t'
#define sp << ' '
#define DD(x) if(debug) cerr << #x << " = " << (x) << ", "
#define DDD(x) if(debug) cerr << #x << " = " << (x) ln
#define db dd
#define dbg ddd
void solve();
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
cin.tie(0);
ios::sync_with_stdio(0);
#endif
cout << fixed << setprecision(20);
cerr << fixed << setprecision(20);
solve();
return 0;
}
#define firstItrSTValGE lower_bound
#define firstItrSTValGT upper_bound
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define amax(x, y) x = max(x, y)
#define amin(x, y) x = min(x, y)
#define vec vector
template<class T> inline istream& operator>>(istream& s, vec<T>& v) { for(auto&& p : v) s >> p; return s; }
#ifdef DEBUG
template<class T, class S> inline ostream& operator<<(ostream&, const pair<T, S>&);
template<class T> inline ostream& operator<<(ostream&, const vec<T>&);
template<class T, class S> inline ostream& operator<<(ostream&, const map<T, S>&);
#define DEFINE_ITER_OUTPUT(s, x, sep) { int i = 0; for(const auto& x##0_elem : x) { if(i++) s << sep; s << x##0_elem; } return s; }
template<class T, class S> inline ostream& operator<<(ostream& s, const pair<T, S>& p) { return s << "(" << p.first << "," << p.second << ")"; }
template<class T> inline ostream& operator<<(ostream& s, const vec<T>& v) DEFINE_ITER_OUTPUT(s, v, ' ')
template<class T, class S> inline ostream& operator<<(ostream& s, const map<T, S>& m) DEFINE_ITER_OUTPUT(s, m, ' ')
template<class T> inline ostream& operator<<(ostream& s, const vec<vec<T>>& w) DEFINE_ITER_OUTPUT(s, w, '\n')
template<class T, class S> inline ostream& operator<<(ostream& s, const vec<map<T, S>>& vm) DEFINE_ITER_OUTPUT(s, vm, '\n')
template<class T> inline void dddf(const T& t) { cerr << t ln; }
template<class T, class...U> inline void dddf(const T& t, const U&... u) { cerr << t << ", "; dddf(u...); }
#define ddd(...) { cerr << #__VA_ARGS__ << " = "; dddf(__VA_ARGS__); }
#else
#define ddd(...) {}
#endif
#define all(v) begin(v), end(v)
template<class T> inline T max(const pair<T, T>& p) { return max(p.first, p.second); }
template<class T> inline T min(const pair<T, T>& p) { return min(p.first, p.second); }
template<class T> inline T max(const vec<T>& v) { return *max_element(all(v)); }
template<class T> inline T min(const vec<T>& v) { return *min_element(all(v)); }
template<class T> inline T sum(const vec<T>& v) { T s = v.empty() ? 0 : v[0]; uptil(1, v.size(), i) s += v[i]; return s; }
template<class T> inline T sum(const vec<T>& v, int mod) { T s = v.empty() ? 0 : v[0]; uptil(1, v.size(), i) (s += v[i]) %= mod; return s; }
template<class T, class U> inline T dig(const U& d, const T& t) { return t; }
template<class T, class U, class...I> inline U dig(const U& d, const T& t, int i, I... j) {
return 0 <= i && i < t.size() ? dig(d, t[i], j...) : d; }
#define INF (1LL << 60)
constexpr int Turn = 20, H = 10, W = 10;
#define Stage vec<vec<int>>
inline void putOne(Stage& s, int i, int j) {
++s[i][j];
if(s[i][j] < 0) {
s[i][j] = min(0ll, s[i][j] + 1);
}
s[i][j] = min(3ll, max(-3ll, s[i][j]));
}
void put(Stage& s, int i, int j, int r) {
putOne(s, i, j);
putOne(s, i + r, j + !r);
putOne(s, i + 2*r, j + 2*!r);
}
int score(const Stage& s) {
double sum = 0;
int mx = INT_MIN;
vec<int> lens;
times(H, i) {
int a = 0, l = 0, lm = 0;
times(W, j) {
a += s[i][j] + (s[i][j] > 0) - (s[i][j] < 0);
if(s[i][j] > 0) ++l;
else l = 0;
amax(lm, l);
}
sum += (a > 0 ? 1 : -1) * pow(abs(a), 1.5);
amax(mx, a);
}
times(W, j) {
int a = 0, l = 0, lm = 0;
times(H, i) {
a += s[i][j] + (s[i][j] > 0) - (s[i][j] < 0);
if(s[i][j] > 0) ++l;
else l = 0;
amax(lm, l);
}
sum += (a > 0 ? 1 : -1) * pow(abs(a), 1.5);
amax(mx, a);
}
return (int)sum + mx * 10;
}
void solve() {
srand((unsigned) time(NULL));
int T; scanf("%lld", &T);
Stage V(H, vec<int>(W)), v0;
times(H, i) times(W, j) scanf("%lld", &V[i][j]);
if(T == 0) {
cout << 4 sp << 6 sp << 0 ln;
return;
}
int x, y, rot, best = INT_MIN;
times(2, r) times(H, i) times(W, j) {
if(r == 0 && j >= W-2 || r == 1 && i >= W-2) continue;
v0 = V;
put(V, i, j, r);
int sc = score(V);
if(best < sc) {
best = sc;
x = j; y = i; rot = r;
}
V = v0;
}
cout << x+1 sp << y+1 sp << rot ln;
}
Battle History