#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
struct edge {
  int to, next, val;
} e[maxn << 1];
int n, m, s[maxn], tot = 1, ssum;
int head[maxn], sum[maxn], dep[maxn], ans[maxn];
int p[maxn], g[maxn][3];
int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); }
bool merge(int x, int y) {
  x = find(x), y = find(y);
  if (x ^ y) p[x] = y;
  return x != y;
}
void dfs(int u, int p) {
  sum[u] = s[u];
  for (int t = head[u]; t; t = e[t].next) {
    int v = e[t].to;
    if (v == p) continue;
    dep[v] = dep[u] + 1;
    dfs(v, u);
    sum[u] += sum[v];
  }
}
void arc(int f, int t) {
  e[++tot] = (edge){t, head[f]};
  head[f] = tot;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", s + i), ssum += s[i], p[i] = i;
  if (ssum != 0) {
    puts("Impossible");
    return 0;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int &x = g[i][0], &y = g[i][1];
    scanf("%d%d", &x, &y);
    if (merge(x, y))
      arc(x, y), arc(y, x), g[i][2] = 1;
    else
      g[i][2] = 0;
  }
  dfs(1, 0);
  puts("Possible");
  for (int i = 1; i <= m; ++i) {
    int u = g[i][0], v = g[i][1];
    if (!g[i][2])
      puts("0");
    else {
      if (dep[u] < dep[v])
        printf("%d\n", sum[v]);
      else
        printf("%d\n", -sum[u]);
    }
  }
  return 0;
}
