#include <bits/stdc++.h>
int N, M, a[200001], head[200001], next[400001], to[400001], E, O[200001],
    vi[200001];
void DFS(int p) {
  static int q[200001], fe[200001], fa[200001];
  int H = 0, T = 1, u;
  q[1] = p;
  vi[p] = 1;
  while (H < T)
    for (int e = head[u = q[++H]]; e; e = next[e])
      if (!vi[to[e]]) {
        q[++T] = to[e];
        fe[to[e]] = e;
        fa[to[e]] = u;
        vi[to[e]] = 1;
      }
  for (int i = T; i > 1; i--) {
    int u = q[i];
    O[fe[u] + 1 >> 1] = fe[u] & 1 ? a[u] : -a[u];
    a[fa[u]] += a[u];
  }
  if (a[q[1]]) {
    puts("Impossible");
    exit(0);
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", a + i);
  scanf("%d", &M);
  for (int i = 1, u, v; i <= M; i++) {
    scanf("%d%d", &u, &v);
    next[++E] = head[u], to[E] = v, head[u] = E;
    next[++E] = head[v], to[E] = u, head[v] = E;
  }
  for (int i = 1; i <= N; i++)
    if (!vi[i]) DFS(i);
  puts("Possible");
  for (int i = 1; i <= M; i++) printf("%d\n", O[i]);
  return 0;
}
