#include <bits/stdc++.h>
using namespace std;
class Solver {
 public:
  void solve() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    io.resize(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> io[i];
      sum += io[i];
    }
    cin >> m;
    ans.resize(m, 0);
    edge.resize(m);
    con.resize(n);
    visited.resize(n, false);
    for (int i = 0; i < m; i++) {
      cin >> edge[i].first >> edge[i].second;
      con[--edge[i].first].push_back(i);
      con[--edge[i].second].push_back(i);
    }
    if (sum) {
      cout << "Impossible" << endl;
      return;
    }
    rec(0, -1);
    cout << "Possible" << endl;
    for (int i = 0; i < m; i++) {
      cout << ans[i] << endl;
    }
  }
  void rec(int cur, int from_edge) {
    visited[cur] = true;
    for (int e : con[cur]) {
      if (e == from_edge) {
        continue;
      }
      int nxt = neighbor(cur, e);
      if (visited[nxt]) {
        continue;
      }
      rec(nxt, e);
      if (is_from(cur, e)) {
        ans[e] = io[nxt];
        io[cur] += io[nxt];
        io[nxt] = 0;
      } else {
        ans[e] = -io[nxt];
        io[cur] += io[nxt];
        io[nxt] = 0;
      }
    }
  }
  bool is_from(int u, int e) { return u == edge[e].first; }
  int neighbor(int u, int e) {
    if (u == edge[e].first) return edge[e].second;
    return edge[e].first;
  }
  int n, m;
  vector<int> io;
  vector<bool> visited;
  vector<pair<int, int>> edge;
  vector<vector<int>> con;
  vector<int> ans;
};
int main() {
  Solver sol;
  sol.solve();
  return 0;
}
