#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > a[200018];
int n, val[200018], ans[200018], m, u, v;
bool vis[200018];
inline int read() {
  int X = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    X = (X << 3) + (X << 1) + ch - '0', ch = getchar();
  return X * w;
}
void dfs(int x, int fa, int id) {
  vis[x] = 1;
  for (int i = 0; i < (int)a[x].size(); i++) {
    if (vis[a[x][i].first] == 0) {
      dfs(a[x][i].first, x, a[x][i].second);
    }
  }
  if (val[x] != 0) {
    if (id < 0) {
      ans[-id] -= val[x];
    } else {
      ans[id] += val[x];
    }
    val[fa] += val[x];
    val[x] = 0;
  }
}
int main() {
  int sum = 0;
  n = read();
  for (int i = 1; i <= n; i++) {
    val[i] = read();
    sum += val[i];
  }
  if (sum != 0) {
    puts("Impossible");
    return 0;
  }
  puts("Possible");
  m = read();
  for (int i = 1; i <= m; i++) {
    u = read(), v = read();
    a[u].push_back(make_pair(v, i));
    a[v].push_back(make_pair(u, -i));
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= m; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
