#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

void readFile() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	readFile();

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];

		int x = 1;
		int i = 1;
		int ctr = 0;
		int sum = 0;
		vector<int>vec;
		while (i < n) {
			int val = arr[i] + sum;
			while (val < arr[i - 1]) {
				val += x;
				ctr++;
				x *= 2;
			}
			sum += val - arr[i];
			vec.pb(val - arr[i]);
			i++;
		}

		cout << ctr << en;
	}
}


#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

void readFile() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	readFile();

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];
		set<int >set;

		int i = 1;
		int ctr = 0;
		int sum = 0;
		int last = arr[0];
		while (i < n) {
			int req = max(last, arr[i]);
			int steps = 0;
			int x = 1;
			while (arr[i] < req) {
				arr[i] += x;
				x *= 2;
				steps++;
			}
			last = arr[i];
			ctr = max(ctr, steps);
			i++;
		}

		cout << ctr << en;
	}
}


#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

void readFile() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	readFile();

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];

		int x = 1;
		int i = 1;
		int ctr = 0;
		vector<int>vec;
		while (i < n) {
			int val = arr[i];
			while (val < arr[i - 1]) {
				val += x;
				ctr++;
				x *= 2;
			}
			vec.pb(val - arr[i]);
			i++;
		}

		cout << ctr << en;
	}
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		if(mp[s]){
			x = mp[s];
			d = t-mp[s];
			break;
		}
		mp[s] = t;
		p[t ++] = s;
	}
	if(k == 0){
		cout << p[0] << endl;
		return 0;
	}
	if(d == 0){
		cout << p[1] << endl;
		return 0;
	}
	if(k < x)	cout << p[k] << endl;
	else	cout << p[(k-x) % d + x] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		p[t ++] = s;
		if(mp[s]){
			x = mp[s];
			d = t-1-mp[s];
			break;
		}
		mp[s] = t-1;
	}
	if(t == 1){
		cout << s;
		return 0;
	}
	int w;
	if(d == 0)	w = 1;
	else	w = (k - x) % d;
	if(k < t){
		cout << p[k] << endl;
		return 0;
	}
	cout << p[w] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, x, t, cnt;
string s;
priority_queue <int> p;
map <string, int> mp;
bool ok;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	x = k;
	for(int i = 0; i < n-1; ++ i){
		if(s[i] == '4' && s[i+1] == '7'){
			p.push(-i);
		}
	}
	while(k -- && !p.empty()){
		t = -p.top();
		p.pop();
		if(t % 2){
			s[t] = '7';
			if(t > 0 && s[t-1] == '4'){
				p.push(1-t);
			}
		}
		else{
			s[t+1] = '4';
			if(s[t+2] == '7'){
				p.push(-t-1);
			}
		}
		if(mp[s] && !ok){
			x = (cnt + 1) - mp[s];
			k %= x;
			ok = 1;
		}
		if(!ok)	mp[s] = ++ cnt;
		if(cnt > 100)	ok = 1;
	}
	cout << s << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		p[t ++] = s;
//		cout << s << endl;
		if(mp[s]){
			x = mp[s];
			d = t-1-mp[s];
			break;
		}
		mp[s] = t-1;
	}
	if(t == 1){
		cout << s;
		return 0;
	}
	int w;
	if(d == 0)	w = 1;
	else	w = (k - x) % d + 1;
	cout << p[w] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		p[t ++] = s;
		if(mp[s]){
			x = mp[s];
			d = t-1-mp[s];
			break;
		}
		mp[s] = t-1;
	}
	if(t == 1){
		cout << s;
		return 0;
	}
	if(k <= t-1){
		cout << p[k] << endl;
		return 0;
	}
	int w;
	if(d == 0)	w = 1;
	else	w = (k - x) % d + 1;
	cout << p[w] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, in, a[100005], cnt;
string s;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	for(int i = 1; i <= n; ++ i){
		a[i] = s[i-1] - '0';
	}
	while(k --){
		for(; in < n; ++ in){
			if(a[in] == 4 && a[in+1] == 7){
				break;
			}
		}
		if(in == n)	break;
		if(in % 2 == 0){
			a[in] = 7;
			in --;
		}
		else{
			a[in+1] = 4;
		}
		if(++ cnt >= 100000)	k %= 2;
	}
	for(int i = 1; i <= n; ++ i)
		cout << a[i];
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		if(mp[s]){
			x = mp[s];
			d = t-x;
			break;
		}
		mp[s] = t;
		p[t] = s;
		t ++;
	}
	if(k == 0){
		cout << p[0] << endl;
		return 0;
	}
	else if(k < x)	cout << p[k] << endl;
	else if(d == 0){
		cout << p[t-1] << endl;
		return 0;
	}
	else	cout << p[(k-x) % d + x] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, int> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		p[t ++] = s;
		if(mp[s]){
			x = mp[s];
			d = t-1-mp[s];
			break;
		}
		mp[s] = t-1;
	}
	if(t == 1){
		cout << s;
		return 0;
	}
	if(k < t){
		cout << p[t-1] << endl;
		return 0;
	}
	int w;
	if(d == 0)	w = 1;
	else	w = (k - x) % d + 1;
	cout << p[w] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s, p[100005];
map <string, bool> mp;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		if(mp[s]){
			x = mp[s];
			d = t-x;
			break;
		}
		mp[s] = t;
		p[t] = s;
		t ++;
	}
	if(k == 0){
		cout << p[0] << endl;
		return 0;
	}
	else if(k < x)	cout << p[k] << endl;
	else if(d == 0){
		cout << p[t-1] << endl;
		return 0;
	}
	else	cout << p[(k-x) % d + x] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, x, t, a[100005], cnt;
string s;
priority_queue <int> p;
map <string, int> mp;
bool ok;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	x = k;
	for(int i = 0; i < n-1; ++ i){
		if(s[i] == '4' && s[i+1] == '7'){
			p.push(-i);
		}
	}
	while(k -- && !p.empty()){
		t = -p.top();
		p.pop();
		if(t % 2){
			s[t] = '7';
			if(t > 0 && s[t-1] == '4'){
				p.push(1-t);
			}
		}
		else{
			s[t+1] = '4';
			if(s[t+2] == '7'){
				p.push(-t-1);
			}
		}
		if(mp[s] && !ok){
			x = (cnt + 1) - mp[s];
			k %= x;
			ok = 1;
		}
		if(!ok)	mp[s] = ++ cnt;
	}
	cout << s << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
//string s, p[100005];
string s;
map <string, int> mp;
map <int, string> p;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	p[0] = s;
	while(1){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
		if(mp[s]){
			x = mp[s];
			d = t-x;
			break;
		}
		mp[s] = t;
		p[t] = s;
		t ++;
	}
	if(k == 0){
		cout << p[0] << endl;
		return 0;
	}
	else if(k < x)	cout << p[k] << endl;
	else if(d == 0){
		cout << p[t-1] << endl;
		return 0;
	}
	else	cout << p[(k-x) % d + x] << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, k, t = 1, x, d;
