#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, N = 2e5 + 7;
int s[N], f[N], vis[N];
vector<pair<int, int> > G[N];
vector<int> tt;
void dfs(int u) {
  vis[u] = 1;
  for (pair<int, int> e : G[u])
    if (!vis[e.first]) dfs(e.first);
  tt.push_back(u);
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 1; i <= n; i++) cin >> s[i], sum += s[i];
  if (sum != 0) return cout << "Impossible" << endl, 0;
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].emplace_back(v, i);
    G[v].emplace_back(u, -i);
  }
  dfs(1);
  memset(vis, 0, sizeof vis);
  for (int u : tt) {
    vis[u] = 1;
    for (pair<int, int> e : G[u]) {
      if (!vis[e.first]) {
        if (e.second > 0) {
          f[e.second] -= s[u];
          s[e.first] += s[u];
        } else {
          f[-e.second] += s[u];
          s[e.first] += s[u];
        }
        break;
      }
    }
  }
  cout << "Possible" << endl;
  for (int i = 1; i <= m; i++) cout << f[i] << endl;
}
