#include <bits/stdc++.h>
using namespace std;
struct Fau {
  vector<int> par;
  Fau(int n) : par(n) { iota(par.begin(), par.end(), 0); }
  int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
  int unite(int x, int y) {
    x = root(x);
    y = root(y);
    par[y] = x;
    return x != y;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> s(n);
  for (int& e : s) {
    cin >> e;
    e *= -1;
  }
  int m;
  cin >> m;
  vector<pair<int, int>> edges;
  vector<vector<pair<int, int>>> g(n);
  vector<int> up(n);
  Fau f(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    edges.emplace_back(x, y);
    if (f.unite(x, y)) {
      g[x].emplace_back(y, i);
      g[y].emplace_back(x, i);
    }
  }
  if (accumulate(s.begin(), s.end(), 0) != 0) {
    cout << "Impossible\n";
    return 0;
  }
  for (int i = 0, j = 0; i < n; ++i) {
    while (s[i] > 0) {
      while (j < n && s[j] >= 0) ++j;
      int mn = min(s[i], -s[j]);
      up[i] += mn;
      up[j] -= mn;
      s[i] -= mn;
      s[j] += mn;
    }
  }
  vector<int> result;
  if (m > 0) result.assign(m, 0);
  function<void(int, int)> dfs = [&](int v, int pr) {
    for (auto edge : g[v]) {
      int to = edge.first;
      int id = edge.second;
      if (to == pr) {
        continue;
      }
      dfs(to, v);
      up[v] += up[to];
      result[id] = up[to];
      if (edges[id] != make_pair(to, v)) result[id] *= -1;
    }
  };
  dfs(0, -1);
  cout << "Possible\n";
  for (int i = 0; i < m; ++i) {
    cout << result[i] << '\n';
  }
}
