#include <bits/stdc++.h>
using namespace std;
FILE *in, *out;
int N, M, K;
int ar[200100];
vector<vector<pair<int, int> > > edges(200100);
int used[200100];
int SUM;
int ANS[200100];
int dfs(int root) {
  int i, j, k;
  used[root] = 1;
  j = ar[root];
  for (i = 0; i < (int)(edges[root].size()); i++) {
    if (used[edges[root][i].first]) continue;
    k = dfs(edges[root][i].first);
    if (edges[root][i].second > 0)
      ANS[edges[root][i].second] = (SUM - k);
    else
      ANS[-edges[root][i].second] = k;
    j += k;
  }
  return j;
}
int read() {
  int i, j, k;
  int x, y;
  cin >> N;
  for (i = 1; i <= N; i++) {
    cin >> ar[i];
    SUM += ar[i];
  }
  cin >> M;
  for (i = 0; i < M; i++) {
    cin >> x >> y;
    edges[x].push_back(make_pair(y, i + 1));
    edges[y].push_back(make_pair(x, -i - 1));
  }
  if (SUM != 0) {
    cout << "Impossible\n";
    return 0;
  }
  dfs(1);
  cout << "Possible\n";
  for (i = 1; i <= M; i++) {
    cout << -ANS[i] << "\n";
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  in = stdin;
  out = stdout;
  read();
  return 0;
}
