#include <bits/stdc++.h>
using namespace std;
void preproc() {}
void reset() {}
void solve() {
  int n;
  cin >> n;
  vector<long long> s(n);
  for (long long &x : s) cin >> x;
  if (accumulate(s.begin(), s.end(), 0) != 0) {
    cout << "Impossible\n";
    return;
  }
  int m;
  cin >> m;
  vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>());
  vector<long long> f(m);
  for (int e = 0; e < m; ++e) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back({v, 2 * e});
    g[v].push_back({u, 2 * e + 1});
  }
  vector<bool> vis(n);
  function<long long(int)> dfsTree = [&](int u) -> long long {
    vis[u] = true;
    long long fo = 0;
    for (auto [v, e] : g[u])
      if (!vis[v]) {
        f[e / 2] = dfsTree(v);
        fo += f[e / 2];
        if (e % 2 == 0) f[e / 2] *= -1;
      }
    fo += -s[u];
    return fo;
  };
  dfsTree(0);
  cout << "Possible\n";
  for (long long x : f) cout << x << '\n';
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  preproc();
  int tc = 1;
  for (int Tt = 1; Tt <= tc; ++Tt) {
    ;
    reset();
    solve();
  }
  return EXIT_SUCCESS;
}
