#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
string num2bit(long long num, long long len) {
  string bit = "";
  for (int i = 0; i < (int)len; ++i) {
    bit += char('0' + (num >> i & 1));
  }
  return bit;
}
struct edge {
  long long to, idx, rev;
};
vector<long long> visited(202020, false);
vector<long long> s(202020);
long long dfs(long long now, vector<vector<edge>>& G, vector<long long>& res) {
  visited[now] = true;
  long long val = s[now];
  for (auto e : G[now]) {
    if (visited[e.to]) continue;
    long long tmp = dfs(e.to, G, res);
    res[e.idx] = tmp;
    if (e.rev == -1) res[e.idx] = -tmp;
    val += tmp;
  }
  return val;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<vector<edge>> G(n);
  for (int i = 0; i < (int)n; ++i) cin >> s[i];
  long long m;
  cin >> m;
  for (int i = 0; i < (int)m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back((edge){y, i, 1});
    G[y].push_back((edge){x, i, -1});
  }
  long long S = 0;
  for (int i = 0; i < (int)n; ++i) S += s[i];
  if (S == 0) {
    vector<long long> res(m, 0);
    dfs(0, G, res);
    cout << "Possible" << endl;
    for (int i = 0; i < (int)m; ++i) {
      cout << res[i] << "\n";
    }
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}
