Little Artem is a very smart programmer. He knows many different difficult algorithms. Recently he has mastered in 2-SAT one.

In computer science, 2-satisfiability (abbreviated as 2-SAT) is the special case of the problem of determining whether a conjunction (logical AND) of disjunctions (logical OR) have a solution, in which all disjunctions consist of no more than two arguments (variables). For the purpose of this problem we consider only 2-SAT formulas where each disjunction consists of exactly two arguments.

Consider the following 2-SAT problem as an example: <image>. Note that there might be negations in 2-SAT formula (like for x1 and for x4).

Artem now tries to solve as many problems with 2-SAT as possible. He found a very interesting one, which he can not solve yet. Of course, he asks you to help him. 

The problem is: given two 2-SAT formulas f and g, determine whether their sets of possible solutions are the same. Otherwise, find any variables assignment x such that f(x) ≠ g(x). 

Input

The first line of the input contains three integers n, m1 and m2 (1 ≤ n ≤ 1000, 1 ≤ m1, m2 ≤ n2) — the number of variables, the number of disjunctions in the first formula and the number of disjunctions in the second formula, respectively.

Next m1 lines contains the description of 2-SAT formula f. The description consists of exactly m1 pairs of integers xi ( - n ≤ xi ≤ n, xi ≠ 0) each on separate line, where xi > 0 corresponds to the variable without negation, while xi < 0 corresponds to the variable with negation. Each pair gives a single disjunction. Next m2 lines contains formula g in the similar format.

Output

If both formulas share the same set of solutions, output a single word "SIMILAR" (without quotes). Otherwise output exactly n integers xi (<image>) — any set of values x such that f(x) ≠ g(x).

Examples

Input

2 1 1
1 2
1 2


Output

SIMILAR


Input

2 1 1
1 2
1 -2


Output

0 0 

Note

First sample has two equal formulas, so they are similar by definition.

