#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;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
unsigned char a[200042];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%hhu", &a[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 - 1; i < r; i++) a[i] = a[i] == x ? y : a[i];
  }
  for (int i = 0; i < n; ++i) printf("%hhu ", a[i]);
  return 0;
}
