#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m;
int u, v, tot;
int head[N], to[N << 1], nxt[N << 1];
int ans[N], vis[N];
long long sum;
long long w[N];
void dfs(int u) {
  vis[u] = 1;
  for (int i = head[u]; ~i; i = nxt[i]) {
    if (vis[to[i]]) continue;
    dfs(to[i]);
    w[u] += w[to[i]];
  }
}
void solve(int u) {
  vis[u] = 1;
  for (int i = head[u]; ~i; i = nxt[i]) {
    if (vis[to[i]]) continue;
    if (i & 1)
      ans[i + 1 >> 1] = w[to[i]];
    else
      ans[i + 1 >> 1] = -w[to[i]];
    solve(to[i]);
  }
}
int main() {
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &w[i]);
    sum += w[i];
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    to[++tot] = v;
    nxt[tot] = head[u];
    head[u] = tot;
    to[++tot] = u;
    nxt[tot] = head[v];
    head[v] = tot;
  }
  if (sum) {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  dfs(1);
  memset(vis, 0, sizeof(vis));
  solve(1);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
}