string s;
int main(){
	scanf("%d %d", &n, &k);
	cin >> s;
	while(k --){
		int in = -1;
		for(int i = 0; i < n-1; ++ i){
			if(s[i] == '4' && s[i+1] == '7'){
				in = i;
				break;
			}
		}
		if(in > -1){
			if(in % 2){
				s[in] = '7';
			}
			else{
				s[in+1] = '4';
			}
		}
		else	break;
	}
	cout << s << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

# define ll long long
# define pb push_back
# define ppb pop_back
# define pf push_front
# define ppf pop_front

const ll N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll inf = -1e18;

ll n, k;
string a;

int main() {
    //freopen("in.cpp", "r", stdin);
    //freopen("out.cpp", "w", stdout);
    //ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> k;
    cin >> a;
    for(int i = 0;i < a.size();i++) {
        if(k <= 0) break;
        if(i % 2 == 0) {
            if(a[i] == '4' && a[i + 1] == '7') {
                a[i] = '4';
                a[i + 1] = '4';
                k--;
            }
        }
        else {
            if(a[i] == '4' && a[i + 1] == '7') {
                k--;
                a[i] = '7';
                a[i + 1] = '7';
                i -= 2;
                if(a[i + 1] == '4') {
                    k = k % 2;
                }
            }
        }
    }
    cout << a;
    return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  string orig = w;
  int t = 0;
  while (!pq.empty() && k-- && t < 1000000) {
    if (pq.size() == 1) {
      t++;
    } else {
      t = 0;
    }
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  if (pq.empty()) cout << w << '\n';
  else {
    int pos = pq.top();
    if (k % 2 != 0) {
      if (w[pos] == '7') {
        w[pos] = '7';
        w[pos + 1] = '4';
      } else {
        w[pos] = '4';
        w[pos + 1] = '7';
      }
    }
    cout << w << '\n';
  }
  return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  string orig = w;
  int t = 0;
  while (!pq.empty() && k-- && t < 100) {
    if (pq.size() == 1) {
      t++;
    } else {
      t = 0;
    }
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  if (pq.empty()) cout << w << '\n';
  else {
    int pos = pq.top();
    if (k % 2 != 0) {
      if (w[pos] == '7') {
        w[pos] = '7';
        w[pos + 1] = '4';
      } else {
        w[pos] = '4';
        w[pos + 1] = '7';
      }
    }
    cout << w << '\n';
  }
  return 0;
}


#include <iostream>
#include <queue>
#include <unordered_set>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  if (k == 0) {
    cout << w << '\n';
    return 0;
  }
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  unordered_set<string> chk;
  vector<string> seen;
  while (!pq.empty() && k--) {
    if (chk.find(w) != chk.end()) {
      k++;
      int pos = 0;
      for (; ; pos++) {
        if (seen[pos] == w) {
          break;
        }
      }
      int mod = seen.size() - pos;
      int place = k % mod;
      pos += place;
      cout << seen[pos] << '\n';
      exit(0);
    }
    chk.insert(w);
    seen.push_back(w);
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  cout << w << '\n';
  return 0;
}


#include <iostream>
#include <queue>
#include <unordered_set>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  if (k == 0) {
    cout << w << '\n';
    return 0;
  }
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  unordered_set<string> chk;
  vector<string> seen;
  while (!pq.empty() && k--) {
    if (chk.find(w) != chk.end()) {
      break;
    }
    chk.insert(w);
    seen.push_back(w);
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  if (pq.empty()) cout << w << '\n';
  else {

    int pos = (pq.top() + k) % seen.size();
 //   cout << k << ' ' << pos << '\n';
   // for (int i =0 ; i < seen.size(); i++) cout << seen[i] << '\n';
    cout << seen[pos] << '\n';
  }
  return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string w;
  int n, k;
  cin >> n >> k >> w;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  string ant1 = "*", ant2 = "*";
  while (!pq.empty() && k--) {
    swap(ant1, ant2);
    int pos = pq.top();
    pq.pop();
     if (w == ant1) {
      if (k % 2 != 0) cout << ant1 << '\n';
      else cout << ant2 << '\n';
      return 0;
    }
    ant1 = w;
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= (int) w.length() - 1 && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  cout << w << '\n';
  return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  while (!pq.empty() && k--) {
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  cout << w << '\n';
  return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  string w;
  int n, k;
  cin >> n >> k >> w;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  string ant1 = "*", ant2 = "*";
  while (!pq.empty() && k--) {
    swap(ant1, ant2);
    int pos = pq.top();
    pq.pop();
     if (w == ant1) {
      if (k % 2 != 0) cout << ant1 << '\n';
      else cout << ant2 << '\n';
      return 0;
    }
    ant1 = w;
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= (int) w.length() - 1 && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  cout << w << '\n';
  return 0;
}


#include <iostream>
#include <queue>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string w;
  int n, k, tamanho;
  cin >> n >> k >> w;
  tamanho = w.length() - 1;
  priority_queue<int, vector<int>,  greater<int> > pq;
  for (int i = 1; i < n; i++) {
    if (w[i] == '7' && w[i - 1] == '4') {
      pq.push(i - 1);
    }
  }
  string orig = w;
  int t = 0;
  while (!pq.empty() && k-- && t < 100000) {
    if (pq.size() == 1) {
      t++;
    } else {
      t = 0;
    }
    int pos = pq.top();
    pq.pop();
    if (pos % 2 != 0) {
      w[pos] = '7';
      w[pos + 1] = '7';
      if (pos - 1 >= 0 && w[pos - 1] == '4') {
        pq.push(pos - 1);
      }
    } else {
      w[pos] = '4';
      w[pos + 1] = '4';
      if (pos + 2 <= tamanho && w[pos + 2] == '7') {
        pq.push(pos + 1);
      }
    }
  }
  if (pq.empty()) cout << w << '\n';
  else {
    int pos = pq.top();
    if (k % 2 != 0) {
      if (w[pos] == '7') {
        w[pos] = '7';
        w[pos + 1] = '4';
      } else {
        w[pos] = '4';
        w[pos + 1] = '7';
      }
    }
    cout << w << '\n';
  }
  return 0;
}


#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,k;
char s[100005],pre[100005],prepre[100005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>s;
	int cnt=0;
	if(k==0)
	{
		cout<<s<<endl;
		return 0;
	}
	while(1)
	{
		bool flag=true;
		for(int i=0;i<n;i++)
			if(s[i]!=pre[i])
			{
				flag=false;
				break;
			}
		if(flag) break;
		flag=true;
		for(int i=0;i<n;i++)
			if(s[i]!=prepre[i])
			{
				flag=false;
				break;
			}
		if(flag) break;
		memcpy(prepre,pre,sizeof(pre));
		memcpy(pre,s,sizeof(s));
		int id=-1;
		for(int i=0;i<n-1;i++)
			if(s[i]=='4'&&s[i+1]=='7')
			{
				id=i;
				break;
			}
		if(id==-1)
		{
			cnt++;
			continue;
		}
		if(id%2==0) s[id]=s[id+1]='4';
		else s[id]=s[id+1]='7';
		cnt++;
		if(cnt==k)
		{
			cout<<s<<endl;
			return 0;
		}
	}
	bool flag=true;
	for(int i=0;i<n;i++)
		if(s[i]!=pre[i])
		{
			flag=false;
			break;
		}
	if(flag)
	{
		cout<<s<<endl;
		return 0;
	}
	if((k-cnt)%2==0)
		cout<<s<<endl;
	else
		cout<<pre<<endl;
	return 0;
}


// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <bitset>

#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5 , MOD = 1e9 + 7 , MAXN = 1e8 + 1000 , LG = 30 , M = 1e6 + 5 , P = 727 , Sq = 100;
const ll inf = 3e18 + 10;

int n, k;
string s;

int main(){
      cin >> n >> k >> s;
      for(int i = 0; i < n; i++){
            if(i < n - 1 && s[i] == '4' && s[i + 1] == '7'){
                  if((i + 1) % 2 == 0){
                        if(i > 0 && s[i - 1] == '4'){
                              if(k % 2 == 0)
                                    return cout << s, 0;
                              s[i] = '7';
                              return cout << s, 0;
                        }
                        else{
                              s[i] = '7';
                        }
                  }
                  else{
                        if(i + 2 < n && s[i + 2] == '7'){
                              if(k % 2 == 0)
                                    return cout << s, 0;
                              s[i + 1] = '4';
                              return cout << s, 0;
                        }
                        else{
                              s[i + 1] = '4';
                        }
                  }
                  k--;
                  if(!k)
                        return cout << s, 0;
            }
      }
      return cout << s, 0;
}


// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <bitset>

#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5 , MOD = 1e9 + 7 , MAXN = 1e8 + 1000 , LG = 30 , M = 1e6 + 5 , P = 727 , Sq = 100;
const ll inf = 3e18 + 10;

int n, k;
string s;

int main(){
      cin >> n >> k >> s;
      if(!k)
            return cout << s, 0;
      for(int i = 0; i < n; i++){
            if(i < n - 1 && s[i] == '4' && s[i + 1] == '7'){
                  if((i + 1) % 2 == 0){
                        if(i > 0 && s[i - 1] == '4'){
                              if(k % 2 == 0)
                                    return cout << s, 0;
                              s[i] = '7';
                              return cout << s, 0;
                        }
                        else{
                              s[i] = '7';
                        }
                  }
                  else{
                        if(i + 2 < n && s[i + 2] == '7'){
                              if(k % 2 == 0)
                                    return cout << s, 0;
                              s[i + 1] = '4';
                              return cout << s, 0;
                        }
                        else{
                              s[i + 1] = '4';
                        }
                  }
                  k--;
                  if(!k)
                        return cout << s, 0;
            }
      }
      return cout << s, 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

void bfs(){

}

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
	while (cin >> n >> k){
		getchar();
		cin >> s;
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		if (k==0) {
			cout << s << endl;
			continue;
		}
		for (i=0;i<ls-1;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
				if ((i+1)%2) {
					s[i]=s[i+1]='4';
					if (i+2<ls && s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
						else s[i+1]='4';
						break;
					}
				}
				else {
					s[i]=s[i+1]='7';
					if (i-1>=0 && s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
						else s[i]='7';
						break;
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

void bfs(){

}

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
	while (cin >> n >> k){
		getchar();
		getline(cin,s);
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		for (i=0;ls-2;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				if (i%2==0) {
					s[i+1]='4';k--;
				}
				else {
					s[i]='7';k--;
					if (s[i-1]=='4' && s[i]=='7' && s[i+1]=='7'){
						cnt=i-1;
						break;
					}
				}
			}
		}
		if (k%2==1) {
			s[cnt]='4';s[cnt+1]='7';s[cnt+2]='7';
		}
		cout << s << endl;
	}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
		cin >> n >> k;
		getchar();
		cin >> s;
//		cout << s << endl;
		int ls=s.size();
		if (k==0) {
			cout << s << endl;
		}
		else {
			for (int i=0;i<ls-1;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
					if ((i+1)%2) {
					s[i]=s[i+1]='4';
						if (i+2<ls && s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
							else s[i+1]='4';
							break;
						}
					}
					else {
						s[i]=s[i+1]='7';
						if (i-1>=0 && s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
							else s[i]='7';
							break;
						}
					}
			}

			}
			cout << s << endl;
		}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
		cin >> n >> k;
		getchar();
		cin >> s;
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		if (k==0) {
			cout << s << endl;
		}
		else {
			for (i=0;i<ls-1;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
				if ((i+1)%2) {
					s[i]=s[i+1]='4';
					if (i+2<ls && s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
						else s[i+1]='4';
						break;
					}
				}
				else {
					s[i]=s[i+1]='7';
					if (i-1>=0 && s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
						else s[i]='7';
						break;
					}
				}
			}

		}
		cout << s << endl;
	}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

void bfs(){

}

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
	while (cin >> n >> k){
		getchar();
		getline(cin,s);
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		if (k==0) {
			cout << s << endl;
			continue;
		}
		for (i=0;ls-2;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
				if ((i+1)%2) {
					s[i]=s[i+1]='4';
					if (s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
						else s[i+1]='4';
						break;
					}
				}
				else {
					s[i]=s[i+1]='7';
					if (s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
						else s[i]='7';
						break;
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

void bfs(){

}

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
	while (cin >> n >> k){
		getchar();
		cin >> s;
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		if (k==0) {
			cout << s << endl;
			continue;
		}
		for (i=0;i<ls-2;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
				if ((i+1)%2) {
					s[i]=s[i+1]='4';
					if (s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
						else s[i+1]='4';
						break;
					}
				}
				else {
					s[i]=s[i+1]='7';
					if (s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
						else s[i]='7';
						break;
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
		cin >> n >> k;
		getchar();
		cin >> s;
//		cout << s << endl;
		int ls=s.size();
		if (k==0) {
			cout << s << endl;
		}
		else {
			for (int i=0;i<ls-1;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
					if ((i+1)%2) {
					s[i]=s[i+1]='4';
						if (i+2<ls && s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
							else s[i+1]='4';
							break;
						}
					}
					else {
						s[i]=s[i+1]='7';
						if (i-1>=0 && s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
							else s[i]='7';
							break;
						}
					}
					if (k==0) break;
			}

			}
			cout << s << endl;
		}
	return 0;
}


//
//  Created by  CQU_CST_WuErli
//  Copyright (c) 2015�� CQU_CST_WuErli. All rights reserved.
//
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <time.h>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#define cir(i,a,b)  for (int i=a;i<=b;i++)
#define CIR(j,a,b)  for (int j=a;j>=b;j--)
#define CLR(x) memset(x,0,sizeof(x))
#define root 1,n,1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define INF 0x3f3f3f3f
#define BUG(x) cout << "I am in line" << x << endl
const double eps=1e-9;
const double pi=acos(-1);
typedef long long  ll;
using namespace std;

int n;
ll k;
string s;

void bfs(){

}

int main(){
#ifdef LOCAL
	freopen("C:\\Users\\john\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\john\\Desktop\\out.txt","w",stdout);
#endif
	while (cin >> n >> k){
		getchar();
		cin >> s;
//		cout << s << endl;
		int k;
		int ls=s.size();
		int i;
		int cnt;
		if (k==0) {
			cout << s << endl;
			continue;
		}
		for (i=0;i<=ls-2;i++){
			if (s[i]=='4' && s[i+1]=='7') {
				k--;
				if ((i+1)%2) {
					s[i]=s[i+1]='4';
					if (s[i+2]=='7'){
						if (k%2==1) s[i+1]='7';
						else s[i+1]='4';
						break;
					}
				}
				else {
					s[i]=s[i+1]='7';
					if (s[i-1]=='4' ){
						if (k%2==1) s[i]='4';
						else s[i]='7';
						break;
					}
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


#include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <list>
#include<cstdlib>
using namespace std;
#define pi acos(-1.0)
typedef long long ll;
const int inf = 1000000007;
const int maxn = 3e5+7;
const double eps = 1e-12;
typedef double db;
const ll mod = 998244353;
int n = 0, m, k, cnt;
int vis[maxn], aa[maxn],bb[maxn];
bool use[maxn];
list<int>st;
int main()
{
	while (~scanf("%d%d", &n, &k)) {
		string s;
		cin >> s;
		int flag = 0;
		for (int i = 0; i < s.length() - 1 && k; i++) {
			if (s[i] == '4' && s[i + 1] == '7') {
				if (i >= 1 && s[i - 1] == '4') {
					if (i % 2 == 1) {
						if (k % 2 == 1) {
							s[i] = '7';
						}
						k -= k, flag = 1;
						continue;
					}
				}
				if (i % 2 == 0)
					s[i + 1] = '4';
				else
					s[i] = '7';
				flag = 1;
				k--;
			}
		}
		cout << s << endl;
	}
}

	    	  	  	    	 	 		 		  				//hellobig_tq


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
string s;
ll n,k;
bool check[100005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>k>>s;
    for(int i=0;i<s.size()&&k;++i)
    {
        if(s[i]=='4'&&s[i+1]=='7')
        {
            if((i+1)%2) s[i+1]='4',--k;
            else if(i>=1&&s[i-1]=='4') s[i]='7',--k,i-=2;
        }
    }
    cout<<s;
    return 0;
}
// 447
// 477
// 447
// 477


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
string s;
ll n,k;
bool check[100005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>k>>s;
    for(int i=0;i<s.size()&&k;++i)
    {
        if(i<0) continue;
        if(s[i]=='4'&&s[i+1]=='7')
        {
            if(i>=1&&s[i-1]=='4')
            {
                if(k%2&&i%2) s[i]='7';
                else if(k%2) s[i+1]='4';
                break;
            }
             if(i%2==0) s[i+1]='4',--k;
             else s[i]='7',--k,i-=2;
        }
    }
    cout<<s;
    return 0;
}
// 447
// 477
// 447
// 477


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
string s;
ll n,k;
bool check[100005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>k>>s;
    for(int i=0;i<s.size()&&k;++i)
    {
        if(i<0) continue;
        if(s[i]=='4'&&s[i+1]=='7')
        {
            if(check[i])
            {
                if(k%2&&i%2) s[i]='7';
                else if(k%2) s[i+1]='4';
                break;
            }
             check[i]=1;
             if(i%2==0) s[i+1]='4',--k;
             else s[i]='7',--k,i-=2;
        }
    }
    cout<<s;
    return 0;
}
// 447
// 477
// 447
// 477


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
string s;
ll n,k;
bool check[100005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>k>>s;
    for(int i=0;i<s.size()&&k;++i)
    {
        if(s[i]=='4'&&s[i+1]=='7')
        {
            if(i>=1&&s[i-1]=='4')
            {
                if(k%2&&i%2) s[i]='7';
                else if(k%2) s[i+1]='4';
                break;
            }
             if(i%2==0) s[i+1]='4',--k;
             else s[i]='7',--k,i-=2;
        }
    }
    cout<<s;
    return 0;
}
// 447
// 477
// 447
// 477


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100007

int n,k,ptr;
string s;
deque<int> q;

void solve(string str){
    if(!q.empty()){
        int ptr = q.front();
//      /cout<<ptr<<endl;
        q.pop_front();
        if(ptr%2){
            s[ptr] = '7';
            if(s[ptr-1]=='4'){
                q.push_front(ptr-1);
            }
            //cout<<s<<endl;
        }else{
            s[ptr+1] = '4';
            if(s[ptr+2] == '7'){
                q.push_front(ptr+1);
            }
            //cout<<s<<endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='4' and s[i+1]=='7'){
            q.push_back(i);
        }
    }
    ptr = 0;
    for(int i=0;i<k;i++){
        solve(s);
        //cout<<s<<endl;
    }
    cout<<s<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100007

int n,k,ptr;
string s;
deque<int> q;
/*
void solve(string str){
    if(!q.empty()){
        ptr = q.front();
//      /cout<<ptr<<endl;
        q.pop_front();
        if(ptr%2){
            s[ptr] = '7';
            if(s[ptr-1]=='4'){
                q.push_front(ptr-1);
            }
            //cout<<s<<endl;
        }else{
            s[ptr+1] = '4';
            if(s[ptr+2] == '7'){
                q.push_front(ptr+1);
            }
            //cout<<s<<endl;
        }
    }
}
*/
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='4' and s[i+1]=='7'){
            q.push_back(i);
        }
    }
    ptr = 0;
    while(k--){
        if(!q.empty()){
        ptr = q.front();
//      /cout<<ptr<<endl;
        q.pop_front();
        if(ptr%2){
            s[ptr] = '7';
            if(s[ptr-1]=='4'){
                q.push_front(ptr-1);
            }
            //cout<<s<<endl;
        }else{
            s[ptr+1] = '4';
            if(s[ptr+2] == '7'){
                q.push_front(ptr+1);
            }
            //cout<<s<<endl;
        }
     }

    }
    printf("%s",s.c_str());
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN 100007

int n,k,ptr;
string s;
deque<int> q;

void solve(string str){
    if(!q.empty()){
        ptr = q.front();
//      /cout<<ptr<<endl;
        q.pop_front();
        if(ptr%2){
            s[ptr] = '7';
            if(s[ptr-1]=='4'){
                q.push_front(ptr-1);
            }
            //cout<<s<<endl;
        }else{
            s[ptr+1] = '4';
            if(s[ptr+2] == '7'){
                q.push_front(ptr+1);
            }
            //cout<<s<<endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='4' and s[i+1]=='7'){
            q.push_back(i);
        }
    }
    ptr = 0;
    for(int i=0;i<k;i++){
        solve(s);
        //cout<<s<<endl;
    }
    cout<<s<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	for (int i = 0; i < n - 1; i++) {
		if(k == 0)
			break;
		if(s[i] == '4' && s[i + 1] == '7') {
			if(i & 1) {
				if(i - 1 >= 0 && s[i - 1] == '4') {
					if(k % 2 == 1) {
						s[i] = '7';
					}
					break;
				}
				s[i] = '7';
			}
			else {
				if(i + 2 == n || s[i + 2] != '7') {
					s[i + 1] = '4';
				}
				else {
					if(k % 2 == 1)
						s[i + 1] = '4';
					break;
				}
			}
			k--;
		}
	}
	cout << s;
}


// #pragma GCC optimize("no-stack-protector")
// #pragma GCC diagnostic ignored "-W"

#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<sstream>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<vector>
#include<utility>

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vint vector<int>
#define SS stringstream
#define PQ priority_queue
#define PRF(...) printf(__VA_ARGS__)
#define MS(x,v) memset((x),(v),sizeof(x))
#define RZUNI(x) sort(x.begin(),x.end()), x.resize(unique(x.begin(),x.end())-x.begin())
#define FLH fflush(stdout)
#define CPPinput ios_base::sync_with_stdio(0); cin.tie(0)

#define tm Ovuvuevuevue
#define y1 Enyetuenwuevue
#define left Ugbemugbem
#define ws Osas
#define dec tetteterette
#define exp expexpexpexp
#define expl explexplexpl

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl

#ifdef WEAK
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define PDE1(a) cout<<#a<<" = "<<(a)<<endl
#define PDE2(a,b) cout<<#a<<" = "<<(a)<<" , ", PDE1(b)
#define PDE3(a,b,c) cout<<#a<<" = "<<(a)<<" , ", PDE2(b,c)
#define PDE4(a,b,c,d) cout<<#a<<" = "<<(a)<<" , ", PDE3(b,c,d)
#define PDE5(a,b,c,d,e) cout<<#a<<" = "<<(a)<<" , ", PDE4(b,c,d,e)
#define PDE(...) macro_dispatcher(PDE, __VA_ARGS__)(__VA_ARGS__)
#define DEB(...) printf(__VA_ARGS__),fflush(stdout)
#define WHR() printf("%s: Line %d",__PRETTY_FUNCTION__,__LINE__),fflush(stdout)
#define LOG(...) printf("%s: Line %d ",__PRETTY_FUNCTION__,__LINE__),printf(__VA_ARGS__),fflush(stdout)
#define FIN freopen("in","r",stdin)
#define FOUT freopen("out","w",stdout)
#define DEBUG 1
#define exit(x) cout<<"exit code "<<x<<endl, exit(0)
#else
#define PDE(...) ;
#define PDE1(a) ;
#define PDE2(a,b) ;
#define PDE3(a,b,c) ;
#define PDE4(a,b,c,d) ;
#define PDE5(a,b,c,d,e) ;
#define DEB(...) ;
#define WHR() ;
#define LOG(...) ;
#define getchar gtx
#define FIN ;
#define FOUT ;
#define DEBUG 0
#endif

#define lowbit(x) ((x)&(-(x)))

#if __cplusplus >= 201103L
#include<unordered_map>
#include<unordered_set>
#include<tuple>

template<typename TA,typename TB> ostream& operator<<(ostream& ostm, const pair<TA,TB> &p){ostm<<"("<<p.X<<","<<p.Y<<")";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm, const vector<T> &v){ostm<<"[ ";for(auto i:v)ostm<<i<<" ";ostm<<"]";return ostm;}
template<typename TA,typename TB> ostream& operator<<(ostream &ostm, const map<TA,TB> &mp){ostm<<"[ ";for(auto &it:mp)ostm<<it<<" ";ostm<<"]";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm,const set<T> &s){ostm<<"[ ";for(auto &it:s)ostm<<it<<" ";ostm<<"]";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm,const multiset<T> &s){ostm<<"[ ";for(auto &it:s)ostm<<it<<" ";ostm<<"]";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm,const stack<T> &inp){stack<T> st=inp;ostm<<"[ ";while(!st.empty()){ostm<<st.top()<<" ";st.pop();}ostm<<"]";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm,const queue<T> &inp){queue<T> q=inp;ostm<<"[ ";while(!q.empty()){ostm<<q.front()<<" ";q.pop();}ostm<<"]";return ostm;}
template<typename TA,typename TB,typename TC> ostream& operator<<(ostream &ostm,const priority_queue<TA,TB,TC> &inp){priority_queue<TA,TB,TC> pq=inp;ostm<<"[ ";while(!pq.empty()){ostm<<pq.top()<<" ";pq.pop();}ostm<<"]";return ostm;}
template<typename T> ostream& operator<<(ostream &ostm,const deque<T> &inp){deque<T> dq=inp;ostm<<"[ ";while(!dq.empty()){ostm<<dq.front()<<" ";dq.pop_front();}ostm<<"]";return ostm;}
// ostream& operator<<(ostream &ostm,const __int128 &val){if(!val){ostm<<"0"; return ostm;} bool mns=0; __int128 cpy=(val<0?mns=1,-val:val); stack<char> st; while(cpy)st.push(cpy%10+'0'),cpy/=10; if(mns)st.push('-'); while(st.size())ostm<<st.top(),st.pop(); return ostm;}
#endif

void JIZZ(){cout<<"";exit(0);}

const ld PI=3.14159265358979323846264338327950288;
const ld eps=1e-13;
const ll mod=1e9+7;

int main(){
    CPPinput;
    int n,k; cin>>n>>k;
    string s; cin>>s;
    int prv=-3,ptr=0;
    for(int i=1;i<=k;++i){
        while(ptr<n-1){
            if(s[ptr]=='4' && s[ptr+1]=='7')break;
            ++ptr;
        }
        if(ptr>=n-1)break;
        if(ptr&1){
            s[ptr]='7';
            if(prv==ptr-1){
                i+=(k-i)/2*2;
            }
            if(ptr)--ptr;
        }
        else s[ptr+1]='4';
        prv=ptr;

    }
    cout<<s<<endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;

int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if (x == -1 && y == -1)
	{
		while (s.find("47") != 0 && k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
		}
	}
	else
	{
		if (x != -1 && y != -1)
		{
			if (x < y)
			{
				while (s.find("47") != x + 1 && k > 0)
				{
					int pos = s.find("47");
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[x + 1] = '7';
					}
				}
			}
			else
			{
				while (s.find("47") != y && k > 0)
				{
					int pos = s.find("47");
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[y + 1] = '4';
					}
				}
			}
		}
		else if (x == -1)
		{
			while (s.find("47") != y && k > 0)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
		else if (y == -1)
		{
			while (s.find("47") != x + 1 && k > 0)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[x + 1] = '7';
				}
			}
		}
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;
void work(int x, int y, string &s,int &k)
{
	if (x != -1 && y != -1)
	{
		if (x < y)
		{
			int u = 0;
			while (s.find("47", u) != x + 1 && k > 0 && s.find("47", u) != -1)
			{
				int pos = s.find("47", u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[x + 1] = '7';
				}
			}
		}
		else
		{
			int u = 0;
			while (s.find("47", u) != y && k > 0 && s.find("47", u) != -1)
			{
				int pos = s.find("47", u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
	}
	else if (x == -1)
	{
		int u = 0;
		while (s.find("47", u) != y && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				s[y + 1] = '4';
			}
		}
	}
	else if (y == -1)
	{
		int u = 0;
		while (s.find("47", u) != x + 1 && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				s[x + 1] = '7';
			}
		}
	}
}
int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if (x == -1 && y == -1)
	{
		int u = 0;
		while (s.find("47") != 0 && k > 0 && s.find("47", u) != -1)
		{
			k--;
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			int x = s.find("447");
			int y = s.find("477");
			if (x != -1 || y != -1)work(x, y, s,k);
		}
	}
	else
	{
		work(x, y, s,k);
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;
void work(int x, int y, string &s,int &k)
{
	if (x != -1 && y != -1)
	{
		if (x < y)
		{

			while (s.find("47") != x + 1 && k > 0 && s.find("47") != -1)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					if((x+1)%2==0)s[x + 2] = '4';
					else s[x + 1] = '7';
				}
			}
		}
		else
		{
			while (s.find("47") != y && k > 0 && s.find("47") != -1)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
	}
	else if (x == -1)
	{
		int u = 0;
		while (s.find("47", u) != y && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				s[y + 1] = '4';
			}
		}
	}
	else if (y == -1)
	{
		int u = 0;
		while (s.find("47", u) != x + 1 && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				if ((x + 1) % 2 == 0)s[x + 2] = '4';
				else s[x + 1] = '7';
			}
		}
	}
}
int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if ((x + 1) % 2 == 0)x = -1;
	if (y % 2 == 1)y = -1;
	if (x == -1 && y == -1)
	{
		while (s.find("47") != -1 && k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			int x = s.find("447");
			int y = s.find("477");
			if ((x + 1) % 2 == 0)x = -1;
			if (y % 2 == 1)y = -1;
			//cout << s << endl;
			if (x != -1 || y != -1)
			{
				work(x, y, s, k);
				break;
			}
		}
	}
	else
	{
		while (s.find("47") != -1 && s.find("47") != x + 1 && s.find("47") != y&&k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			int uu = s.find("447");
			if(x==-1)x = uu;
			else x = min(uu, x);
			uu = s.find("477");
			if (y == -1)y = uu;
			else y = min(uu, y);
		}
		work(x, y, s,k);
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;

int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if (x == -1 && y == -1)
	{
		int u = 0;
		while (s.find("47") != 0 && k > 0 && s.find("47", u) != -1)
		{
			k--;
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
		}
	}
	else
	{
		if (x != -1 && y != -1)
		{
			if (x < y)
			{
				int u = 0;
				while (s.find("47",u) != x + 1 && k > 0 && s.find("47", u) != -1)
				{
					int pos = s.find("47",u);
					u = pos + 1;
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[x + 1] = '7';
					}
				}
			}
			else
			{
				int u = 0;
				while (s.find("47",u) != y && k > 0 && s.find("47", u) != -1)
				{
					int pos = s.find("47",u);
					u = pos + 1;
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[y + 1] = '4';
					}
				}
			}
		}
		else if (x == -1)
		{
			int u = 0;
			while (s.find("47",u) != y && k > 0 && s.find("47", u) != -1)
			{
				int pos = s.find("47",u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
		else if (y == -1)
		{
			int u = 0;
			while (s.find("47",u) != x + 1 && k > 0 && s.find("47", u) != -1)
			{
				int pos = s.find("47",u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[x + 1] = '7';
				}
			}
		}
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;
void work(int x, int y, string &s,int &k)
{
	if (x != -1 && y != -1)
	{
		if (x < y)
		{

			while (s.find("47") != x + 1 && k > 0 && s.find("47") != -1)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					if((x+1)%2==0)s[x + 2] = '4';
					else s[x + 1] = '7';
				}
			}
		}
		else
		{
			while (s.find("47") != y && k > 0 && s.find("47" ) != -1)
			{
				int pos = s.find("47");
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
	}
	else if (x == -1)
	{
		int u = 0;
		while (s.find("47", u) != y && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				s[y + 1] = '4';
			}
		}
	}
	else if (y == -1)
	{
		int u = 0;
		while (s.find("47", u) != x + 1 && k > 0 && s.find("47", u) != -1)
		{
			int pos = s.find("47", u);
			u = pos + 1;
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			k--;
		}
		if (k != 0)
		{
			if (k % 2 == 1)
			{
				if ((x + 1) % 2 == 0)s[x + 2] = '4';
				else s[x + 1] = '7';
			}
		}
	}
}
int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if (y % 2 == 1)y = -1;
	if (x == -1 && y == -1)
	{
		while (s.find("47") != -1 && k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			int x = s.find("447");
			int y = s.find("477");
			if (y % 2 == 1)y = -1;
			//cout << s << endl;
			if (x != -1 || y != -1)
			{
				work(x, y, s, k);
				break;
			}
		}
	}
	else
	{
		while (s.find("47") != -1 && s.find("47") != x + 1 && s.find("47") != y&&k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
			int uu = s.find("447");
			if(x==-1)x = uu;
			else x = min(uu, x);
			uu = s.find("477");
			if (y == -1)y = uu;
			else y = min(uu, y);
		}
		work(x, y, s,k);
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;

int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	int x = s.find("447");
	int y = s.find("477");
	if (x == -1 && y == -1)
	{
		while (s.find("47") != 0 && k > 0)
		{
			k--;
			int pos = s.find("47");
			if (pos % 2 == 0)
			{
				s[pos + 1] = '4';
			}
			else
			{
				s[pos] = '7';
			}
		}
	}
	else
	{
		if (x != -1 && y != -1)
		{
			if (x < y)
			{
				int u = 0;
				while (s.find("47",u) != x + 1 && k > 0)
				{
					int pos = s.find("47",u);
					u = pos + 1;
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[x + 1] = '7';
					}
				}
			}
			else
			{
				int u = 0;
				while (s.find("47",u) != y && k > 0)
				{
					int pos = s.find("47",u);
					u = pos + 1;
					if (pos % 2 == 0)
					{
						s[pos + 1] = '4';
					}
					else
					{
						s[pos] = '7';
					}
					k--;
				}
				if (k != 0)
				{
					if (k % 2 == 1)
					{
						s[y + 1] = '4';
					}
				}
			}
		}
		else if (x == -1)
		{
			int u = 0;
			while (s.find("47",u) != y && k > 0)
			{
				int pos = s.find("47",u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[y + 1] = '4';
				}
			}
		}
		else if (y == -1)
		{
			int u = 0;
			while (s.find("47",u) != x + 1 && k > 0)
			{
				int pos = s.find("47",u);
				u = pos + 1;
				if (pos % 2 == 0)
				{
					s[pos + 1] = '4';
				}
				else
				{
					s[pos] = '7';
				}
				k--;
			}
			if (k != 0)
			{
				if (k % 2 == 1)
				{
					s[x + 1] = '7';
				}
			}
		}
	}
	cout << s << endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ll long long

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;

const int MAXN = 1000005;
const int MAXM = 1000005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e30;

int main()
{
	int n, k;
	string s;
	scanf("%d%d", &n, &k);
	cin >> s;
	for (int i = 0; i < n - 1 && k>0; ++i)
	{
		if (s[i] == '4'&&s[i + 1] == '7')
		{
			if (i % 2 == 0)s[i + 1] = '4', k--;
			else
			{
				if (i != 0)
				{
					if (s[i - 1] == '4')
					{
						k = k % 2;
						if (k == 1)s[i] = '7';
						k = 0;
					}
					else
					{
						s[i] = '7';
						k--;
					}
				}
				else
				{
					s[i] = '7';
					k--;
				}
			}
		}
	}
	cout << s << endl;
}


///////////////////////////////////////////////THIS FILE IS AUTO GENERATED ///////////////////////////////////////////////

#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <string>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <sstream>
#include <time.h>

#define _USE_MATH_DEFINES

using namespace std;

#define PI 3.14159265359
#define ll long long
#define ull unsigned long long
#define ld long double

#define getLast(x) x[x.size()-1]
#define mp(a,b) make_pair(a,b)
#define forn(it, a, b) for(auto it = a; it < b; it++)

ld dist(ld x1, ld y1, ld x2, ld y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

vector < ll > p;

void F(ll t, int k) {
	if (k <= 10){
		if (t != 0) {
			p.push_back(t);
		}
		ll z;
		z = t * 10 + 7;
		F(z, k + 1);

		z = t * 10 + 4;
		F(z, k + 1);
	}
}

int main() {
	////////////////////////////
	ios::sync_with_stdio(false);
	///////////////////////////

	int n, k; cin >> n >> k;
	string s; cin >> s;

	if (s.size() == 1) {
		cout << s;
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (k > 0) {
			if (i + 1 && i + 2 < s.size()) {
				if (s[i] == '4' && s[i+1] == '4' && s[i+2] == '7' && i % 2 == 0){
					if (k % 2 == 0) {
						cout << s;
					}
					else {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					return 0;
				}
				if (s[i] == '4' && s[i + 1] == '7' && s[i + 2] == '7' && i % 2 == 0) {
					if (k % 2 == 0) {
						cout << s;
					}
					else {
						s[i] = '4'; s[i + 1] = '4'; s[i + 2] = '7';
						cout << s;
					}
					return 0;
				}
			}
			if (i + 1 < s.size()) {
				if (s[i] == '4' && s[i + 1] == '7') {
					if (i % 2 == 0) {
						s[i] = '4'; s[i + 1] = '4';
					}
					else {
						s[i] = '7'; s[i + 1] = '7';
					}
					k--;
				}
			}
		}
	}
	cout << s;
}


///////////////////////////////////////////////THIS FILE IS AUTO GENERATED ///////////////////////////////////////////////

#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <string>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <sstream>
#include <time.h>

#define _USE_MATH_DEFINES

using namespace std;

#define PI 3.14159265359
#define ll long long
#define ull unsigned long long
#define ld long double

#define getLast(x) x[x.size()-1]
#define mp(a,b) make_pair(a,b)
#define forn(it, a, b) for(auto it = a; it < b; it++)

ld dist(ld x1, ld y1, ld x2, ld y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

vector < ll > p;

void F(ll t, int k) {
	if (k <= 10){
		if (t != 0) {
			p.push_back(t);
		}
		ll z;
		z = t * 10 + 7;
		F(z, k + 1);

		z = t * 10 + 4;
		F(z, k + 1);
	}
}

int main() {
	////////////////////////////
	ios::sync_with_stdio(false);
	///////////////////////////

	int n, k; cin >> n >> k;
	string s; cin >> s;

	if (s.size() == 1) {
		cout << s;
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (k > 0) {
			if (i + 1 && i + 2 < s.size()) {
				if (s[i] == '4' && s[i+1] == '4' && s[i+2] == '7' && i % 2 == 1) {
					if (k % 2 == 0) {
						cout << s;
					}
					else {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					return 0;
				}
				if (s[i] == '4' && s[i + 1] == '7' && s[i + 2] == '7' && i % 2 == 1) {
					if (k % 2 == 0) {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					else {
						cout << s;
					}
					return 0;
				}
			}
			if (i + 1 < s.size()) {
				if (s[i] == '4' && s[i + 1] == '7') {
					if (i % 2 == 0) {
						s[i] = '4'; s[i + 1] = '4';
					}
					else {
						s[i] = '7'; s[i + 1] = '7';
					}
					k--;
				}
			}
		}
	}
	cout << s;
}


///////////////////////////////////////////////THIS FILE IS AUTO GENERATED ///////////////////////////////////////////////

#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <string>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <sstream>
#include <time.h>

#define _USE_MATH_DEFINES

using namespace std;

#define PI 3.14159265359
#define ll long long
#define ull unsigned long long
#define ld long double

#define getLast(x) x[x.size()-1]
#define mp(a,b) make_pair(a,b)
#define forn(it, a, b) for(auto it = a; it < b; it++)

ld dist(ld x1, ld y1, ld x2, ld y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

vector < ll > p;

void F(ll t, int k) {
	if (k <= 10){
		if (t != 0) {
			p.push_back(t);
		}
		ll z;
		z = t * 10 + 7;
		F(z, k + 1);

		z = t * 10 + 4;
		F(z, k + 1);
	}
}

int main() {
	////////////////////////////
	ios::sync_with_stdio(false);
	///////////////////////////

	int n, k; cin >> n >> k;
	string s; cin >> s;

	if (s.size() == 1) {
		cout << s;
		return 0;
	}

	for (int i = 0; i < s.size(); i++) {
		if (k > 0) {
			if (i + 1 && i + 2 < s.size()) {
				if (s[i] == '4' && s[i+1] == '4' && s[i+2] == '7' && i % 2 == 0) {
					if (k % 2 == 0) {
						cout << s;
					}
					else {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					return 0;
				}
				if (s[i] == '4' && s[i + 1] == '7' && s[i + 2] == '7' && i % 2 == 0) {
					if (k % 2 == 0) {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					else {
						cout << s;
					}
					return 0;
				}
			}
			if (i + 1 < s.size()) {
				if (s[i] == '4' && s[i + 1] == '7') {
					if (i % 2 == 0) {
						s[i] = '4'; s[i + 1] = '4';
					}
					else {
						s[i] = '7'; s[i + 1] = '7';
					}
					k--;
				}
			}
		}
	}
	cout << s;
}


///////////////////////////////////////////////THIS FILE IS AUTO GENERATED ///////////////////////////////////////////////

#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <string>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <sstream>
#include <time.h>

#define _USE_MATH_DEFINES

using namespace std;

#define PI 3.14159265359
#define ll long long
#define ull unsigned long long
#define ld long double

#define getLast(x) x[x.size()-1]
#define mp(a,b) make_pair(a,b)
#define forn(it, a, b) for(auto it = a; it < b; it++)

ld dist(ld x1, ld y1, ld x2, ld y2) {
	return sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
}

#if _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <iostream>
#endif

vector < ll > p;

void F(ll t, int k) {
	if (k <= 10){
		if (t != 0) {
			p.push_back(t);
		}
		ll z;
		z = t * 10 + 7;
		F(z, k + 1);

		z = t * 10 + 4;
		F(z, k + 1);
	}
}

int main() {
	////////////////////////////
	ios::sync_with_stdio(false);
	///////////////////////////

	int n, k; cin >> n >> k;
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (k > 0) {
			if (i + 1 && i + 2 < s.size()) {
				if (s[i] == '4' && s[i+1] == '4' && s[i+2] == '7' && i % 2 == 0) {
					if (k % 2 == 0) {
						cout << s;
					}
					else {
						s[i] = '4'; s[i + 1] = '7'; s[i + 2] = '7';
						cout << s;
					}
					return 0;
				}
			}
			if (i + 1 < s.size()) {
				if (s[i] == '4' && s[i + 1] == '7') {
					if (i % 2 == 0) {
						s[i] = '4'; s[i + 1] = '4';
					}
					else {
						s[i] = '7'; s[i + 1] = '7';
					}
					k--;
				}
			}
		}
	}
	cout << s;
}


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
void seq_map(char* s1, char* s2, int n, int* r, int* rn);
int swap_count(int* r, int n);

int main(){
    int n;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    string out[n];int swp = 0; int rn;
    int smap[n];
    seq_map(t,s,n,smap,&rn);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if((smap[i] != 0)&&(smap[j] != 0))
                if((smap[i] == smap[j])&&(i != j)){
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;
                        rn-=2;
                        break;
                    }
        if(rn%2 != 0){
            cout<<"-1";
            return 0;
        }
        else if((rn == 2))
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;

                        break;
                    }

    cout<<swp<<endl;
    for(int i=0;i<swp;i++)
        cout<<out[i]<<endl;
    return 0;
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(char* s1, char* s2, int n, int* r, int* rn){
    *rn =0;
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i]){
            r[i] = 0;
            continue;
        }

        if((s1[i] == 'a')&& (s2[i] == 'b')){
            r[i] = 1;
            *rn+=1;
            continue;
        }
        if((s1[i] == 'b')&& (s2[i] == 'a')){
            r[i] = 2;
            *rn+=1;
            continue;
        }
    }
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    string s,t;
    cin>>t;
    cin>>s;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include <string>

using namespace std;
void seq_map(string s1, string s2, int n, int* r, int* rn);
int swap_count(int* r, int n);

int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string s,t;
    cin>>t;
    cin>>s;
    string out[n];int swp = 0; int rn;
    int smap[n];
    seq_map(t,s,n,smap,&rn);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if((smap[i] != 0)&&(smap[j] != 0))
                if((smap[i] == smap[j])&&(i != j)){
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;
                        rn-=2;
                        break;
                    }
        if(rn%2 != 0){
            cout<<"-1";
            return 0;
        }
        else if((rn == 2))
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;

                        break;
                    }

    cout<<swp<<endl;
    for(int i=0;i<swp;i++)
        cout<<out[i]<<endl;
    return 0;
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(string s1, string s2, int n, int* r, int* rn){
    *rn =0;
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i]){
            r[i] = 0;
            continue;
        }

        if((s1[i] == 'a')&& (s2[i] == 'b')){
            r[i] = 1;
            *rn+=1;
            continue;
        }
        if((s1[i] == 'b')&& (s2[i] == 'a')){
            r[i] = 2;
            *rn+=1;
            continue;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    /*ios::sync_with_stdio(false);
    cin.tie(NULL);*/
    int n,i;
    //string s,t;
    cin>>n;
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
void seq_map(char* s1, char* s2, int n, int* r, int* rn);
int swap_count(int* r, int n);

int main(){
    int n;
    cin>>n;
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    string out[n];int swp = 0; int rn;
    int smap[n];
    seq_map(t,s,n,smap,&rn);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if((smap[i] != 0)&&(smap[j] != 0))
                if((smap[i] == smap[j])&&(i != j)){
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;
                        rn-=2;
                        break;
                    }
        if(rn%2 != 0){
            cout<<"-1";
            return 0;
        }
        else if((rn == 2))
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;

                        break;
                    }

    cout<<swp<<endl;
    for(int i=0;i<swp;i++)
        cout<<out[i]<<endl;
    return 0;
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(char* s1, char* s2, int n, int* r, int* rn){
    *rn =0;
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i]){
            r[i] = 0;
            continue;
        }

        if((s1[i] == 'a')&& (s2[i] == 'b')){
            r[i] = 1;
            *rn+=1;
            continue;
        }
        if((s1[i] == 'b')&& (s2[i] == 'a')){
            r[i] = 2;
            *rn+=1;
            continue;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
    string s,t;
    cin>>n;
    cin>>s;
    cin>>t;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
bool check_seq(char* seq1, char* seq2, int n);
void seq_map(char* s1, char* s2, int n, int* r);
int swap_count(int* r, int n);

int main(){
    int n;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    string out[n];int swp = 0;
    int smap[n];
    seq_map(t,s,n,smap);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            if((smap[i] != 0)&&(smap[j] != 0))
                if((smap[i] == smap[j])&&(i != j)){
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                        smap[i] = 0;smap[j] = 0;
                        break;
                    }
        int tmp = swap_count(smap,n);
        if(tmp%2 != 0){
            cout<<"-1";
            return 0;
        }
        else if((tmp != 0)&&(tmp%2 ==0))
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                            smap[i] = 0;smap[j] = 0;
                    }

    cout<<swp<<endl;
    for(int i=0;i<swp;i++)
        cout<<out[i]<<endl;
    return 0;
}

bool check_seq(char* seq1, char* seq2, int n){
    int a = 0;
    int b = 0;
    for(int i=0;i<n;i++){
        if(seq1[i] == 'a')
            a++;
        if(seq1[i] == 'b')
            b++;
        if(seq1[i] == 'a')
            a++;
        if(seq2[i] == 'b')
            b++;
    }
    return ((a%2 == 0)&&(b%2 == 0));
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(char* s1, char* s2, int n, int* r){
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i])
            r[i] = 0;
        if((s1[i] == 'a')&& (s2[i] == 'b'))
            r[i] = 1;
        if((s1[i] == 'b')&& (s2[i] == 'a'))
            r[i] = 2;
    }
}


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
bool check_seq(char* seq1, char* seq2, int n);
void seq_map(char* s1, char* s2, int n, int* r);
int swap_count(int* r, int n);

int main(){
    int n;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    char t[n];char s[n];
    cin>>setw(n+1)>>t;
    cin>>setw(n+1)>>s;
    if(!check_seq(t,s,n))
        cout<<"-1";
    else{
        string out[n];int swp = 0;
        int smap[n];
        seq_map(t,s,n,smap);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if((smap[i] != 0)&&(smap[j] != 0))
                    if((smap[i] == smap[j])&&(i != j)){
                            out[swp] = to_string(i+1)+" "+to_string(j+1);
                            swp++;
                            smap[i] = 0;smap[j] = 0;
                            break;
                    }
        if(swap_count(smap,n) != 0)
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                            smap[i] = 0;smap[j] = 0;
                    }

        cout<<swp<<endl;
        for(int i=0;i<swp;i++)
            cout<<out[i]<<endl;
    }

    return 0;
}

bool check_seq(char* seq1, char* seq2, int n){
    int a = 0;
    int b = 0;
    for(int i=0;i<n;i++){
        if(seq1[i] == 'a')
            a++;
        if(seq1[i] == 'b')
            b++;
        if(seq1[i] == 'a')
            a++;
        if(seq2[i] == 'b')
            b++;
    }
    return ((a%2 == 0)&&(b%2 == 0));
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(char* s1, char* s2, int n, int* r){
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i])
            r[i] = 0;
        if((s1[i] == 'a')&& (s2[i] == 'b'))
            r[i] = 1;
        if((s1[i] == 'b')&& (s2[i] == 'a'))
            r[i] = 2;
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
    //string s,t;
    cin>>n;
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    string s,t;
    cin>>n;
    //char t[n];char s[n];
    cin>>t;
    cin>>s;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
bool check_seq(char* seq1, char* seq2, int n);
void seq_map(char* s1, char* s2, int n, int* r);
int swap_count(int* r, int n);

int main(){
    int n;
    do{
        cin>>n;
    }while((n<1)||(n>20000));
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    if(!check_seq(t,s,n))
        cout<<"-1";
    else{
        string out[n];int swp = 0;
        int smap[n];
        seq_map(t,s,n,smap);
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if((smap[i] != 0)&&(smap[j] != 0))
                    if((smap[i] == smap[j])&&(i != j)){
                            out[swp] = to_string(i+1)+" "+to_string(j+1);
                            swp++;
                            smap[i] = 0;smap[j] = 0;
                            break;
                    }
        if(swap_count(smap,n) != 0)
            for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                    if((smap[i] != 0)&&(smap[j] != 0)&&(smap[i] != smap[j])){
                        out[swp] = to_string(i+1)+" "+to_string(i+1);
                        swp++;
                        out[swp] = to_string(i+1)+" "+to_string(j+1);
                        swp++;
                            smap[i] = 0;smap[j] = 0;
                    }

        cout<<swp<<endl;
        for(int i=0;i<swp;i++)
            cout<<out[i]<<endl;
    }

    return 0;
}

bool check_seq(char* seq1, char* seq2, int n){
    int a = 0;
    int b = 0;
    for(int i=0;i<n;i++){
        if(seq1[i] == 'a')
            a++;
        if(seq1[i] == 'b')
            b++;
        if(seq1[i] == 'a')
            a++;
        if(seq2[i] == 'b')
            b++;
    }
    return ((a%2 == 0)&&(b%2 == 0));
}

int swap_count(int* r, int n){
    int c = 0;
    for(int i=0;i<n;i++)
        if(r[i] == 0)
            c++;
    return (n-c);
}

void seq_map(char* s1, char* s2, int n, int* r){
    for(int i=0;i<n;i++){
        if(s1[i] == s2[i])
            r[i] = 0;
        if((s1[i] == 'a')&& (s2[i] == 'b'))
            r[i] = 1;
        if((s1[i] == 'b')&& (s2[i] == 'a'))
            r[i] = 2;
    }
}


#include <iostream>
#include <string>

using namespace std;

int main(){
    /*ios::sync_with_stdio(false);
    cin.tie(NULL);*/
    int n,i;
    //string s,t;
    cin>>n;
    char t[n];char s[n];
    cin>>t;
    cin>>s;
    bool swp;

    int ab[n];
    int _ab = 0;
    int ba[n];
    int _ba = 0;

    for(i=0;i<n;i++){
        if((s[i] == 'a') && (t[i] == 'b'))
            ab[_ab++] = i+1;
        else if((s[i] == 'b') && (t[i] == 'a'))
            ba[_ba++] = i+1;
    }
    if(_ab != _ba){
        cout<<"-1";
        return 0;
    }
    i = 0;
    if(_ab%2 == 0) {
        swp = false;
        while(i<_ab){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    else {
        swp = true;
        while(i<_ab-1){
            cout<<ab[i]<<" "<<ab[i+1]<<endl;
            i+=2;
        }
    }
    i = 0;
    if(_ba%2 == 0) {
        while(i<_ba){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    else {
        while(i<_ba-1){
            cout<<ba[i]<<" "<<ba[i+1]<<endl;
            i+=2;
        }
    }
    if(swp){
        cout<<ba[_ba-1]<<" "<<ba[_ba-1]<<endl;
        cout<<ab[_ab-1]<<" "<<ba[_ba-1]<<endl;
    }
    return 0;
}