#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, m, sum, s[maxn], fa[maxn], u[maxn], v[maxn], d[maxn];
bool used[maxn];
vector<int> G[maxn];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void dfs(int v, int f) {
  for (int u : G[v])
    if (u ^ f) {
      d[u] = d[v] + 1, dfs(u, v), s[v] += s[u];
    }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]), sum += s[fa[i] = i];
  }
  if (sum) printf("Impossible\n"), exit(0);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u[i], &v[i]);
    if (find(u[i]) ^ find(v[i])) {
      used[i] = 1, fa[find(u[i])] = find(v[i]);
      G[u[i]].push_back(v[i]), G[v[i]].push_back(u[i]);
    }
  }
  dfs(1, 0), printf("Possible\n");
  for (int i = 1; i <= m; i++) {
    if (!used[i])
      printf("0\n");
    else
      printf("%d\n", d[u[i]] < d[v[i]] ? s[v[i]] : -s[u[i]]);
  }
  return 0;
}
