#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
const int INF = (ll)1e9 + 7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template <class t>
using vvector = vector<vector<t>>;
template <class t>
using vvvector = vector<vector<vector<t>>>;
template <class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template <class t, class u>
bool chmax(t &a, u b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class t, class u>
bool chmin(t &a, u b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll modpow(ll x, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = res * x % MOD;
    x = x * x % MOD;
    b >>= 1;
  }
  return res;
}
ll modinv(ll x) { return modpow(x, MOD - 2); }
bool was_output = false;
template <class t>
void output(t a) {
  if (was_output) cout << " ";
  cout << a;
  was_output = true;
}
void outendl() {
  was_output = false;
  cout << endl;
}
int n, m;
vector<ll> d;
vvector<int> edges;
vector<int> color;
void draw_color(int place) {
  if (color[place] == -1) {
    color[place] = 0;
  }
  for (auto &i : (edges[place])) {
    if (color[i] >= 0) continue;
    color[i] = !color[place];
    draw_color(i);
  }
}
int main() {
  cout << -1 << endl;
  return 0;
  cin >> n >> m;
  d.resize(n);
  color.resize(n, -1);
  edges.resize(n);
  for (auto &i : (d)) cin >> i;
  vector<pair<int, int>> memo;
  for (int i = 0; i < (m); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    edges[a].push_back(b);
    edges[b].push_back(a);
    if (a > b) swap(a, b);
    memo.emplace_back(a, b);
  }
  for (int i = 0; i < (n); ++i) {
    for (auto &j : (edges[i])) {
      if (d[i] == d[j]) {
        draw_color(i);
      }
    }
  }
  vector<pair<int, int>> order;
  for (int i = 0; i < (n); ++i) {
    order.emplace_back(d[i], i);
  }
  map<pair<int, int>, ll> ans;
  sort((order).begin(), (order).end());
  for (auto &now : (order)) {
    int place = now.second;
    int dis = now.first;
    for (auto &edge : (edges[place])) {
      if (d[edge] > dis) continue;
      if (d[edge] == dis) {
        int a = place;
        int b = edge;
        if (a > b) swap(a, b);
        ans[pair<int, int>(a, b)] = dis;
        continue;
      }
      if (color[place] == -1) {
        color[place] = color[edge];
      }
      {
        int a = place;
        int b = edge;
        if (a > b) swap(a, b);
        if (color[place] == color[edge]) {
          ans[pair<int, int>(a, b)] = dis - d[edge];
        } else {
          ans[pair<int, int>(a, b)] = dis;
        }
      }
    }
    if (color[place] == -1) {
      cout << -1 << endl;
      return 0;
    }
  }
  bool flag = false;
  for (auto &i : (color)) {
    if (i) {
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << -1 << endl;
    return 0;
  }
  for (auto &i : (color)) {
    if (i) {
      cout << "W";
    } else {
      cout << "B";
    }
  }
  cout << endl;
  for (auto &i : (memo)) {
    cout << ans[i] << endl;
  }
  return 0;
}
