#include <iostream>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
char s[1000] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> s[i];
}
int i = 0;
int l = 0, r = 0;
char c1, c2;
for (i = 0; i < m; i++)
{
int j = 0;
cin >> l >> r >> c1 >> c2;
for (j = l - 1; j < r; j++)
{
if (s[j] == c1)
{
s[j] = c2;
}
}
}
for (int i = 0; i < n; i++)
{
cout << s[i];
}
cout << endl;
return 0;
}
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
char s[1000] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> s[i];
}
int i = 0;
int l = 0, r = 0;
char c1, c2;
for (i = 0; i < m; i++)
{
int j = 0;
cin >> l >> r >> c1 >> c2;
for (j = l - 1; j < r; j++)
{
if (s[j] == c1)
{
s[j] = c2;
}
}
}
for (int i = 0; i < n; i++)
{
cout << s[i];
}
cout << endl;
return 0;
}