#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[200009];
long long cst[200009], par[200009], sub[200009], pani[200009], tme[200009],
    TM = 1;
bool is[200009];
struct node {
  long long u;
  long long v;
} edge[200009];
long long findpar(long long u) {
  if (par[u] == u) return u;
  return par[u] = findpar(par[u]);
}
long long dfs(long long u, long long p) {
  tme[u] = TM++;
  long long ret = 0;
  for (long long i = 0; i < graph[u].size(); i++) {
    long long nd = graph[u][i];
    if (nd == p) continue;
    ret += dfs(nd, u);
  }
  return pani[u] = ret + cst[u];
}
int main() {
  long long n;
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &cst[i]);
    par[i] = i;
    sub[i] = 1;
    sum += cst[i];
  }
  long long m;
  cin >> m;
  for (long long i = 1; i <= m; i++) {
    is[i] = 0;
    long long u, v;
    scanf("%lld %lld", &u, &v);
    edge[i].u = u;
    edge[i].v = v;
    long long pu = findpar(u);
    long long pv = findpar(v);
    if (pu == pv) continue;
    if (sub[pu] < sub[pv]) swap(pu, pv);
    sub[pu] += sub[pv];
    par[pv] = pu;
    is[i] = 1;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  if (sum != 0) {
    printf("Impossible\n");
    return 0;
  }
  printf("Possible\n");
  dfs(1, -1);
  for (long long i = 1; i <= m; i++) {
    if (!is[i]) {
      printf("0\n");
      continue;
    }
    long long u = edge[i].u;
    long long v = edge[i].v;
    if (tme[u] < tme[v])
      printf("%lld\n", pani[v]);
    else
      printf("%lld\n", -pani[u]);
  }
  return 0;
}
