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;
const int N = 2222;
const long long INF = 1e9 + 19;
struct Var {
  int id;
  bool flag;
  Var(int x) {
    flag = x > 0;
    id = abs(x) - 1;
  }
};
struct Graph {
  vector<vector<int> > e;
  vector<vector<int> > er;
  vector<vector<int> > g;
  vector<char> use;
  vector<int> st;
  vector<int> color;
  vector<bitset<N> > bb;
  vector<bitset<N> > realbb;
  vector<bitset<N> > invbb;
  vector<vector<int> > who;
  vector<int> bad;
  vector<int> answer;
  int n;
  Graph(vector<pair<Var, Var> > eq, int n) : n(n) {
    e.resize(n * 2);
    er.resize(n * 2);
    for (auto x : eq) {
      Var v = x.first;
      Var u = x.second;
      v.flag ^= 1;
      e[getId(v)].push_back(getId(u));
      er[getId(u)].push_back(getId(v));
      v.flag ^= 1;
      u.flag ^= 1;
      e[getId(u)].push_back(getId(v));
      er[getId(v)].push_back(getId(u));
    }
    use.resize(n * 2);
    for (int i = 0; i < n * 2; i++)
      if (!use[i]) dfs1(i);
    reverse(st.begin(), st.end());
    color.resize(n * 2, -1);
    int cc = 0;
    for (int i = 0; i < n * 2; i++) {
      int v = st[i];
      if (color[v] == -1) {
        who.push_back(vector<int>());
        dfs2(v, cc);
        cc++;
      }
    }
    g.resize(cc);
    for (int i = 0; i < n * 2; i++)
      for (auto u : e[i]) {
        if (color[i] != color[u]) g[color[i]].push_back(color[u]);
      }
    bb.resize(cc);
    use.assign(n * 2, 0);
    for (int i = 0; i < cc; i++)
      if (!use[i]) dfs3(i);
    realbb.resize(n * 2);
    invbb.resize(n * 2);
    for (int i = 0; i < cc; i++) {
      for (auto v : who[i])
        for (int j = 0; j < cc; j++)
          if (bb[i][j])
            for (auto u : who[j]) {
              realbb[v][u] = 1;
              int id = (u + n) % (2 * n);
              invbb[v][id] = 1;
            }
    }
    bad.resize(n * 2);
    for (int i = 0; i < n * 2; i++)
      for (int j = 0; j < n; j++) {
        if (realbb[i][j] && realbb[i][j + n]) {
          bad[i] = 1;
          break;
        }
      }
    for (int i = 0; i < n; i++) {
      if (color[i] == color[i + n]) {
        answer.clear();
        break;
      }
      if (color[i] < color[i + n])
        answer.push_back(1);
      else
        answer.push_back(0);
    }
  }
  void dfs3(int v) {
    use[v] = 1;
    bb[v][v] = 1;
    for (auto u : g[v]) {
      if (!use[u]) dfs3(u);
      bb[v] |= bb[u];
    }
  }
  void dfs2(int v, int cc) {
    color[v] = cc;
    who.back().push_back(v);
    for (auto u : er[v])
      if (color[u] == -1) dfs2(u, cc);
  }
  void dfs1(int v) {
    use[v] = 1;
    for (auto u : e[v])
      if (!use[u]) dfs1(u);
    st.push_back(v);
  }
  int getId(Var v) { return v.id + v.flag * n; }
};
int n, m1, m2;
vector<pair<Var, Var> > e1;
vector<pair<Var, Var> > e2;
int getId(Var v) { return v.id + v.flag * n; }
void read() {
  scanf("%d%d%d", &n, &m1, &m2);
  for (int i = 0; i < m1; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    e1.push_back(make_pair(Var(v), Var(u)));
  }
  for (int i = 0; i < m2; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    e2.push_back(make_pair(Var(v), Var(u)));
  }
}
void solve() {
  for (int tt = 0; tt < 2; tt++) {
    Graph g2(e2, n);
    if (g2.answer.empty()) {
      swap(e1, e2);
      continue;
    }
    for (int i = 0; i < (int)e1.size(); i++) {
      int A = (getId(e1[i].first) + n) % (2 * n);
      int B = (getId(e1[i].second) + n) % (2 * n);
      if (g2.bad[A] || g2.bad[B]) {
        continue;
      }
      if ((g2.invbb[A] & g2.realbb[B]).any()) continue;
      if ((g2.invbb[B] & g2.realbb[A]).any()) continue;
      vector<int> answer = g2.answer;
      for (int i = 0; i < n * 2; i++) {
        if (g2.realbb[A][i]) {
          int id = i % n;
          int val = i / n;
          answer[id] = val;
        }
      }
      for (int i = 0; i < n * 2; i++) {
        if (g2.realbb[B][i]) {
          int id = i % n;
          int val = i / n;
          answer[id] = val;
        }
      }
      for (int i = 0; i < n; i++) printf("%d ", answer[i]);
      puts("");
      exit(0);
    }
    swap(e1, e2);
  }
  puts("SIMILAR");
}
void stress() {}
int main() {
  if (1) {
    int k = 1;
    for (int tt = 0; tt < k; tt++) {
      read();
      solve();
    }
  } else {
    stress();
  }
  return 0;
}
