#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long mxn = 200005;
const int mod = 1000000007;
unsigned char arr[mxn + 1];
void solve_case() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%hhu", &arr[i]);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    unsigned char x, y;
    scanf("%d %d %hhu %hhu", &l, &r, &x, &y);
    for (int i = l; i <= r; i++) {
      if (arr[i] == x) arr[i] = y;
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%hhu ", arr[i]);
  }
  printf("\n");
  return;
}
int main() {
  solve_case();
  return 0;
}
