#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, mod = 1e9 + 7;
const long long inf = 1e18;
int a[maxn], A[maxn], B[maxn], vl[maxn], ans[maxn];
vector<pair<int, int> > pos, neg, v[maxn];
int mark[maxn];
void dfs(int u) {
  mark[u] = 1;
  if (a[u] < 0) neg.push_back({-a[u], u});
  if (a[u] > 0) pos.push_back({a[u], u});
  for (pair<int, int> p : v[u]) {
    if (!mark[p.first]) dfs(p.first);
  }
}
int dfs2(int u) {
  mark[u] = 2;
  int num = vl[u];
  for (pair<int, int> p : v[u]) {
    if (mark[p.first] != 2) {
      int num2 = dfs2(p.first);
      if (A[p.second] == u)
        ans[p.second] = num2;
      else
        ans[p.second] = -num2;
      num += num2;
    }
  }
  return num;
}
void solve(int u) {
  pos.clear(), neg.clear();
  dfs(u);
  int sm = 0;
  for (pair<int, int> p : pos) sm += p.first;
  for (pair<int, int> p : neg) sm -= p.first;
  if (sm != 0) cout << "Impossible\n", exit(0);
  while (int((pos).size()) || int((neg).size())) {
    int mn = min(neg.back().first, pos.back().first);
    vl[neg.back().second] -= mn, vl[pos.back().second] += mn;
    neg[int((neg).size()) - 1].first -= mn,
        pos[int((pos).size()) - 1].first -= mn;
    while (neg.back().first == 0) neg.pop_back();
    while (pos.back().first == 0) pos.pop_back();
  }
  dfs2(u);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> A[i] >> B[i];
    v[A[i]].push_back({B[i], i});
    v[B[i]].push_back({A[i], i});
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) solve(i);
  }
  cout << "Possible\n";
  for (int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
