#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << endl;
}
struct edge {
  int u, v;
  int up;
  long long flow;
  bool used;
  edge() {}
  edge(int u, int v) : u(u), v(v) {
    used = 0;
    flow = 0;
  }
  int getto(int v) {
    if (this->v == v) return this->u;
    return this->v;
  }
};
const int N = 2e5 + 9;
vector<edge> e;
vector<int> g[N];
int n, m;
long long s[N];
bool used[N];
long long dp[N];
void dfs1(int v, int par) {
  used[v] = 1;
  dp[v] = s[v];
  for (int id : g[v]) {
    int to = e[id].getto(v);
    if (par == to) continue;
    if (used[to]) continue;
    e[id].used = 1;
    e[id].up = v;
    dfs1(to, v);
    dp[v] += dp[to];
  }
}
void dfs2(int v, int par, long long up) {
  long long sum = up;
  sum += s[v];
  for (int id : g[v]) {
    int to = e[id].getto(v);
    if (to == par || !e[id].used) continue;
    sum += dp[to];
  }
  for (int id : g[v]) {
    int to = e[id].getto(v);
    if (to == par || !e[id].used) continue;
    sum -= dp[to];
    e[id].flow = sum;
    if (sum != -dp[to]) {
      cout << "Impossible" << endl;
      exit(0);
    }
    dfs2(to, v, sum);
    sum += dp[to];
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < int(n); ++i) {
    cin >> s[i + 1];
    s[i + 1] *= -1;
  }
  cin >> m;
  for (int iter = 0; iter < int(m); ++iter) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(e.size());
    g[v].push_back(e.size());
    e.push_back(edge(u, v));
  }
  for (int i = 1; i <= n; ++i)
    if (!used[i]) {
      dfs1(i, -1);
      if (dp[i]) {
        cout << "Impossible" << endl;
        return 0;
      }
      dfs2(i, -1, 0);
    }
  cout << "Possible\n";
  for (int id = 0; id < int(m); ++id) {
    if (!e[id].used)
      cout << "0\n";
    else {
      if (e[id].up == e[id].v) e[id].flow *= -1;
      cout << e[id].flow << "\n";
    }
  }
}
