#include <bits/stdc++.h>
using namespace std;
int n, m;
int q[200005];
int vis[200005];
int sum[200005];
int ans[200005];
int head[200005];
struct node {
  int to, nex;
} E[400005];
void dfs(int x, int fa) {
  vis[x] = 1;
  int c = head[x];
  for (int i = c; i; i = E[i].nex) {
    int v = E[i].to;
    if (v == fa) continue;
    if (vis[v]) continue;
    dfs(v, x);
    sum[x] += sum[v];
  }
}
void dfs2(int x, int fa) {
  vis[x] = 1;
  int c = head[x];
  for (int i = c; i; i = E[i].nex) {
    int v = E[i].to;
    if (v == fa) continue;
    if (vis[v]) {
      ans[(i + 1) / 2] = 0;
      continue;
    }
    if (i & 1)
      ans[(i + 1) / 2] = sum[v];
    else
      ans[(i + 1) / 2] = -sum[v];
    dfs2(v, x);
  }
}
int main() {
  int ssum = 0;
  int cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &q[i]), ssum += q[i], sum[i] = q[i];
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    E[++cnt].to = v;
    E[cnt].nex = head[u];
    head[u] = cnt;
    E[++cnt].to = u;
    E[cnt].nex = head[v];
    head[v] = cnt;
  }
  if (ssum != 0) {
    puts("Impossible");
    return 0;
  } else
    puts("Possible");
  dfs(1, -1);
  memset(vis, 0, sizeof(vis));
  dfs2(1, -1);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
