#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
const int maxn = 2e5;
unsigned char a[maxn + 5];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q, tc;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%hhu", &a[i]);
  scanf("%d", &tc);
  while (tc--) {
    int l, r;
    unsigned char x, y;
    scanf("%d %d %hhu %hhu", &l, &r, &x, &y);
    for (int i = l; i <= r; ++i)
      if (a[i] == x) a[i] = y;
  }
  for (int i = 1; i <= n; ++i) printf("%hi ", a[i]);
}
