#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, x[N], y[N], a[N], ans[N], p[N], dp[N], d[N];
bool used[N];
vector<int> g[N];
int dsu_get(int v) { return p[v] == v ? v : p[v] = dsu_get(p[v]); }
inline bool dsu_unite(int x, int y) {
  x = dsu_get(x);
  y = dsu_get(y);
  if (x != y) {
    p[x] = y;
    return true;
  } else {
    return false;
  }
}
void dfs(int v, int pr = -1, int depth = 0) {
  dp[v] = a[v];
  d[v] = depth;
  for (int to : g[v]) {
    if (to != pr) {
      dfs(to, v, depth + 1);
      dp[v] += dp[to];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    p[i] = i;
  }
  if (sum != 0) {
    return cout << "Impossible", 0;
  }
  cout << "Possible\n";
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x[i] >> y[i];
    if (dsu_unite(x[i], y[i])) {
      g[x[i]].push_back(y[i]);
      g[y[i]].push_back(x[i]);
      used[i] = true;
    }
  }
  dfs(1);
  for (int i = 1; i <= m; i++) {
    if (used[i]) {
      if (d[x[i]] < d[y[i]]) {
        ans[i] = dp[y[i]];
      } else {
        ans[i] = -dp[x[i]];
      }
    }
    cout << ans[i] << "\n";
  }
}
