#include <bits/stdc++.h>
using namespace std;
using DO = double;
using LL = long long;
using VI = vector<int>;
const int N = 2e5 + 10;
int s[N], vst[N], ans[N], root[N], head[N], nxt[N << 1], to[N << 1], id[N << 1],
    E;
void add(int u, int v, int i) {
  nxt[E] = head[u];
  to[E] = v;
  id[E] = i, head[u] = E++;
  nxt[E] = head[v];
  to[E] = u;
  id[E] = -i, head[v] = E++;
}
int find(int u) { return u == root[u] ? u : root[u] = find(root[u]); }
int sgn(int u) { return u < 0 ? -1 : u > 0; }
void dfs(int u) {
  vst[u] = 1;
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    if (vst[v]) continue;
    dfs(v);
    ans[abs(id[e])] += sgn(id[e]) * s[v];
    s[u] += s[v];
  }
}
int main() {
  memset(head, -1, sizeof head);
  int n, m;
  cin >> n;
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", s + i), tot += s[i];
    root[i] = i;
  }
  if (tot) {
    puts("Impossible");
    return 0;
  }
  cin >> m;
  puts("Possible");
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    find(u);
    find(v);
    if (root[u] != root[v]) {
      root[root[u]] = root[v];
      add(u, v, i);
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vst[i]) dfs(i);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
