#include <bits/stdc++.h>
using namespace std;
const int MX = 2e5 + 5;
int d[MX];
pair<int, int> e[MX];
char c[MX];
const int INF = 1e9;
int b[MX];
int n, m;
vector<pair<int, int>> a[MX];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  int i;
  for (i = 1; i <= m; i++) b[i] = INF;
  for (i = 1; i <= n; i++) cin >> d[i], e[i] = {d[i], i};
  for (i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back({v, i});
    a[v].push_back({u, i});
  }
  sort(e + 1, e + n + 1);
  for (i = 1; i <= n; i++) {
    int v = e[i].second;
    if (c[v]) continue;
    for (auto j : a[v]) {
      int u = j.first;
      if (d[u] < d[v]) {
        if (c[u] == 'b')
          c[v] = 'w';
        else
          c[v] = 'b';
        b[j.second] = d[v];
        break;
      }
      if (d[u] == d[v]) {
        if (c[u] == 'b')
          c[v] = 'w';
        else {
          c[v] = 'b';
          c[u] = 'w';
        }
        b[j.second] = d[v];
        break;
      }
    }
  }
  int isok = 1;
  for (i = 1; i <= n; i++) {
    if (c[i] == 0) isok = 0;
  }
  if (isok == 0) {
    cout << -1;
    return 0;
  }
  cout << c + 1 << endl;
  for (i = 1; i <= m; i++) {
    cout << b[i] << "\n";
  }
  return 0;
}
