#include <bits/stdc++.h>
using namespace std;
long long int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans % md;
}
const long long int MAXN = 1e6 + 10;
const long long int INF = 8e18;
const long long int MOD = 1e9 + 7;
long long int U[MAXN], V[MAXN], par[MAXN], mark[MAXN], ans[MAXN], deg[MAXN],
    A[MAXN], d[MAXN], n, m, sum = 0;
vector<long long int> adj[2][MAXN];
map<pair<long long int, long long int>, long long int> ind;
void DFS(long long int v) {
  mark[v] = 1;
  for (long long int u : adj[0][v]) {
    if (mark[u] == 1) continue;
    d[u]++, d[v]++;
    adj[1][u].push_back(v);
    adj[1][v].push_back(u);
    par[u] = v;
    DFS(u);
  }
}
void BFS() {
  queue<long long int> Q;
  for (long long int i = 2; i <= n; i++) {
    if ((long long int)adj[1][i].size() == 1) Q.push(i);
  }
  while ((long long int)Q.size()) {
    long long int x, v = Q.front();
    Q.pop();
    x = A[v] - deg[v];
    deg[par[v]] -= x;
    ans[ind[{v, par[v]}]] = ans[ind[{par[v], v}]] = x;
    d[par[v]]--;
    if (d[par[v]] == 1) Q.push(par[v]);
  }
}
int main() {
  scanf("%lld", &n);
  for (long long int i = 1; i <= n; i++) scanf("%lld", &A[i]), sum += A[i];
  scanf("%lld", &m);
  for (long long int i = 1; i <= m; i++) {
    long long int u, v;
    scanf("%lld%lld", &u, &v);
    adj[0][v].push_back(u);
    adj[0][u].push_back(v);
    ind[{u, v}] = ind[{v, u}] = i, U[i] = u, V[i] = v;
  }
  if (sum != 0) return !printf("Impossible\n");
  DFS(1);
  BFS();
  printf("Possible\n");
  for (long long int i = 1; i <= m; i++) {
    long long int u = U[i], v = V[i];
    if (par[u] == v)
      printf("%lld\n", -ans[i]);
    else
      printf("%lld\n", ans[i]);
  }
  return 0;
}
