Can anybody explain What I am doing wrong?

This is my simple solution approach for problem SWAP10HG given in December Lunchtime 2020 Div 2, It is AC on all testcase but not on first, the testcase with the easiest bounds, I am not able to figure out, what is wrong here,

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define loop(i, a, b) for(int i=(a);i<=(b);i++)
#define looprev(i, a, b) for(int i=(a);i<=(b);i--)
#define mid(low, high) ((low)+((high)-(low))/2)
#define vi vector<ll>
#define all(x) x.begin(),x.end()
#define setbits(x) __builtin_popcount(x)
#define eb emplace_back
#define po pop_back
#define fast_io ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);
#define F first
#define S second
#define np next_permutation
#define pq priority_queue
#define inf 1e18
#define mod 1000000007
#define w(t) while(t--)
#define print(arr, low, high) for(int i=(low); i<=(high); i++)cout<<(arr[i])<<" ";cout<<endl;
#define debug(n) cout << "n is : " << (n) << endl;

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

int main() {
	file();
	int t;
	cin >> t;
	while (t--) {
		int n; cin >> n;
		string a, b; cin >> a >> b;
		int i = 0, j = n - 1;
		while (i < j) {
			while (a[i] == b[i])
				i++;
			while (a[j] == b[j])
				j--;
			if (a[i] != b[i] && a[j] != b[j] && i < j && a[i] == '1' && a[j] == '0') {
				swap(a[i], a[j]);
				i++;
				j--;
			} else {
				break;
			}

		}
		if (a != b)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	return 0;
}