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>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
void solve();
void precalc();
clock_t start;
int testNumber = 1;
bool todo = true;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  int testNum = 1;
  while (t--) {
    solve();
    ++testNumber;
  }
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
void precalc() {}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
int get_var() {
  int cur;
  cin >> cur;
  int dom = 0;
  if (cur < 0) {
    dom = 1;
    cur = -cur;
  }
  --cur;
  return 2 * cur + dom;
}
int n;
vector<vector<int>> g, gr;
vector<char> used;
vector<int> order;
vector<vector<int>> components;
vector<int> num_comp;
void dfs1(int v) {
  used[v] = true;
  for (size_t i = 0; i < g[v].size(); ++i)
    if (!used[g[v][i]]) dfs1(g[v][i]);
  order.push_back(v);
}
void dfs2(int v, int col) {
  used[v] = true;
  components[col].push_back(v);
  num_comp[v] = col;
  for (size_t i = 0; i < gr[v].size(); ++i)
    if (!used[gr[v][i]]) dfs2(gr[v][i], col);
}
void solve_2sat() {
  used.assign(n * 2, false);
  for (int i = 0; i < g.size(); ++i) {
    if (!used[i]) {
      dfs1(i);
    }
  }
  used.assign(n * 2, false);
  int comps = 0;
  components.clear();
  num_comp.clear();
  num_comp.resize(2 * n);
  for (int i = 0; i < order.size(); ++i) {
    int v = order[order.size() - 1 - i];
    if (!used[v]) {
      components.push_back(vector<int>());
      dfs2(v, comps++);
    }
  }
}
void solve() {
  cin >> n;
  vector<int> m(2);
  cin >> m[0] >> m[1];
  vector<vector<pair<int, int>>> dis(2);
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < m[i]; ++j) {
      int cur1 = get_var(), cur2 = get_var();
      dis[i].push_back(make_pair(cur1, cur2));
    }
  }
  for (int bui = 0; bui < 2; ++bui) {
    g.clear();
    gr.clear();
    g.resize(2 * n);
    gr.resize(2 * n);
    for (auto& e : dis[bui]) {
      g[e.first ^ 1].push_back(e.second);
      g[e.second ^ 1].push_back(e.first);
      gr[e.second].push_back(e.first ^ 1);
      gr[e.first].push_back(e.second ^ 1);
    }
    solve_2sat();
    int comps = components.size();
    vector<vector<int>> new_g(comps);
    for (int i = 0; i < 2 * n; ++i) {
      for (int to : g[i]) {
        new_g[num_comp[i]].push_back(num_comp[to]);
      }
    }
    for (int i = 0; i < comps; ++i) {
      sort(new_g[i].begin(), new_g[i].end());
      new_g[i].erase(unique(new_g[i].begin(), new_g[i].end()), new_g[i].end());
    }
    vector<bitset<2001>> reachable(comps);
    for (int i = comps - 1; i >= 0; --i) {
      reachable[i][i] = 1;
      for (int to : new_g[i]) {
        reachable[i] |= reachable[to];
      }
    }
    bool f = true;
    for (int i = 0; i < n; ++i) {
      if (num_comp[2 * i] == num_comp[2 * i + 1]) {
        f = false;
        break;
      }
    }
    if (!f) {
      continue;
    }
    for (auto& e : dis[bui ^ 1]) {
      int a = e.first, ne_a = e.first ^ 1;
      int b = e.second, ne_b = e.second ^ 1;
      if (reachable[num_comp[ne_a]][num_comp[a]] ||
          reachable[num_comp[ne_b]][num_comp[b]] ||
          (reachable[num_comp[ne_b]][num_comp[a]] &&
           reachable[num_comp[ne_a]][num_comp[b]])) {
      } else {
        g[a].push_back(ne_a);
        g[b].push_back(ne_b);
        gr[ne_a].push_back(a);
        gr[ne_b].push_back(b);
        solve_2sat();
        int comps = components.size();
        vector<int> assigned(comps, -1);
        for (int i = comps - 1; i >= 0; --i) {
          if (assigned[i] != -1) {
            continue;
          }
          assigned[i] = 1;
          for (int to : components[i]) {
            assigned[num_comp[to ^ 1]] = 0;
          }
        }
        vector<int> res(2 * n);
        for (int i = 0; i < comps; ++i) {
          for (int v : components[i]) {
            res[v] = assigned[i];
          }
        }
        for (int i = 0; i < n; ++i) {
          cout << res[2 * i] << ' ';
        }
        return;
      }
    }
  }
  cout << "SIMILAR\n";
}
