#include <bits/stdc++.h>
using namespace std;
int dfs(const vector<vector<array<int, 3>>>& edges, vector<int>& ans,
        vector<int>& s, vector<char>& used, int v) {
  used[v] = true;
  int sum = 0;
  for (auto& w : edges[v]) {
    if (!used[w[0]]) {
      int d = dfs(edges, ans, s, used, w[0]);
      ans[w[1]] = -d * w[2];
      sum += d;
    }
  }
  return sum - s[v];
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  cin >> m;
  if (n == 1) {
    cout << (s[0] == 0 ? "Possible" : "Impossible");
    return 0;
  }
  vector<vector<array<int, 3>>> edges(n);
  vector<int> ans(m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    edges[x].push_back({y, i, 1});
    edges[y].push_back({x, i, -1});
  }
  vector<char> used(n);
  if (dfs(edges, ans, s, used, 0) == 0) {
    cout << "Possible\n";
    for (int i : ans) {
      cout << i << endl;
    }
  } else {
    cout << "Impossible";
  }
  return 0;
}
