QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#745090#6432. Puzzle in InazumamaspyAC ✓3ms7184kbC++2317.2kb2024-11-14 04:06:402024-11-14 04:06:40

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 04:06:40]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:7184kb
  • [2024-11-14 04:06:40]
  • 提交

answer

#line 1 "library/my_template.hpp"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define FOR4_R(i, a, b, c) for (ll i = (b)-1; i >= ll(a); i -= (c))
#define overload4(a, b, c, d, e, ...) e
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) \
  overload4(__VA_ARGS__, FOR4_R, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) for (ll t = s; t >= 0; t = (t == 0 ? -1 : (t - 1) & s))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

template <typename T>
T SUM(vector<T> &A) {
  T sum = T(0);
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}

template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}

template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

ll binary_search(function<bool(ll)> check, ll ok, ll ng) {
  assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    if (check(x))
      ok = x;
    else
      ng = x;
  }
  return ok;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

vi s_to_vi(const string &S, char first_char) {
  vi A(S.size());
  FOR(i, S.size()) { A[i] = S[i] - first_char; }
  return A;
}

template <typename T>
vector<T> cumsum(vector<T> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

template <typename CNT, typename T>
vc<CNT> bincount(const vc<T> &A, int size) {
  vc<CNT> C(size);
  for (auto &&x: A) { ++C[x]; }
  return C;
}

template <typename T>
vector<int> argsort(const vector<T> &A) {
  // stable
  vector<int> ids(A.size());
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return A[i] < A[j] || (A[i] == A[j] && i < j); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  int n = len(A);
  assert(len(I) == n);
  vc<T> B(n);
  FOR(i, n) B[i] = A[I[i]];
  return B;
}
#line 1 "library/other/io.hpp"
// based on yosupo's fastio
#include <unistd.h>

namespace detail {
template <typename T, decltype(&T::is_modint) = &T::is_modint>
std::true_type check_value(int);
template <typename T>
std::false_type check_value(long);
} // namespace detail

template <typename T>
struct is_modint : decltype(detail::check_value<T>(0)) {};
template <typename T>
using is_modint_t = enable_if_t<is_modint<T>::value>;
template <typename T>
using is_not_modint_t = enable_if_t<!is_modint<T>::value>;

struct Scanner {
  FILE *fp;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) { ref = 10 * ref + (line[st++] & 0xf); }
    if (neg) ref = -ref;
    return true;
  }
  template <class T, is_modint_t<T> * = nullptr>
  bool read_single(T &ref) {
    long long val = 0;
    bool f = read_single(val);
    ref = T(val);
    return f;
  }
  bool read_single(double &ref) {
    string s;
    if (!read_single(s)) return false;
    ref = std::stod(s);
    return true;
  }
  bool read_single(char &ref) {
    string s;
    if (!read_single(s) || s.size() != 1) return false;
    ref = s[0];
    return true;
  }
  template <class T>
  bool read_single(vector<T> &ref) {
    for (auto &d: ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T, class U>
  bool read_single(pair<T, U> &p) {
    return (read_single(p.first) && read_single(p.second));
  }
  template <class A, class B, class C>
  bool read_single(tuple<A, B, C> &p) {
    return (read_single(get<0>(p)) && read_single(get<1>(p))
            && read_single(get<2>(p)));
  }
  template <class A, class B, class C, class D>
  bool read_single(tuple<A, B, C, D> &p) {
    return (read_single(get<0>(p)) && read_single(get<1>(p))
            && read_single(get<2>(p)) && read_single(get<3>(p)));
  }
  void read() {}
  template <class H, class... T>
  void read(H &h, T &... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE *fp) : fp(fp) {}
};

struct Printer {
  Printer(FILE *_fp) : fp(_fp) {}
  ~Printer() { flush(); }

  static constexpr size_t SIZE = 1 << 15;
  FILE *fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write(const char &val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write('0');
      return;
    }
    if (val < 0) {
      write('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) { line[pos + i] = small[len - 1 - i]; }
    pos += len;
  }
  void write(const string &s) {
    for (char c: s) write(c);
  }
  void write(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write(s[i]);
  }
  void write(const double &x) {
    ostringstream oss;
    oss << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  void write(const long double &x) {
    ostringstream oss;
    oss << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  template <class T, is_modint_t<T> * = nullptr>
  void write(T &ref) {
    write(ref.val);
  }
  template <class T>
  void write(const vector<T> &val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  template <class T, class U>
  void write(const pair<T, U> &val) {
    write(val.first);
    write(' ');
    write(val.second);
  }
  template <class A, class B, class C>
  void write(const tuple<A, B, C> &val) {
    auto &[a, b, c] = val;
    write(a), write(' '), write(b), write(' '), write(c);
  }
  template <class A, class B, class C, class D>
  void write(const tuple<A, B, C, D> &val) {
    auto &[a, b, c, d] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d);
  }
  template <class A, class B, class C, class D, class E>
  void write(const tuple<A, B, C, D, E> &val) {
    auto &[a, b, c, d, e] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d), write(' '), write(e);
  }
  template <class A, class B, class C, class D, class E, class F>
  void write(const tuple<A, B, C, D, E, F> &val) {
    auto &[a, b, c, d, e, f] = val;
    write(a), write(' '), write(b), write(' '), write(c), write(' '), write(d), write(' '), write(e), write(' '), write(f);
  }
  template <class T, size_t S>
  void write(const array<T, S> &val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  void write(i128 val) {
    string s;
    bool negative = 0;
    if(val < 0){
      negative = 1;
      val = -val;
    }
    while (val) {
      s += '0' + int(val % 10);
      val /= 10;
    }
    if(negative) s += "-";
    reverse(all(s));
    if (len(s) == 0) s = "0";
    write(s);
  }
};

Scanner scanner = Scanner(stdin);
Printer printer = Printer(stdout);

void flush() { printer.flush(); }
void print() { printer.write('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  printer.write(head);
  if (sizeof...(Tail)) printer.write(' ');
  print(forward<Tail>(tail)...);
}

void read() {}
template <class Head, class... Tail>
void read(Head &head, Tail &... tail) {
  scanner.read(head);
  read(tail...);
}

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)      \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 1 "library/other/random.hpp"
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  ll operator()(ll a, ll b) {  // [a, b)
    uniform_int_distribution<ll> dist(a, b - 1);
    return dist(mt);
  }

  ll operator()(ll b) {  // [0, b)
    return (*this)(0, b);
  }
};
#line 4 "main.cpp"

void solve() {
  LL(N);
  vv(ll, G, N, N);
  FOR(i, N) FOR(j, i + 1, N) {
    LL(x);
    G[i][j] += x, G[j][i] += x;
  }
  FOR(i, N) FOR(j, i + 1, N) {
    LL(x);
    G[i][j] -= x, G[j][i] -= x;
  }
  using T = tuple<ll, ll, ll, ll, ll>;
  vc<T> ANS;

  auto ope = [&](ll a, ll b, ll c, ll d, ll x) -> void {
    assert(0 <= min({a, b, c, d}) && max({a, b, c, d}) < N);
    assert(a != b);
    assert(a != c);
    assert(a != d);
    assert(b != c);
    assert(b != d);
    assert(c != d);
    if (x == 0) return;
    G[a][b] += x, G[b][a] += x;
    G[a][c] += x, G[c][a] += x;
    G[a][d] += x, G[d][a] += x;
    G[b][c] -= x, G[c][b] -= x;
    G[b][d] -= x, G[d][b] -= x;
    G[c][d] -= x, G[d][c] -= x;
    ANS.eb(a, b, c, d, x);
  };

  auto out = [&]() -> void {
    FOR(i, N) FOR(j, N) if (G[i][j] != 0) return print(-1);
    print(len(ANS));
    for (auto&& [a, b, c, d, x]: ANS) print(a + 1, b + 1, c + 1, d + 1, x);
  };

  if (N == 4) {
    vi A(4);
    FOR(i, N) A[i] = SUM(G[i]);
    ll x0 = (A[3] - A[0]) / 4;
    ll x1 = (A[3] - A[1]) / 4;
    ll x2 = (A[3] - A[2]) / 4;
    ope(0, 1, 2, 3, x0);
    ope(1, 0, 2, 3, x1);
    ope(2, 0, 1, 3, x2);
    return out();
  }

  // solve F2
  auto check = [&]() -> bool {
    FOR(i, N) FOR(j, N) if (G[i][j] % 2 != 0) return false;
    return true;
  };

  const int thresh = 6;
  if (N <= thresh) {
    RandomNumberGenerator RNG;
    vc<T> cand;
    FOR(s, 1 << N) {
      if (popcnt(s) != 4) continue;
      vi I;
      FOR(i, N) if (s & 1 << i) I.eb(i);
      cand.eb(I[0], I[1], I[2], I[3], 1);
      cand.eb(I[1], I[0], I[2], I[3], 1);
      cand.eb(I[2], I[0], I[1], I[3], 1);
      cand.eb(I[3], I[0], I[1], I[2], 1);
    }

    FOR(50000) {
      if (check()) break;
      ll i = RNG(0, len(cand));
      auto [a, b, c, d, x] = cand[i];
      ope(a, b, c, d, x);
    }
  }

  if (N > thresh) {
    auto f = [&](int i, int j) -> void {
      // 辺 01 と辺 ij を flip する
      ll a = [&]() -> int {
        FOR(x, N) if (x != 0 && x != 1 && x != i && x != j) return x;
        return -1;
      }();
      ll b = [&]() -> int {
        FOR(x, N) if (x != 0 && x != 1 && x != i && x != j && x != a) return x;
        return -1;
      }();
      ll c = [&]() -> int {
        FOR(x, N)
        if (x != 0 && x != 1 && x != i && x != j && x != a && x != b) return x;
        return -1;
      }();

      if (i == 0) {
        ope(0, 1, a, b, 1);
        ope(0, 1, a, c, 1);
        ope(0, 1, b, c, 1);
        ope(0, j, a, b, 1);
        ope(0, j, a, c, 1);
        ope(0, j, b, c, 1);
        return;
      }
      if (i == 1) {
        ope(1, 0, a, b, 1);
        ope(1, 0, a, c, 1);
        ope(1, 0, b, c, 1);
        ope(1, j, a, b, 1);
        ope(1, j, a, c, 1);
        ope(1, j, b, c, 1);
        return;
      }
      // 01 and 0i
      ope(0, 1, a, b, 1);
      ope(0, 1, a, c, 1);
      ope(0, 1, b, c, 1);
      ope(0, i, a, b, 1);
      ope(0, i, a, c, 1);
      ope(0, i, b, c, 1);
      // 0i and ij
      ope(i, 0, a, b, 1);
      ope(i, 0, a, c, 1);
      ope(i, 0, b, c, 1);
      ope(i, j, a, b, 1);
      ope(i, j, a, c, 1);
      ope(i, j, b, c, 1);
    };

    FOR(i, N) FOR(j, i + 1, N) {
      if (i == 0 && j == 1) continue;
      if (G[i][j] % 2 == 0) continue;
      f(i, j);
    }
  }

  auto add_ab_sub_cd = [&](ll a, ll b, ll c, ll d, ll x) -> void {
    // distinct なとき
    ope(a, b, c, d, x / 2);
    ope(b, a, c, d, x / 2);
  };

  auto g = [&](int i, int j) -> void {
    ll x = G[i][j];
    if (i >= 2) {
      add_ab_sub_cd(i, j, 0, 1, -x);
      return;
    }
    // ij を 0 にして、01 に押し付ける
    ll a = [&]() -> int {
      FOR(x, N) if (x != 0 && x != 1 && x != i && x != j) return x;
      return -1;
    }();
    ll b = [&]() -> int {
      FOR(x, N) if (x != 0 && x != 1 && x != i && x != j && x != a) return x;
      return -1;
    }();

    add_ab_sub_cd(i, j, a, b, -x);
    add_ab_sub_cd(a, b, 0, 1, -x);
  };

  FOR(i, N) FOR(j, i + 1, N) {
    if (i == 0 && j == 1) continue;
    g(i, j);
  }

  // FOR(i, N) print(G[i]);
  return out();
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15);

  // LL(T);
  ll T = 1;
  FOR(T) solve();

  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3868kb

input:

4
0 1 1
0 0
1
1 0 0
1 1
0

output:

1
2 1 3 4 1

result:

ok n=4

Test #2:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

4
3 3 3
0 0
0
0 0 0
3 3
3

output:

1
1 2 3 4 -3

result:

ok n=4

Test #3:

score: 0
Accepted
time: 0ms
memory: 7184kb

input:

5
-12 15 -12 1
37 14 7
7 9
-11
12 5 1 13
-1 -4 -7
-5 -9
18

output:

-1

result:

ok n=5

Test #4:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

4
37 81 -38
-79 -8
-42
20 -55 80
-23 -43
37

output:

-1

result:

ok n=4

Test #5:

score: 0
Accepted
time: 3ms
memory: 6920kb

input:

5
-22 63 -23 7
-11 36 66
66 -77
36
-87 -17 95 -65
-93 53 63
-54 -56
-77

output:

-1

result:

ok n=5

Test #6:

score: 0
Accepted
time: 1ms
memory: 4012kb

input:

6
-59 77 100 -28 -80
-14 -19 34 0
-8 34 44
58 38
7
87 -53 -57 -79 86
-19 -97 -51 -29
42 -14 61
-6 25
-24

output:

-1

result:

ok n=6

Test #7:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

10
96 -62 71 43 -41 62 37 -17 -73
-51 55 89 63 -17 81 98 78
-96 -70 -16 78 -63 49 86
20 -76 -21 8 -32 16
-93 45 -65 99 65
9 81 47 -2
-50 94 2
29 -77
77
67 -91 -97 -13 -75 -8 -79 21 -86
-44 -55 -92 19 -62 47 25 -88
-89 -10 1 94 -61 78 -70
8 30 -54 -9 19 -60
35 -21 -79 40 92
-56 -12 -56 2
-38 23 -31
2...

output:

-1

result:

ok n=10

Test #8:

score: 0
Accepted
time: 1ms
memory: 4020kb

input:

30
79 75 -71 -8 36 26 -38 -45 43 44 64 52 -23 -64 -73 97 -79 70 24 58 -9 11 14 58 -95 -88 -10 -80 -47
20 -55 86 89 -39 15 26 -32 38 -23 -30 -12 -4 81 39 -13 -43 -11 -38 -70 14 32 -67 -54 38 -80 -80 97
-49 -92 53 -94 -60 -77 -80 -11 75 51 43 52 -28 58 -26 71 -85 66 96 -61 52 -100 -49 93 92 -37 62
-55...

output:

-1

result:

ok n=30

Test #9:

score: 0
Accepted
time: 1ms
memory: 3940kb

input:

50
-47 49 10 46 -54 -70 -39 36 -1 100 -78 -27 23 43 15 -21 71 48 -82 95 85 -11 -99 35 -44 -31 70 -94 12 -45 -81 75 62 89 14 85 -82 -25 2 5 54 -25 -96 -30 -12 -70 13 -51 15
-48 -13 -53 49 19 -62 -15 -99 54 29 17 67 31 -58 80 -2 -97 -40 59 64 84 15 -32 76 -18 35 76 68 -69 47 51 -26 64 -70 71 14 -3 47 ...

output:

-1

result:

ok n=50

Test #10:

score: 0
Accepted
time: 0ms
memory: 5948kb

input:

100
-25 31 38 48 -19 32 87 -10 -30 -88 -79 98 -99 56 -52 -86 -89 51 77 -36 -52 72 -78 48 30 42 -45 84 -75 -71 -83 -48 92 -44 6 -83 -87 -82 -17 40 -44 82 64 -90 89 -34 88 10 -26 -84 -51 -29 86 -55 55 78 12 -38 -96 28 -78 52 -30 85 72 79 57 8 71 -68 -81 -21 14 44 -42 -26 42 95 20 -78 18 29 100 39 -19 ...

output:

-1

result:

ok n=100

Test #11:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

4
75 -69 93
78 24
-61
75 59 80
-50 31
-55

output:

-1

result:

ok n=4

Test #12:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

4
44 -25 -81
84 8
95
-70 -21 82
32 28
74

output:

-1

result:

ok n=4

Test #13:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

4
91 -18 -46
-80 -34
38
-25 18 -40
-35 86
-53

output:

-1

result:

ok n=4

Test #14:

score: 0
Accepted
time: 3ms
memory: 5960kb

input:

5
-16 92 -94 -83
-83 16 -74
75 3
-43
-28 45 -63 -100
-11 -39 -80
62 -14
21

output:

-1

result:

ok n=5

Test #15:

score: 0
Accepted
time: 0ms
memory: 5960kb

input:

5
-95 7 -3 76
57 -85 -98
-64 -28
70
5 48 -42 -99
-56 22 21
-51 74
-85

output:

-1

result:

ok n=5

Test #16:

score: 0
Accepted
time: 3ms
memory: 5904kb

input:

5
-10 31 33 -71
33 -49 4
72 -72
65
-74 55 20 41
61 62 -83
50 -1
-95

output:

-1

result:

ok n=5

Test #17:

score: 0
Accepted
time: 1ms
memory: 3796kb

input:

6
65 -33 2 -67 83
40 93 -28 86
54 -30 -11
56 40
-66
82 42 -32 -56 98
1 85 17 45
-12 -3 -50
-39 6
100

output:

2126
6 1 3 4 1
3 2 4 5 1
6 2 3 5 1
6 3 4 5 1
3 1 4 6 1
5 1 2 3 1
4 1 5 6 1
2 4 5 6 1
4 1 3 6 1
2 3 5 6 1
2 4 5 6 1
3 1 4 6 1
5 1 2 3 1
2 1 3 4 1
2 3 5 6 1
1 4 5 6 1
2 1 3 6 1
6 2 3 4 1
5 2 3 4 1
5 2 3 6 1
1 2 4 6 1
5 1 3 4 1
1 2 4 5 1
4 1 2 5 1
4 1 3 5 1
3 1 2 6 1
1 2 4 6 1
4 1 2 6 1
5 2 3 4 1
4 3 5...

result:

ok n=6

Test #18:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

10
-68 -48 27 80 89 -22 -43 34 43
-41 -4 -10 -90 -62 -11 83 22
-64 -77 84 -20 -56 -56 -79
49 -54 90 19 75 6
41 6 -33 -29 -39
45 -27 7 6
-57 93 -53
-46 -85
-37
40 -49 -32 -28 -16 -71 -97 -99 -67
6 34 -65 -97 95 -99 72 -34
81 32 16 -49 -71 61 -83
89 -23 2 35 -20 50
-14 32 83 31 -43
-15 74 -87 22
-56 -...

output:

348
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 5 1
1 2 3 6 1
1 2 5 6 1
1 4 3 5 1
1 4 3 6 1
1 4 5 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 7 3 4 1
1 7 3 5 1
1 7 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4 ...

result:

ok n=10

Test #19:

score: 0
Accepted
time: 1ms
memory: 3960kb

input:

30
-14 20 -41 -72 25 -17 -90 -2 12 -45 -13 -43 78 -3 15 -25 -5 43 38 -59 -20 -25 29 0 18 -54 49 -13 -88
87 -6 -53 -40 -13 6 -50 -38 -73 -15 95 88 -48 86 96 -63 -2 -49 -85 -19 -44 -11 -94 -51 -68 -71 -40 9
-11 -35 73 6 -10 -67 39 37 6 -3 81 -39 -89 -49 38 17 -25 2 11 -100 22 52 -39 -24 8 -78 13
51 81...

output:

3338
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 14 3 4 1
1 14 3 5 1
1 1...

result:

ok n=30

Test #20:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

50
-98 59 55 -73 49 29 73 -28 51 -81 77 88 -54 -2 58 6 17 -56 15 66 8 -86 96 -41 -33 93 84 4 -14 18 46 64 3 -73 -3 -65 49 30 35 -84 82 -66 93 83 -46 -42 95 -88 32
82 -2 -69 78 -69 -29 95 -25 -96 23 -78 -2 12 77 -79 65 13 17 69 14 91 82 43 -91 -25 6 8 17 -98 8 17 36 17 -80 91 -3 -35 -88 91 -89 80 25 ...

output:

9882
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 10 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 11 3 4 1
1 11 3 5 1
1 11 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 12 3 4 1
1 12 3 5 1
1 12 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 14 3 4 1
1 14 3 5 1
1 14 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 15 3 4 1
1 ...

result:

ok n=50

Test #21:

score: 0
Accepted
time: 3ms
memory: 6140kb

input:

100
-93 27 9 49 -69 -2 26 37 -10 -52 43 81 96 -10 32 46 -18 13 14 59 -58 3 -68 33 -62 -13 39 93 15 -81 -6 96 -81 -50 77 50 93 95 11 79 86 25 -28 48 77 5 -9 89 9 -62 86 -45 -50 70 -94 75 12 47 73 -26 -83 -29 -28 -70 -31 58 -67 63 47 9 -95 -52 94 -22 -96 -84 16 53 -14 -98 -11 26 -59 -28 -60 -80 -76 -2...

output:

39088
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 10 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 11 3 4 1
1 11 3 5 1...

result:

ok n=100

Test #22:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

4
63 -85 -96
73 -75
-24
-17 1 -24
-83 -8
-13

output:

-1

result:

ok n=4

Test #23:

score: 0
Accepted
time: 3ms
memory: 5856kb

input:

5
25 -22 24 37
-48 67 25
97 -55
57
-82 -44 -25 27
-35 89 81
88 37
71

output:

-1

result:

ok n=5

Test #24:

score: 0
Accepted
time: 1ms
memory: 4040kb

input:

6
-59 84 42 67 72
-51 -86 -37 -2
61 -84 -78
-8 -81
76
61 41 -3 32 -74
30 -39 -37 -13
-23 100 -24
-90 -41
-4

output:

1576
5 1 4 6 1
4 1 2 6 1
3 1 4 6 1
3 2 5 6 1
1 2 4 5 1
2 4 5 6 1
6 1 4 5 1
5 2 4 6 1
2 3 4 6 1
4 1 3 6 1
3 2 4 5 1
4 1 2 6 1
6 1 2 3 1
4 3 5 6 1
1 2 5 6 1
3 4 5 6 1
6 2 3 4 1
5 1 2 3 1
6 3 4 5 1
2 1 3 4 1
5 2 3 4 1
6 1 3 5 1
6 1 2 3 1
2 1 3 5 1
4 2 5 6 1
2 4 5 6 1
1 2 5 6 1
5 1 2 6 1
2 4 5 6 1
4 1 3...

result:

ok n=6

Test #25:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

7
98 -77 33 -59 44 21
-71 -78 42 82 -60
6 76 96 -18
53 96 1
-72 -53
-86
69 40 -13 -11 63 55
-70 86 -49 -29 -34
-4 -51 67 19
-81 1 70
-77 10
13

output:

186
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
2 1 4 5 1
2 1 4 6 1
2 1 5 6 1
2 3 4 5 1
2 3 4 6 1
2 3 5 6 1
2 1 3 4 1
2 1 3 6 1
2 1 4 6 1
2 5 3 4 1
2 5 3 6 1
2 5 4 6 1
2 1 3 4 1
2 1 3 5 1
2 1 4 5 1
2 6 3 4 1
2 6 3 5 1
2 6 4 ...

result:

ok n=7

Test #26:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

37
1 -86 11 -63 -41 -21 99 14 28 17 63 66 24 53 2 -79 9 -95 -63 -40 12 -9 -71 90 -33 -13 -22 -36 50 31 -63 -1 7 -35 100 97
-57 -66 60 57 -30 8 32 -95 99 -67 -1 14 -75 83 42 -17 86 90 -33 -52 21 48 12 -69 -37 -25 74 -14 39 -20 65 38 14 -59 89
59 -3 91 76 -16 20 1 -85 51 -23 -24 49 10 -28 -11 -96 16 -...

output:

5178
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 5 1
1 2 3 6 1
1 2 5 6 1
1 4 3 5 1
1 4 3 6 1
1 4 5 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4...

result:

ok n=37

Test #27:

score: 0
Accepted
time: 2ms
memory: 4708kb

input:

71
100 39 36 -14 -71 -95 1 23 -66 -23 58 46 83 67 16 95 -77 21 -87 20 69 -50 -74 -69 90 75 -18 84 -45 63 63 51 34 58 -51 90 -91 -50 -89 58 3 63 56 -58 -51 16 72 -36 36 64 -67 38 42 -93 76 -51 0 21 58 37 -4 26 -22 -12 72 93 -98 51 -11 -47
95 95 -17 -51 67 -38 63 74 52 89 80 -94 37 -18 -73 -32 -94 17 ...

output:

19372
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 5 1
1 2 3 6 1
1 2 5 6 1
1 4 3 5 1
1 4 3 6 1
1 4 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 11 3 4 1
1 11 3 5 1
1 ...

result:

ok n=71

Test #28:

score: 0
Accepted
time: 3ms
memory: 6020kb

input:

97
-73 49 60 15 -5 57 94 79 -7 51 -26 -21 -78 -67 31 90 7 46 -75 -82 3 24 -28 81 -77 -100 53 65 6 -63 17 100 13 -19 14 67 -31 7 92 45 61 58 -83 8 65 93 -35 94 97 97 80 -45 63 -15 57 -40 -65 -67 -32 12 -26 -99 32 -62 28 27 -25 52 -45 39 27 -34 78 65 -23 91 -71 -46 5 -36 84 -11 44 44 -74 -62 -91 -75 2...

output:

36750
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 10 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 11 3 4 1
1 11 3 5 1...

result:

ok n=97

Test #29:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

59
-83 56 51 -64 30 35 52 -22 -54 -36 76 25 37 39 -26 -10 2 -99 71 95 -67 -2 33 9 -79 97 -18 -56 -54 99 -2 -3 -64 -42 -72 81 -84 5 -39 93 -72 -90 19 4 95 -30 28 -1 -81 -59 47 15 -94 -59 87 0 82 26
42 76 56 47 -5 26 -76 85 -16 -16 68 -19 26 -93 0 24 -47 20 16 -63 75 -36 -2 -88 38 -14 -70 27 -98 -70 4...

output:

13276
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 7 3 4 1
1 7 3 5 1
1 7 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 ...

result:

ok n=59

Test #30:

score: 0
Accepted
time: 3ms
memory: 6960kb

input:

100
33 54 -87 -27 79 -67 -64 29 -32 49 -43 87 29 -64 38 -27 47 -67 -57 -66 -84 -67 68 -34 -12 -50 -55 -75 -96 0 71 -49 46 -39 63 -48 -60 -53 -92 18 -33 51 1 47 -100 42 81 -40 -14 43 -51 -7 -77 30 -20 -93 -99 -70 26 52 -58 -74 57 -54 -3 93 58 -90 32 -100 -72 51 -93 48 19 84 -89 77 55 12 -45 -5 39 5 -...

output:

39384
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 11 3 4 1
1 11 3 5 1
1 ...

result:

ok n=100

Test #31:

score: 0
Accepted
time: 0ms
memory: 6012kb

input:

100
68 -49 44 23 8 57 17 32 21 46 43 -84 -62 63 -83 99 -63 59 -11 31 83 -62 -24 66 -50 81 30 -55 -7 -82 68 73 -31 -33 -65 -91 -70 -68 73 50 -87 86 58 14 8 -24 31 37 66 -46 38 -64 -79 13 15 88 -29 29 -84 0 -10 -75 -100 -26 -50 -38 36 -35 85 48 58 -98 5 63 40 -61 93 -52 -37 16 -6 72 -77 -83 -87 50 -20...

output:

39306
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 7 3 4 1
1 7 3 5 1
1 7 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 ...

result:

ok n=100

Test #32:

score: 0
Accepted
time: 3ms
memory: 5952kb

input:

100
-54 27 -16 97 15 -92 -66 73 -13 12 44 -10 -47 95 -25 -67 21 73 -19 -7 96 1 98 66 -58 16 -49 26 9 -97 90 -58 -17 -26 69 1 -37 -40 33 -36 14 -74 -44 -83 -44 66 -52 -11 95 -66 46 -72 37 67 28 40 -63 37 -24 -29 24 28 41 2 -41 71 -29 25 26 93 59 11 -66 -60 70 24 -42 -65 79 -56 -24 77 23 51 -19 25 9 3...

output:

38958
1 2 4 5 1
1 2 4 6 1
1 2 5 6 1
1 3 4 5 1
1 3 4 6 1
1 3 5 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 7 3 4 1
1 7 3 5 1
1 7 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 10 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 12 3 4 1
1 12 3 5 1...

result:

ok n=100

Test #33:

score: 0
Accepted
time: 3ms
memory: 6044kb

input:

5
96 70 0 -25
3 10 -61
-40 8
58
62 43 24 82
-81 -49 68
88 -20
-98

output:

-1

result:

ok n=5

Test #34:

score: 0
Accepted
time: 0ms
memory: 6032kb

input:

5
43 -6 -77 19
84 1 -9
-87 67
-68
-42 -48 77 65
17 -1 -86
-22 -42
49

output:

-1

result:

ok n=5

Test #35:

score: 0
Accepted
time: 3ms
memory: 5944kb

input:

5
-85 -81 -99 97
10 -58 -26
-7 48
1
71 -68 -86 -65
84 41 -74
-84 41
-60

output:

-1

result:

ok n=5

Test #36:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

5
-59 -76 -34 15
-16 76 -35
82 -35
-41
-70 -91 31 82
94 -50 -1
8 -37
-89

output:

74
2 1 3 4 1
5 1 3 4 1
4 1 3 5 1
3 2 4 5 1
3 1 4 5 1
5 1 3 4 1
4 2 3 5 1
2 1 4 5 1
2 1 3 4 1
1 2 3 5 1
5 1 3 4 1
5 2 3 4 1
4 1 2 3 1
4 1 2 5 1
4 1 3 5 1
5 1 2 4 1
2 1 3 5 1
1 2 4 5 1
2 1 3 4 1
2 1 4 5 1
4 1 2 3 1
4 1 3 5 1
1 2 3 4 1
1 2 3 4 1
2 1 3 5 1
3 1 2 5 1
3 2 4 5 1
4 2 3 5 1
3 1 2 4 1
1 3 4 5...

result:

ok n=5

Test #37:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

4
-52 -78 -9
100 30
51
14 62 -52
86 -86
18

output:

-1

result:

ok n=4

Test #38:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

4
-74 73 69
-54 -65
44
59 -50 -46
32 -49
47

output:

-1

result:

ok n=4

Test #39:

score: 0
Accepted
time: 0ms
memory: 7076kb

input:

100
-61 -13 42 41 82 78 99 70 15 -38 76 -21 80 27 9 33 77 -15 -58 -80 -32 -8 52 -53 56 -86 -79 19 -26 -74 68 -92 61 9 2 -65 -92 47 -81 53 65 92 27 -84 94 -78 29 -61 27 68 91 -18 -95 64 67 -73 77 23 -77 -87 84 66 -84 -14 27 -64 -27 -74 -65 74 -65 69 -23 -75 -70 -77 -26 61 -23 47 -20 -5 1 -1 38 97 26 ...

output:

39486
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 6 3 4 1
1 6 3 5 1
1 6 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 8 3 4 1
1 8 3 5 1
1 8 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 12 3 4 1
1 12 3 5 1
1 ...

result:

ok n=100

Test #40:

score: 0
Accepted
time: 0ms
memory: 6036kb

input:

100
-80 84 40 30 -73 76 -79 9 32 -61 86 -44 13 -8 -97 -85 -9 76 75 85 -2 -22 25 58 -37 4 -86 64 -89 25 14 32 11 -71 -62 -55 -78 19 -54 -2 12 56 -78 33 74 1 -98 -1 -41 19 71 0 24 -5 -59 -92 78 62 -84 59 75 95 -27 22 -88 77 50 80 25 -77 29 -28 -34 -98 81 43 -91 -31 21 100 31 -96 -5 -51 -1 80 -23 9 15 ...

output:

39346
1 2 3 5 1
1 2 3 6 1
1 2 5 6 1
1 4 3 5 1
1 4 3 6 1
1 4 5 6 1
1 2 3 4 1
1 2 3 6 1
1 2 4 6 1
1 5 3 4 1
1 5 3 6 1
1 5 4 6 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 7 3 4 1
1 7 3 5 1
1 7 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 9 3 4 1
1 9 3 5 1
1 9 4 5 1
1 2 3 4 1
1 2 3 5 1
1 2 4 5 1
1 10 3 4 1
1 10 3 5 1
1 ...

result:

ok n=100

Test #41:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

4
40 -37 6
-68 -33
100
43 28 9
-71 -98
97

output:

2
1 2 3 4 34
3 1 2 4 31

result:

ok n=4

Test #42:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

4
84 -41 68
30 -18
19
73 -64 21
77 5
30

output:

3
1 2 3 4 -17
2 1 3 4 18
3 1 2 4 12

result:

ok n=4

Test #43:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

4
27 -78 29
81 -14
-44
41 -62 33
77 -30
-58

output:

3
1 2 3 4 15
2 1 3 4 5
3 1 2 4 6

result:

ok n=4

Test #44:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

4
-82 85 8
1 -50
-10
-41 50 47
-38 -15
-51

output:

3
1 2 3 4 3
2 1 3 4 1
3 1 2 4 -37

result:

ok n=4

Test #45:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

4
-39 -81 59
-49 52
-66
-32 -74 24
-14 45
-73

output:

3
1 2 3 4 7
2 1 3 4 21
3 1 2 4 21

result:

ok n=4

Test #46:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

4
6 6 6
6 6
6
2 2 2
2 2
2

output:

-1

result:

ok n=4

Test #47:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

5
6 6 6 6
6 6 6
6 6
6
2 2 2 2
2 2 2
2 2
2

output:

-1

result:

ok n=5

Test #48:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

5
-21 -29 -2 -46
-55 78 43
87 -33
18
-55 55 -78 -8
-38 -25 60
50 16
63

output:

37
1 2 3 5 1
4 1 3 5 1
3 2 4 5 1
2 1 4 5 1
3 1 4 5 1
5 1 2 3 1
4 1 2 5 1
1 3 4 5 42
3 1 4 5 42
4 5 1 2 42
5 4 1 2 42
1 4 3 5 -38
4 1 3 5 -38
3 5 1 2 -38
5 3 1 2 -38
1 5 3 4 20
5 1 3 4 20
3 4 1 2 20
4 3 1 2 20
2 3 4 5 9
3 2 4 5 9
4 5 1 2 9
5 4 1 2 9
2 4 3 5 -52
4 2 3 5 -52
3 5 1 2 -52
5 3 1 2 -52
2 5...

result:

ok n=5

Test #49:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

5
95 -11 -61 61
85 -32 -14
-12 -75
-89
-42 -14 -23 40
-79 91 -90
19 -19
64

output:

76
4 1 2 5 1
1 2 3 4 1
4 2 3 5 1
1 2 4 5 1
2 1 3 5 1
5 2 3 4 1
1 3 4 5 1
4 1 2 5 1
2 3 4 5 1
4 1 2 5 1
4 1 3 5 1
4 1 2 5 1
2 1 3 5 1
5 1 2 3 1
4 1 2 3 1
1 2 3 5 1
1 2 4 5 1
4 1 2 3 1
2 1 4 5 1
5 1 2 4 1
1 2 3 4 1
2 3 4 5 1
1 2 4 5 1
1 2 3 4 1
3 2 4 5 1
3 1 4 5 1
2 1 4 5 1
4 1 2 3 1
4 2 3 5 1
3 1 4 5...

result:

ok n=5

Test #50:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

5
30 12 46 66
-22 -53 -8
63 -40
-84
36 38 36 55
-63 -22 2
28 -4
-96

output:

57
2 3 4 5 1
4 2 3 5 1
5 2 3 4 1
2 1 3 4 1
4 1 3 5 1
2 1 3 5 1
1 3 4 5 1
2 3 4 5 1
1 2 3 4 1
3 1 4 5 1
5 1 3 4 1
4 1 2 3 1
1 2 3 5 1
5 1 3 4 1
5 2 3 4 1
1 2 3 4 1
5 1 2 4 1
1 2 4 5 1
1 3 4 5 1
3 1 4 5 1
2 1 3 4 1
2 3 4 5 1
2 1 3 5 1
3 1 2 4 1
3 1 4 5 1
1 2 4 5 1
1 3 4 5 1
1 3 4 5 12
3 1 4 5 12
4 5 1...

result:

ok n=5

Test #51:

score: 0
Accepted
time: 0ms
memory: 3716kb

input:

5
-89 -74 46 -19
59 46 45
-15 -35
-12
-35 -87 -5 28
15 76 37
-22 -56
1

output:

51
4 1 2 5 1
4 1 3 5 1
5 1 2 3 1
1 3 4 5 1
4 1 3 5 1
2 3 4 5 1
1 2 3 5 1
5 2 3 4 1
4 1 2 3 1
2 1 3 4 1
3 1 4 5 1
4 2 3 5 1
5 1 3 4 1
2 1 4 5 1
2 1 3 4 1
3 2 4 5 1
1 2 4 5 1
1 2 4 5 1
3 1 2 5 1
1 2 3 5 1
3 1 2 4 1
1 3 4 5 -6
3 1 4 5 -6
4 5 1 2 -6
5 4 1 2 -6
1 4 3 5 -26
4 1 3 5 -26
3 5 1 2 -26
5 3 1 2...

result:

ok n=5

Test #52:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

5
-91 -64 -43 -21
-48 11 -46
-58 43
-43
-52 -87 -45 -79
-35 57 -58
-18 -5
-38

output:

55
1 3 4 5 1
4 1 3 5 1
3 1 4 5 1
4 1 3 5 1
4 2 3 5 1
3 1 2 5 1
5 2 3 4 1
3 1 2 5 1
4 1 2 3 1
2 1 3 4 1
3 1 2 4 1
4 1 2 3 1
3 1 2 5 1
2 1 4 5 1
3 2 4 5 1
4 2 3 5 1
4 1 2 5 1
1 2 3 4 1
4 2 3 5 1
3 2 4 5 1
2 1 3 4 1
5 1 2 3 1
5 2 3 4 1
1 2 4 5 1
4 1 2 5 1
5 1 3 4 1
5 1 2 4 1
1 3 4 5 -11
3 1 4 5 -11
4 5...

result:

ok n=5

Test #53:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

5
-18 70 -27 11
54 -19 36
-94 85
-52
9 41 -28 35
-3 -12 36
-39 75
-68

output:

117
5 1 3 4 1
5 1 2 4 1
2 1 3 5 1
4 1 2 5 1
5 1 3 4 1
2 1 3 4 1
1 2 3 4 1
1 2 3 5 1
3 1 4 5 1
4 1 2 5 1
3 2 4 5 1
1 3 4 5 1
5 1 3 4 1
5 1 2 4 1
4 1 2 5 1
1 3 4 5 1
2 1 3 4 1
1 2 3 4 1
1 3 4 5 1
4 1 2 3 1
4 1 2 5 1
3 1 4 5 1
3 1 2 4 1
4 1 2 3 1
3 1 2 4 1
2 1 4 5 1
5 1 2 3 1
2 3 4 5 1
3 2 4 5 1
2 1 3 ...

result:

ok n=5

Test #54:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

5
30 69 -94 16
75 32 49
59 31
26
71 26 -82 13
26 80 18
89 30
22

output:

55
4 1 2 3 1
2 1 3 4 1
3 1 2 4 1
1 2 3 4 1
5 2 3 4 1
4 1 2 3 1
1 2 3 5 1
1 2 3 4 1
5 1 3 4 1
2 1 3 4 1
5 1 3 4 1
1 3 4 5 1
3 1 2 4 1
1 2 3 5 1
2 1 3 4 1
4 1 2 3 1
1 2 3 5 1
1 2 3 5 1
3 1 2 4 1
2 3 4 5 1
3 1 4 5 1
5 1 2 4 1
4 1 2 3 1
1 2 3 5 1
1 2 4 5 1
1 3 4 5 -23
3 1 4 5 -23
4 5 1 2 -23
5 4 1 2 -23...

result:

ok n=5

Test #55:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

5
84 -23 38 82
-1 3 32
-72 -40
-95
98 -5 -13 87
34 -25 38
-60 -100
-46

output:

55
1 3 4 5 1
4 1 3 5 1
4 2 3 5 1
2 1 4 5 1
1 3 4 5 1
4 2 3 5 1
1 3 4 5 1
2 3 4 5 1
2 3 4 5 1
5 1 2 4 1
3 2 4 5 1
3 1 4 5 1
5 2 3 4 1
4 1 2 3 1
5 1 2 3 1
5 1 2 4 1
3 1 2 4 1
1 2 3 4 1
3 1 2 4 1
5 1 2 3 1
5 1 3 4 1
3 1 2 5 1
2 3 4 5 1
4 1 2 5 1
4 1 2 3 1
1 3 4 5 8
3 1 4 5 8
4 5 1 2 8
5 4 1 2 8
1 4 3 5...

result:

ok n=5

Test #56:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

5
-56 48 23 92
-37 53 -18
-30 -28
-34
-57 99 0 89
-68 64 19
-85 -19
-29

output:

59
3 1 2 5 1
4 1 2 5 1
4 2 3 5 1
5 1 3 4 1
4 1 2 5 1
4 1 3 5 1
5 1 2 4 1
4 1 2 5 1
5 1 2 3 1
5 1 2 3 1
2 3 4 5 1
4 1 2 5 1
3 1 4 5 1
4 1 2 5 1
5 1 2 3 1
1 2 3 4 1
3 1 2 4 1
2 1 4 5 1
2 1 3 5 1
3 1 4 5 1
4 1 3 5 1
1 2 3 5 1
2 1 4 5 1
5 1 2 4 1
1 2 3 4 1
2 1 4 5 1
1 2 3 5 1
5 1 2 4 1
4 2 3 5 1
1 3 4 5...

result:

ok n=5

Test #57:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

4
0 0 0
0 0
0
0 0 0
0 0
0

output:

0

result:

ok n=4