In second sample if we compute first function with x1 = 0 and x2 = 0 we get the result 0, because <image>. But the second formula is 1, because <image>.
#include <bits/stdc++.h>
using namespace std;
template <class T>
T inline sqr(T x) {
  return x * x;
}
const long double pi = 3.1415926535897932384626433832795;
const long double eps = 1e-8;
int nxt() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1002;
typedef bitset<N * 2> T;
vector<vector<int> > g, gt;
vector<bool> used;
vector<int> order, comp;
void dfs1(int v) {
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (!used[to]) dfs1(to);
  }
  order.push_back(v);
}
void dfs2(int v, int cl) {
  comp[v] = cl;
  for (size_t i = 0; i < gt[v].size(); ++i) {
    int to = gt[v][i];
    if (comp[to] == -1) dfs2(to, cl);
  }
}
vector<int> sol(int n, const vector<T>& a) {
  n *= 2;
  g.assign(n, vector<int>());
  gt.assign(n, vector<int>());
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j)
      if (a[i][j]) g[i].push_back(j), gt[j].push_back(i);
  order.clear();
  used.assign(n, false);
  for (int i = 0; i < n; ++i)
    if (!used[i]) dfs1(i);
  comp.assign(n, -1);
  for (int i = 0, j = 0; i < n; ++i) {
    int v = order[n - i - 1];
    if (comp[v] == -1) dfs2(v, j++);
  }
  for (int i = 0; i < n; ++i)
    if (comp[i] == comp[i ^ 1]) {
      return vector<int>();
    }
  vector<int> ans(n / 2);
  for (int i = 0; i < n / 2; i++) {
    ans[i] = comp[i * 2] > comp[i * 2 + 1] ? 1 : 0;
  }
  return ans;
}
vector<T> f(int n, int m) {
  vector<T> a(n * 2);
  for (int i = 0; i < (int)(m); ++i) {
    int u = nxt(), v = nxt();
    int x = (abs(u) - 1) * 2 + (u < 0);
    int y = (abs(v) - 1) * 2 + (v < 0);
    a[x ^ 1][y] = 1;
    a[y ^ 1][x] = 1;
  }
  for (int k = 0; k < (int)(2 * n); ++k)
    for (int i = 0; i < (int)(2 * n); ++i)
      if (a[i][k]) a[i] |= a[k];
  return a;
}
bool check(const vector<int>& a, const vector<T>& b) {
  for (int i = 0; i < (int)(2 * a.size()); ++i)
    for (int j = 0; j < (int)(2 * a.size()); ++j)
      if (a[i / 2] != i % 2 && a[j / 2] == j % 2 && b[i][j]) return false;
  return true;
}
vector<int> broad(const vector<T>& a, const vector<int>& vals) {
  vector<int> res = vals;
  queue<int> q;
  int n = vals.size();
  for (int i = 0; i < (int)(n); ++i)
    if (vals[i] != -1) q.push(i);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < (int)(n * 2); ++i) {
      if (a[v * 2 + (res[v] ^ 1)][i] && res[i / 2] == -1) {
        res[i / 2] = (i % 2) ^ 1;
        q.push(i / 2);
      }
    }
  }
  return res;
}
vector<int> extend(const vector<int>& to_extend, const vector<int>& sol) {
  vector<int> res = to_extend;
  for (int i = 0; i < (int)(sol.size()); ++i)
    if (res[i] == -1) res[i] = sol[i];
  return res;
}
void print(const vector<int>& sol) {
  for (int x : sol) cout << x << " ";
  cout << "\n";
  exit(0);
}
int main() {
  int n = nxt(), m1 = nxt(), m2 = nxt();
  vector<T> a = f(n, m1);
  vector<T> b = f(n, m2);
  if (a == b) {
    puts("SIMILAR");
    return 0;
  }
  vector<int> sa = sol(n, a);
  if (!sa.empty()) assert(check(sa, a));
  vector<int> sb = sol(n, b);
  if (!sb.empty()) assert(check(sb, b));
  if (sa.empty() != sb.empty()) {
    vector<int> x = sa;
    if (x.empty()) x = sb;
    for (int i = 0; i < (int)(n); ++i) cout << x[i] << " ";
    return 0;
  }
  if (sa.empty()) {
    puts("SIMILAR");
    return 0;
  }
  vector<int> dta(n, -1);
  for (int i = 0; i < (int)(n); ++i) {
    if (a[i * 2][i * 2 + 1]) dta[i] = 0;
    if (a[i * 2 + 1][i * 2]) dta[i] = 1;
  }
  dta = broad(a, dta);
  vector<int> dtb(n, -1);
  for (int i = 0; i < (int)(n); ++i) {
    if (b[i * 2][i * 2 + 1]) dtb[i] = 0;
    if (b[i * 2 + 1][i * 2]) dtb[i] = 1;
  }
  dtb = broad(b, dtb);
  for (int i = 0; i < (int)(n * 2); ++i)
    for (int j = 0; j < (int)(n * 2); ++j)
      if (a[i][j] != b[i][j]) {
        for (int di = 0; di < (int)(2); ++di)
          for (int dj = 0; dj < (int)(2); ++dj) {
            vector<int> vals = dta;
            vals[i / 2] = di;
            vals[j / 2] = dj;
            vector<int> w = broad(a, vals);
            for (int i = 0; i < (int)(n); ++i)
              if (w[i] == -1) w[i] = sa[i];
            if (check(w, a) != check(w, b)) {
              for (int i = 0; i < (int)(n); ++i) cout << w[i] << " ";
              return 0;
            }
            vals = dtb;
            vals[i / 2] = di;
            vals[j / 2] = dj;
            w = broad(b, vals);
            for (int i = 0; i < (int)(n); ++i)
              if (w[i] == -1) w[i] = sb[i];
            if (check(w, a) != check(w, b)) {
              for (int i = 0; i < (int)(n); ++i) cout << w[i] << " ";
              return 0;
            }
          }
        if (clock() > CLOCKS_PER_SEC * 2.8) {
          puts("SIMILAR");
          return 0;
        }
      }
  puts("SIMILAR");
  return 0;
}
