#include <bits/stdc++.h>
struct edge {
  int a, b, ind, flow;
};
const int N = 200000;
int n, m;
int s[N];
bool u[N];
std::vector<int> g_[N], g[N];
std::vector<edge> e_, e;
int ans[N];
void dfs_t(int v) {
  u[v] = true;
  for (int i = 0; i < (int)g_[v].size(); ++i)
    if (!u[e_[g_[v][i]].b]) {
      g[e_[g_[v][i] & ~1].a].push_back(e.size());
      e.push_back(e_[g_[v][i] & ~1]);
      g[e_[g_[v][i] | 1].a].push_back(e.size());
      e.push_back(e_[g_[v][i] | 1]);
      dfs_t(e_[g_[v][i]].b);
    }
}
int dfs_into(int v, int edge_i = -1) {
  int flow;
  if (s[v] < 0)
    flow = -s[v];
  else
    flow = 0;
  for (int i = 0; i < (int)g[v].size(); ++i)
    if (edge_i == -1 || e[g[v][i]].b != e[edge_i].a)
      flow += dfs_into(e[g[v][i]].b, g[v][i]);
  if (edge_i != -1) {
    e[edge_i].flow -= flow;
    e[edge_i ^ 1].flow += flow;
  }
  return flow;
}
int dfs_from(int v, int pr = -1) {
  int flow;
  if (s[v] > 0)
    flow = s[v];
  else
    flow = 0;
  for (int i = 0; i < (int)g[v].size(); ++i)
    if (e[g[v][i]].b != pr) {
      int cur = dfs_from(e[g[v][i]].b, v);
      e[g[v][i]].flow += cur;
      e[g[v][i] ^ 1].flow -= cur;
      flow += cur;
    }
  return flow;
}
int main() {
  scanf("%d", &n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", s + i);
    sum += s[i];
  }
  if (sum) {
    printf("Impossible\n");
    return 0;
  }
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g_[a].push_back(e_.size());
    e_.push_back({a, b, i, 0});
    g_[b].push_back(e_.size());
    e_.push_back({b, a, i, 0});
  }
  dfs_t(0);
  dfs_into(0);
  dfs_from(0);
  printf("Possible\n");
  for (int i = 0; i < (int)e.size(); i += 2) ans[e[i].ind] = e[i].flow;
  for (int i = 0; i < m; ++i) printf("%d\n", ans[i]);
  return 0;
}
