#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T>
class red_black_tree {

	using COL = bool;
	static const COL RED = false, BLACK = true;

	struct node {
		COL color;
		int size;
		T val;
		node *p, *ch[2];
		node() : color(BLACK), size(0), val(), p(nullptr), ch{ nullptr, nullptr } {}
		node(COL c, T v, node *par, node *l, node *r) : color(c), size(1), val(v), p(par), ch{ l, r } {}
	} *NIL, *root;

	node* new_node(T val) {
		return new node(RED, val, NIL, NIL, NIL);
	}
	void update(node *x) {
		x->size = x->ch[0]->size + 1 + x->ch[1]->size;
	}
	void rotate(node *x, int b) {
		node *y = x->ch[1 - b];
		x->ch[1 - b] = y->ch[b];
		if (y->ch[b] != NIL) {
			y->ch[b]->p = x;
		}
		y->p = x->p;
		if (x->p == NIL) {
			root = y;
		}
		else {
			x->p->ch[x != x->p->ch[0]] = y;
		}
		y->ch[b] = x;
		x->p = y;
		update(x);
		update(y);
	}
	void insert_fix(node *x) {
		while (x->p->color == RED) {
			int b = (x->p != x->p->p->ch[0]);
			node *y = x->p->p->ch[1 - b];
			if (y->color == RED) {
				x->p->color = BLACK;
				y->color = BLACK;
				x->p->p->color = RED;
				x = x->p->p;
				continue;
			}
			if (x == x->p->ch[1 - b]) {
				x = x->p;
				rotate(x, b);
			}
			x->p->color = BLACK;
			x->p->p->color = RED;
			rotate(x->p->p, 1 - b);
		}
		root->color = BLACK;
	}
	void transplant(node *u, node *v) {
		if (u->p == NIL) {
			root = v;
		}
		else {
			u->p->ch[u != u->p->ch[0]] = v;
		}
		v->p = u->p;
	}
	void erase_fix(node *x) {
		while (x != root && x->color == BLACK) {
			int b = (x != x->p->ch[0]);
			node *w = x->p->ch[1 - b];
			if (w->color == RED) {
				w->color = BLACK;
				x->p->color = RED;
				rotate(x->p, b);
				w = x->p->ch[1 - b];
			}
			if (w->ch[b]->color == BLACK && w->ch[1 - b]->color == BLACK) {
				w->color = RED;
				x = x->p;
				continue;
			}
			if (w->ch[1 - b]->color == BLACK) {
				w->ch[b]->color = BLACK;
				w->color = RED;
				rotate(w, 1 - b);
				w = x->p->ch[1 - b];
			}
			w->color = x->p->color;
			x->p->color = BLACK;
			w->ch[1 - b]->color = BLACK;
			rotate(x->p, b);
			x = root;
		}
		x->color = BLACK;
	}
	node* find(node *x, T val) const {
		while (x != NIL) {
			if (val == x->val) return x;
			x = x->ch[val > x->val];
		}
		return NIL;
	}
	node* minimum(node *x) const {
		if (x == NIL) return NIL;
		while (x->ch[0] != NIL) {
			x = x->ch[0];
		}
		return x;
	}
	node* maximum(node *x) const {
		if (x == NIL) return NIL;
		while (x->ch[1] != NIL) {
			x = x->ch[1];
		}
		return x;
	}
	int cnt(node *t, T v) const {
		if (t == NIL) return 0;
		if (t->val < v) return t->ch[0]->size + 1 + cnt(t->ch[1], v);
		if (t->val == v) return t->ch[0]->size;
		return cnt(t->ch[0], v);
	}
public:
	red_black_tree() : NIL(new node()), root(NIL) {}
	int size() const {
		return root->size;
	}
	T minimum() const {
		return minimum(root)->val;
	}
	T maximum() const {
		return maximum(root)->val;
	}
	bool count(T val) const {
		return find(root, val) != NIL;
	}
	int count_lower(T val) const {
		return cnt(root, val);
	}
	T operator[](int k) const {
		node *x = root;
		while (x->ch[0]->size != k) {
			if (k < x->ch[0]->size) {
				x = x->ch[0];
			}
			else {
				k -= x->ch[0]->size + 1;
				x = x->ch[1];
			}
		}
		return x->val;
	}
	void insert(T val) {
		node *x = root, *y = NIL;
		while (x != NIL) {
			if (val == x->val) return;
			y = x;
			x = x->ch[val > x->val];
		}
		node *v = new_node(val);
		v->p = y;
		if (y == NIL) {
			root = v;
		}
		else {
			y->ch[val > y->val] = v;
		}
		while (y != NIL) update(y), y = y->p;
		insert_fix(v);
	}
	void erase(T val) {
		node *x = find(root, val);
		if (x == NIL) return;
		node *y = x, *z;
		COL c = y->color;
		if (x->ch[0] == NIL) {
			z = x->ch[1];
			transplant(x, x->ch[1]);
		}
		else if (x->ch[1] == NIL) {
			z = x->ch[0];
			transplant(x, x->ch[0]);
		}
		else {
			y = minimum(x->ch[1]);
			c = y->color;
			z = y->ch[1];
			if (y->p == x) {
				z->p = y;
			}
			else {
				transplant(y, y->ch[1]);
				y->ch[1] = x->ch[1];
				y->ch[1]->p = y;
			}
			transplant(x, y);
			y->ch[0] = x->ch[0];
			y->ch[0]->p = y;
			y->color = x->color;
			update(y);
		}
		node *t = z->p;
		while (t != NIL) update(t), t = t->p;
		if (c == BLACK) {
			erase_fix(z);
		}
	}
};

const int MAX = 1 << 18;

red_black_tree<int> segs[MAX << 1];

void add(int x, int y, int val, int t = 1, int lb = 0, int ub = MAX) {
	if (x < lb || ub <= x) return;
	if (val > 0) segs[t].insert(y);
	else segs[t].erase(y);
	if (ub - lb == 1) return;
	int m = (lb + ub) >> 1;
	add(x, y, val, t << 1, lb, m);
	add(x, y, val, (t << 1) | 1, m, ub);
}

int find(int li, int lj, int ri, int rj, int t = 1, int lb = 0, int ub = MAX) {
	if (ri <= lb || ub <= li) return 0;
	if (li <= lb && ub <= ri) return segs[t].count_lower(rj) - segs[t].count_lower(lj);
	int m = (lb + ub) >> 1;
	return find(li, lj, ri, rj, t << 1, lb, m) + find(li, lj, ri, rj, (t << 1) | 1, m, ub);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> val(n);
	for (int i = 0; i < n; i++) {
		val[i] = i;
		add(i, i, 1);
	}
	ll res = 0;
	while (q--) {
		int l, r;
		cin >> l >> r; l--, r--;
		if (l == r) {
			printf("%lld\n", res);
			continue;
		}
		if (l > r) swap(l, r);
		int lv = val[l], rv = val[r];

		res += lv < rv ? 1 : -1;

		int cnt1 = find(l + 1, 0, r, lv);
		res -= cnt1;
		res += (r - l - 1) - cnt1;

		int cnt2 = find(l + 1, 0, r, rv);
		res += cnt2;
		res -= (r - l - 1) - cnt2;

		val[l] = rv, val[r] = lv;

		add(l, lv, -1);
		add(l, val[l], 1);
		add(r, rv, -1);
		add(r, val[r], 1);

		printf("%lld\n", res);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T>
class avl_tree {
	struct node {
		T val;
		node *ch[2];
		int dep, size;
		node(T v, node* l = nullptr, node* r = nullptr) : val(v), dep(1), size(1) {
			ch[0] = l; ch[1] = r;
		}
	};
	int depth(node *t) { return t == nullptr ? 0 : t->dep; }
	int count(node *t) { return t == nullptr ? 0 : t->size; }
	node *update(node *t) {
		t->dep = max(depth(t->ch[0]), depth(t->ch[1])) + 1;
		t->size = count(t->ch[0]) + count(t->ch[1]) + 1;
		return t;
	}
	node *rotate(node *t, int b) {
		node *s = t->ch[1 - b];
		t->ch[1 - b] = s->ch[b];
		s->ch[b] = t;
		t = update(t);
		s = update(s);
		return s;
	}
	node *fix(node *t) {
		if (t == nullptr) return t;
		if (depth(t->ch[0]) - depth(t->ch[1]) == 2) {
			if (depth(t->ch[0]->ch[1]) > depth(t->ch[0]->ch[0])) {
				t->ch[0] = rotate(t->ch[0], 0);
			}
			t = rotate(t, 1);
		}
		else if (depth(t->ch[0]) - depth(t->ch[1]) == -2) {
			if (depth(t->ch[1]->ch[0]) > depth(t->ch[1]->ch[1])) {
				t->ch[1] = rotate(t->ch[1], 1);
			}
			t = rotate(t, 0);
		}
		return t;
	}
	node *insert(node *t, int k, T v) {
		if (t == nullptr) return new node(v);
		int c = count(t->ch[0]), b = (k > c);
		t->ch[b] = insert(t->ch[b], k - (b ? (c + 1) : 0), v);
		update(t);
		return fix(t);
	}
	node *erase(node *t) {
		if (t == nullptr) return nullptr;
		if (t->ch[0] == nullptr && t->ch[1] == nullptr) {
			delete t;
			return nullptr;
		}
		if (t->ch[0] == nullptr || t->ch[1] == nullptr) {
			node *res = t->ch[t->ch[0] == nullptr];
			delete t;
			return res;
		}
		node *res = new node(find(t->ch[1], 0)->val, t->ch[0], erase(t->ch[1], 0));
		delete t;
		return fix(update(res));
	}
	node *erase(node *t, int k) {
		if (t == nullptr) return nullptr;
		int c = count(t->ch[0]);
		if (k < c) {
			t->ch[0] = erase(t->ch[0], k);
			t = update(t);
		}
		else if (k > c) {
			t->ch[1] = erase(t->ch[1], k - (c + 1));
			t = update(t);
		}
		else {
			t = erase(t);
		}
		return fix(t);
	}
	node *find(node *t, int k) {
		if (t == nullptr) return t;
		int c = count(t->ch[0]);
		return k < c ? find(t->ch[0], k) : k == c ? t : find(t->ch[1], k - (c + 1));
	}
	int cnt(node *t, T v) {
		if (t == nullptr) return 0;
		if (t->val < v) return count(t->ch[0]) + 1 + cnt(t->ch[1], v);
		if (t->val == v) return count(t->ch[0]);
		return cnt(t->ch[0], v);
	}
	node *root;
public:
	avl_tree() : root(nullptr) {}
	int size() {
		return count(root);
	}
	void insert(T val) {
		root = insert(root, cnt(root, val), val);
	}
	void erase(int k) {
		root = erase(root, k);
	}
	T find(int k) {
		return find(root, k)->val;
	}
	int count(T val) {
		return cnt(root, val);
	}
};

const int MAX = 1 << 18;

avl_tree<int> segs[MAX << 1];

void add(int x, int y, int val, int t = 1, int lb = 0, int ub = MAX) {
	if (x < lb || ub <= x) return;
	if (val > 0) segs[t].insert(y);
	else segs[t].erase(segs[t].count(y));
	if (ub - lb == 1) return;
	int m = (lb + ub) >> 1;
	add(x, y, val, t << 1, lb, m);
	add(x, y, val, (t << 1) | 1, m, ub);
}

int find(int li, int lj, int ri, int rj, int t = 1, int lb = 0, int ub = MAX) {
	if (ri <= lb || ub <= li) return 0;
	if (li <= lb && ub <= ri) return segs[t].count(rj) - segs[t].count(lj);
	int m = (lb + ub) >> 1;
	return find(li, lj, ri, rj, t << 1, lb, m) + find(li, lj, ri, rj, (t << 1) | 1, m, ub);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> val(n);
	for (int i = 0; i < n; i++) {
		val[i] = i;
		add(i, i, 1);
	}
	ll res = 0;
	while (q--) {
		int l, r;
		cin >> l >> r; l--, r--;
		if (l == r) {
			printf("%lld\n", res);
			continue;
		}
		if (l > r) swap(l, r);
		int lv = val[l], rv = val[r];

		res += lv < rv ? 1 : -1;

		int cnt1 = find(l + 1, 0, r, lv);
		res -= cnt1;
		res += (r - l - 1) - cnt1;

		int cnt2 = find(l + 1, 0, r, rv);
		res += cnt2;
		res -= (r - l - 1) - cnt2;

		val[l] = rv, val[r] = lv;

		add(l, lv, -1);
		add(l, val[l], 1);
		add(r, rv, -1);
		add(r, val[r], 1);

		printf("%lld\n", res);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX = 1 << 18;

struct seg_node1 {
	int pos, val, all;
	seg_node1 *lch, *rch;
	seg_node1(int p, int v = 0)
		: pos(p), val(v), all(v), lch(nullptr), rch(nullptr) {}
};

seg_node1* update(seg_node1 *t) {
	t->all = (t->lch ? t->lch->all : 0) + t->val + (t->rch ? t->rch->all : 0);
	return t;
}

seg_node1* add(seg_node1 *t, int p, int val, int lb = 0, int ub = MAX) {
	if (!t) return new seg_node1(p, val);
	if (t->pos == p) {
		t->val += val;
		return update(t);
	}
	int m = (lb + ub) >> 1;
	if (p < m) {
		if (t->pos > p) {
			swap(p, t->pos);
			swap(val, t->val);
		}
		t->lch = add(t->lch, p, val, lb, m);
	}
	else {
		if (t->pos < p) {
			swap(p, t->pos);
			swap(val, t->val);
		}
		t->rch = add(t->rch, p, val, m, ub);
	}
	return update(t);
}

int find(seg_node1 *t, int l, int r, int lb = 0, int ub = MAX) {
	if (!t || r <= lb || ub <= l) return 0;
	if (l <= lb && ub <= r) return t->all;
	int m = (lb + ub) >> 1;
	int val = l <= t->pos && t->pos < r ? t->val : 0;
	return find(t->lch, l, r, lb, m) + find(t->rch, l, r, m, ub) + val;
}

struct seg_node2 {
	seg_node1 *tree;
	seg_node2 *lch, *rch;
	seg_node2(seg_node1 *t = nullptr, seg_node2* l = nullptr, seg_node2* r = nullptr)
		: tree(t), lch(l), rch(r) {}
};

seg_node2* add(seg_node2 *t, int x, int y, int val, int lb = 0, int ub = MAX) {
	if (x < lb || ub <= x) return t;
	if (!t) t = new seg_node2;
	t->tree = add(t->tree, y, val);
	if (ub - lb == 1) return t;
	int m = (lb + ub) >> 1;
	t->lch = add(t->lch, x, y, val, lb, m);
	t->rch = add(t->rch, x, y, val, m, ub);
	return t;
}

int find(seg_node2 *t, int li, int lj, int ri, int rj, int lb = 0, int ub = MAX) {
	if (!t || ri <= lb || ub <= li) return 0;
	if (li <= lb && ub <= ri) return find(t->tree, lj, rj);
	int m = (lb + ub) >> 1;
	return find(t->lch, li, lj, ri, rj, lb, m) + find(t->rch, li, lj, ri, rj, m, ub);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> val(n);
	seg_node2 *tree = nullptr;
	for (int i = 0; i < n; i++) {
		val[i] = i;
		tree = add(tree, i, i, 1);
	}
	ll res = 0;
	while (q--) {
		int l, r;
		cin >> l >> r; l--, r--;
		if (l == r) {
			printf("%lld\n", res);
			continue;
		}
		if (l > r) swap(l, r);
		int lv = val[l], rv = val[r];

		res += lv < rv ? 1 : -1;

		int cnt1 = find(tree, l + 1, 0, r, lv);
		res -= cnt1;
		res += (r - l - 1) - cnt1;

		int cnt2 = find(tree, l + 1, 0, r, rv);
		res += cnt2;
		res -= (r - l - 1) - cnt2;

		val[l] = rv, val[r] = lv;

		tree = add(tree, l, lv, -1);
		tree = add(tree, l, val[l], 1);
		tree = add(tree, r, rv, -1);
		tree = add(tree, r, val[r], 1);

		printf("%lld\n", res);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template <typename T>
class red_black_tree {

	using COL = bool;
	static const COL RED = false, BLACK = true;

	struct node {
		COL color;
		int size;
		T val;
		node *p, *ch[2];
		node() : color(BLACK), size(0), val(), p(nullptr), ch{ nullptr, nullptr } {}
		node(COL c, T v, node *par, node *l, node *r) : color(c), size(1), val(v), p(par), ch{ l, r } {}
	} *NIL, *root;

	node* new_node(T val) {
		return new node(RED, val, NIL, NIL, NIL);
	}
	void update(node *x) {
		x->size = x->ch[0]->size + 1 + x->ch[1]->size;
	}
	void rotate(node *x, int b) {
		node *y = x->ch[1 - b];
		x->ch[1 - b] = y->ch[b];
		if (y->ch[b] != NIL) {
			y->ch[b]->p = x;
		}
		y->p = x->p;
		if (x->p == NIL) {
			root = y;
		}
		else {
			x->p->ch[x != x->p->ch[0]] = y;
		}
		y->ch[b] = x;
		x->p = y;
		update(x);
		update(y);
	}
	void insert_fix(node *x) {
		while (x->p->color == RED) {
			int b = (x->p != x->p->p->ch[0]);
			node *y = x->p->p->ch[1 - b];
			if (y->color == RED) {
				x->p->color = BLACK;
				y->color = BLACK;
				x->p->p->color = RED;
				x = x->p->p;
				continue;
			}
			if (x == x->p->ch[1 - b]) {
				x = x->p;
				rotate(x, b);
			}
			x->p->color = BLACK;
			x->p->p->color = RED;
			rotate(x->p->p, 1 - b);
		}
		root->color = BLACK;
	}
	void transplant(node *u, node *v) {
		if (u->p == NIL) {
			root = v;
		}
		else {
			u->p->ch[u != u->p->ch[0]] = v;
		}
		v->p = u->p;
	}
	void erase_fix(node *x) {
		while (x != root && x->color == BLACK) {
			int b = (x != x->p->ch[0]);
			node *w = x->p->ch[1 - b];
			if (w->color == RED) {
				w->color = BLACK;
				x->p->color = RED;
				rotate(x->p, b);
				w = x->p->ch[1 - b];
			}
			if (w->ch[b]->color == BLACK && w->ch[1 - b]->color == BLACK) {
				w->color = RED;
				x = x->p;
				continue;
			}
			if (w->ch[1 - b]->color == BLACK) {
				w->ch[b]->color = BLACK;
				w->color = RED;
				rotate(w, 1 - b);
				w = x->p->ch[1 - b];
			}
			w->color = x->p->color;
			x->p->color = BLACK;
			w->ch[1 - b]->color = BLACK;
			rotate(x->p, b);
			x = root;
		}
		x->color = BLACK;
	}
	node* find(node *x, T val) const {
		while (x != NIL) {
			if (val == x->val) return x;
			x = x->ch[val > x->val];
		}
		return NIL;
	}
	node* minimum(node *x) const {
		if (x == NIL) return NIL;
		while (x->ch[0] != NIL) {
			x = x->ch[0];
		}
		return x;
	}
	node* maximum(node *x) const {
		if (x == NIL) return NIL;
		while (x->ch[1] != NIL) {
			x = x->ch[1];
		}
		return x;
	}
public:
	red_black_tree() : NIL(new node()), root(NIL) {}
	int size() const {
		return root->size;
	}
	T minimum() const {
		return minimum(root)->val;
	}
	T maximum() const {
		return maximum(root)->val;
	}
	bool count(T val) const {
		return find(root, val) != NIL;
	}
	T operator[](int k) const {
		node *x = root;
		while (x->ch[0]->size != k) {
			if (k < x->ch[0]->size) {
				x = x->ch[0];
			}
			else {
				k -= x->ch[0]->size + 1;
				x = x->ch[1];
			}
		}
		return x->val;
	}
	void insert(T val) {
		node *x = root, *y = NIL;
		while (x != NIL) {
			if (val == x->val) return;
			y = x;
			x = x->ch[val > x->val];
		}
		node *v = new_node(val);
		v->p = y;
		if (y == NIL) {
			root = v;
		}
		else {
			y->ch[val > y->val] = v;
		}
		while (y != NIL) update(y), y = y->p;
		insert_fix(v);
	}
	void erase(T val) {
		node *x = find(root, val);
		if (x == NIL) return;
		node *y = x, *z;
		COL c = y->color;
		if (x->ch[0] == NIL) {
			z = x->ch[1];
			transplant(x, x->ch[1]);
		}
		else if (x->ch[1] == NIL) {
			z = x->ch[0];
			transplant(x, x->ch[0]);
		}
		else {
			y = minimum(x->ch[1]);
			c = y->color;
			z = y->ch[1];
			if (y->p == x) {
				z->p = y;
			}
			else {
				transplant(y, y->ch[1]);
				y->ch[1] = x->ch[1];
				y->ch[1]->p = y;
			}
			transplant(x, y);
			y->ch[0] = x->ch[0];
			y->ch[0]->p = y;
			y->color = x->color;
			update(y);
		}
		node *t = z->p;
		while (t != NIL) update(t), t = t->p;
		if (c == BLACK) {
			erase_fix(z);
		}
	}
};

const int MAX = 1 << 18;

red_black_tree<int> segs[MAX << 1];

void add(int x, int y, int val, int t = 1, int lb = 0, int ub = MAX) {
	if (x < lb || ub <= x) return;
	if (val > 0) segs[t].insert(y);
	else segs[t].erase(segs[t].count(y));
	if (ub - lb == 1) return;
	int m = (lb + ub) >> 1;
	add(x, y, val, t << 1, lb, m);
	add(x, y, val, (t << 1) | 1, m, ub);
}

int find(int li, int lj, int ri, int rj, int t = 1, int lb = 0, int ub = MAX) {
	if (ri <= lb || ub <= li) return 0;
	if (li <= lb && ub <= ri) return segs[t].count(rj) - segs[t].count(lj);
	int m = (lb + ub) >> 1;
	return find(li, lj, ri, rj, t << 1, lb, m) + find(li, lj, ri, rj, (t << 1) | 1, m, ub);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	vector<int> val(n);
	for (int i = 0; i < n; i++) {
		val[i] = i;
		add(i, i, 1);
	}
	ll res = 0;
	while (q--) {
		int l, r;
		cin >> l >> r; l--, r--;
		if (l == r) {
			printf("%lld\n", res);
			continue;
		}
		if (l > r) swap(l, r);
		int lv = val[l], rv = val[r];

		res += lv < rv ? 1 : -1;

		int cnt1 = find(l + 1, 0, r, lv);
		res -= cnt1;
		res += (r - l - 1) - cnt1;

		int cnt2 = find(l + 1, 0, r, rv);
		res += cnt2;
		res -= (r - l - 1) - cnt2;

		val[l] = rv, val[r] = lv;

		add(l, lv, -1);
		add(l, val[l], 1);
		add(r, rv, -1);
		add(r, val[r], 1);

		printf("%lld\n", res);
	}
	return 0;
}


#include <iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdio>
using namespace std;
char a[4][110];
int x,y;
int n;
int flag[4][110];
int ans=-1;
void dfs(int xx,int yy)
{
    if(xx<0||xx>2||yy<0||yy>n-1)
        return ;
    //cout<<xx<<" "<<yy<<endl;
    if(ans==0||ans==1)
        return ;
    if(flag[xx][yy]==1)
    {
        return ;
    }
    if(yy==n-1)
    {
        ans=1;
        return ;
    }
    if(flag[xx][yy+1]==0)
    {
        int p=0;
        if(flag[xx][yy+2]==0&&flag[xx][yy+3]==0)
        {
            p=1;
            dfs(xx,yy+3);
        }
        if(flag[xx-1][yy+1]==0&&flag[xx-1][yy+2]==0&&flag[xx-1][yy+3]==0)
        {
            p=1;
            dfs(xx-1,yy+3);

        }
        if(flag[xx+1][yy+1]==0&&flag[xx+1][yy+2]==0&&flag[xx+1][yy+3]==0)
        {
            p=1;
            dfs(xx+1,yy+3);

        }
        if(p==0)
        {
            ans=0;
            return ;
        }
    }
    else
    {
        ans=0;
        return ;
    }
    return ;
}
int main()
{
    int t,k,i,j;
    cin>>t;
    while(t--)
    {
        memset(flag,0,sizeof(flag));
        cin>>n>>k;
        ans=-1;
        for(i=0; i<=2; i++)
        {
            for(j=0; j<n; j++)
            {
                cin>>a[i][j];
                if(a[i][j]=='s')
                {
                    x=i;
                    y=j;
                }
                else if(a[i][j]!='.')
                    flag[i][j]=1;
            }
            getchar();
        }
        dfs(x,y);
        if(ans==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][205];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n) return true;
	y ++ ;

	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 2)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 2)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 5 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(dfs(x , y , 1)) cout << "YES" << '\n';
			else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e2 + 10;
int vis[N][N] , mat[N][N] , n , k;
char G[N][N] ;
struct node{
	int x , y;
	node(){}
	node(int a , int b){x = a , y = b;}
};
bool bfs(int sx , int sy)
{
	vis[sx][sy] = 1;
	queue<node>que;
	que.push(node(sx , sy));
	while(!que.empty())
	{
		node temp = que.front();
		que.pop();
		if(temp.y >= n) return true;
		if(mat[temp.x][temp.y + 1]) continue ;
		for(int i = -1 ; i <= 1 ; i ++)
		{
			int x = temp.x;
			int y = temp.y + 1;
			x += i;
			if(x < 1 || x > 3) continue ;
			if(mat[x][y] || mat[x][y + 2] || mat[x][y + 1]) continue ;
			if(vis[x][y + 2]) continue ;
			vis[x][y + 2] = 1;
			que.push(node(x , y + 2));
		}
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while(t --)
	{
		memset(mat , 0 , sizeof(mat));
		cin >> n >> k;
		int sx , sy;
		for(int i = 1 ; i <= 3 ; i ++)
		{
			for(int j = 1 ; j <= n ; j ++)
			{
				cin >> G[i][j];
				if(G[i][j] == 's') sx = i , sy = j;
				else if(G[i][j] != '.') mat[i][j] = 1;
			}
		}
		if(bfs(sx , sy)) cout << "YES" << '\n';
		else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][205];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n && t >= n) return true;
	if(t & 1) y ++ ;
	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 1)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 1)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 5 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(mat[x][y][1] || !dfs(x , y , 1)) cout << "NO" << '\n';
			else cout << "YES" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 3;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][103];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n && t >= n) return true;
	if(t & 1) y ++ ;
	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 1)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 1)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 3 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(mat[x][y][1] || !dfs(x , y , 1)) cout << "NO" << '\n';
			else cout << "YES" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e2 + 10;
int vis[N][N] , mat[N][N] , n , k;
char G[N][N] ;
struct node{
	int x , y;
	node(){}
	node(int a , int b){x = a , y = b;}
};
bool bfs(int sx , int sy)
{
	vis[sx][sy] = 1;
	queue<node>que;
	que.push(node(sx , sy));
	while(!que.empty())
	{
		node temp = que.front();
		que.pop();
		if(temp.y >= n) return true;
		if(mat[temp.x][temp.y + 1]) continue ;
		for(int i = -1 ; i <= 1 ; i ++)
		{
			int x = temp.x;
			int y = temp.y + 1;
			x += i;
			if(x < 1 || x > 3) continue ;
			if(mat[x][y] || mat[x][y + 2] || mat[x][y + 1]) continue ;
			if(vis[x][y + 2]) continue ;
			vis[x][y + 2] = 1;
			que.push(node(x , y + 2));
		}
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while(t --)
	{
		memset(mat , 0 , sizeof(mat));
		memset(vis , 0 , sizeof(vis));
		cin >> n >> k;
		int sx , sy;
		for(int i = 1 ; i <= 3 ; i ++)
		{
			for(int j = 1 ; j <= n ; j ++)
			{
				cin >> G[i][j];
				if(G[i][j] == 's') sx = i , sy = j;
				else if(G[i][j] != '.') mat[i][j] = 1;
			}
		}
		if(bfs(sx , sy)) cout << "YES" << '\n';
		else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 2e2 + 10;
int vis[N][N] , mat[N][N] , n , k;
char G[N][N] ;
int nex[3] = {-1 , 0 , 1};
struct node{
	int x , y , t;
	node(){}
	node(int a , int b){x = a , y = b;}
};
bool bfs(int sx , int sy)
{
	vis[sx][sy] = 1;
	queue<node>que;
	que.push(node(sx , sy));
	while(!que.empty())
	{
		node temp = que.front();
		que.pop();
		if(temp.y >= n) return true;
		if(mat[temp.x][temp.y + 1]) continue ;
		for(int i = -1 ; i <= 1 ; i ++)
		{
			int x = temp.x;
			int y = temp.y + 1;
			x += i;
			if(x < 1 || x > 3) continue ;
			if(mat[x][y] || mat[x][y + 2] || mat[x][y + 1]) continue ;
			if(vis[x][y + 2]) continue ;
			vis[x][y + 2] = 1;
			que.push(node(x , y + 2));
		}
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while(t --)
	{
		memset(mat , 0 , sizeof(mat));
		cin >> n >> k;
		int sx , sy;
		for(int i = 1 ; i <= 3 ; i ++)
		{
			for(int j = 1 ; j <= n ; j ++)
			{
				cin >> G[i][j];
				if(G[i][j] == 's') sx = i , sy = j;
				else if(G[i][j] != '.') mat[i][j] = 1;
			}
		}
		if(bfs(sx , sy)) cout << "YES" << '\n';
		else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][205];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n && t >= n) return true;
	y ++ ;

	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 2)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 2)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 5 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(dfs(x , y , 1)) cout << "YES" << '\n';
			else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][N];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n) return true;
	y ++ ;

	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 2)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 2)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 5 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(dfs(x , y , 1)) cout << "YES" << '\n';
			else cout << "NO" << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2 + 3;
char G[N][N];
vector<pair<int , int>>car[10];
int mat[N][N][103];
int n ;
bool dfs(int x , int y , int t)
{
	if(y > n && t >= n) return true;
	if(t & 1) y ++ ;
	if(mat[x][y][t]) return false;
		if(x + 1 <= 3) if(!mat[x + 1][y][t] && !mat[x + 1][y][t + 1])  if(dfs(x + 1 , y , t + 2)) return true;
		if(x - 1 >= 1) if(!mat[x - 1][y][t] && !mat[x - 1][y][t + 1])  if(dfs(x - 1 , y , t + 2)) return true;
		if(!mat[x][y][t] && !mat[x][y][t + 1]) if(dfs(x , y , t + 1)) return true;

	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0) , cout.tie(0);
	int T;
	cin >> T;
	while(T --)
	{
		for(int i = 1 ; i <= 3 ; i ++) car[i].clear();
		memset(mat , 0 , sizeof(mat));
		int k , x , y;
		cin >> n >> k;
		for(int i = 1 ; i <= 3 ; i ++)
			for(int j = 1 ; j <= n ; j ++)
				cin >> G[i][j];
		for(int i = 1 ; i <= 3 ; i ++)
			{
				for(int j = 1 ; j <= n ; j ++)
				if(G[i][j] != '.' && G[i][j] != 's')
				{
					int st = j;
					while(G[i][j] != '.' && j <= n) j ++ ;
					int ed = j - 1;
					car[i].push_back(make_pair(st , ed));
					for(int h = st ; h <= ed ; h ++) mat[i][h][1] = 1;
					j -- ;
				}
				else if(G[i][j] == 's') x = i , y = j;
			}
			for(int t = 1 ; t <= n ; t ++)
			{
				if(t & 1) continue ;
				for(int i = 1 ; i <= 3 ; i ++)
					for(int j = 0 ; j < (int)car[i].size() ; j ++)
					{
						car[i][j].first -= 2 , car[i][j].second -= 2;
				//		cout << car[i][j].first << " " << car[i][j].second << '\n';
						for(int h = max(0 , car[i][j].first) ; h <= car[i][j].second ; h ++)
						mat[i][h][t] = mat[i][h][t + 1] = 1;
					}
			}
		/*	for(int t = 1 ; t <= n ; t ++)
			{
				for(int i = 1 ; i <= 3 ; i ++)
				{
					for(int j = 1 ; j <= n ; j ++)
						cout << mat[i][j][t] << " ";
					cout << '\n';
				}
				cout << '\n';
			}*/
			if(mat[x][y][1] || !dfs(x , y , 1)) cout << "NO" << '\n';
			else cout << "YES" << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
char a[109][109];
int mv[3][2]={{1,0},{0,0},{-1,0}},n,m,vis[109][109];
struct node{
	int x,y,steps;
};
queue<node>q;
bool zimu(char s){
	if(s>='A'&&s<='Z')	return true;
	else	return false;
}
int bfs()
{
	while(!q.empty())
	{
		node t=q.front();q.pop();
		if(t.y==n)	return 1;
		t.y++;//������һ��
		if(zimu(a[t.x][t.y]))	continue;
		if(t.y==n)	return 1;
		for(int i=0;i<3;i++)
		{
			node o;
			o.x=t.x+mv[i][0],o.y=t.y+mv[i][1];
			if(o.x<1||o.x>3||o.y>n||vis[o.x][o.y])	continue;
			vis[o.x][o.y]=1;
			if(zimu(a[o.x][o.y]))	continue;
			o.y++;
			if(o.y==n)	return 1;
			if(zimu(a[o.x][o.y]))	continue;
			o.y++;
			if(o.y==n)	return 1;
			if(zimu(a[o.x][o.y]))	continue;
			q.push(o);
		}
	}
	return 0;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		cin>>n>>m;
		for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='s')	q.push((node){i,j,0}),vis[i][j]=1;
		}
		int ok=bfs();
		if(ok)	cout<<"YES";
		else	cout<<"NO";
		cout<<endl;
		while(!q.empty())	q.pop();
	}
}


#include <bits/stdc++.h>
using namespace std;
char a[109][109];
int mv[3][2]={{1,0},{0,0},{-1,0}},n,m,vis[109][109];
struct node{
	int x,y,steps;
};
queue<node>q;
bool zimu(char s){
	if(s>='A'&&s<='Z')	return true;
	else	return false;
}
int bfs()
{
	while(!q.empty())
	{
		node t=q.front();q.pop();
		if(t.y==n)	return 1;
		t.y++;//������һ��
		if(zimu(a[t.x][t.y]))	continue;
		if(t.y==n)	return 1;
		for(int i=0;i<3;i++)
		{
			node o;
			o.x=t.x+mv[i][0],o.y=t.y+mv[i][1];
			if(o.x<1||o.x>3||o.y>n||vis[o.x][o.y])	continue;
			vis[o.x][o.y]=1;
			if(zimu(a[o.x][o.y]))	continue;
			o.y++;
			if(o.y==n)	return 1;
			if(zimu(a[o.x][o.y]))	continue;
			o.y++;
			if(o.y==n)	return 1;
			if(zimu(a[o.x][o.y]))	continue;
			q.push(o);
		}
	}
	return 0;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		memset(vis,0,sizeof(vis));
		memset(a,0,sizeof(a));
		cin>>n>>m;
		for(int i=1;i<=3;i++)
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='s')	q.push((node){i,j,0}),vis[i][j]=1;
		}
		int ok=bfs();
		if(ok)	cout<<"YES";
		else	cout<<"NO";
		cout<<endl;
		while(!q.empty())	q.pop();
	}
}


#include "bits/stdc++.h"
using namespace std;

//Utility functions
#define pb push_back
#define sz size()
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()

//Constants
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define MOD 1000000007 //998244353

//Printing
#define coutRV(a,L,R) FE(i,L,R) cout<<a[i]<<" \n"[i==R] ;
#define coutV(a) coutRV(a,0,a.size()-1)

//For loops
#define FE(i,a,b)  for(int i=a; i<=b; i++)
#define FRE(i,b,a) for(int i=b; i>=a; i--)
#define FA(x,cont) for(auto& x : cont)

//For debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Definitions
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vvi vector<vector<int> > //For UnGraph
#define vvpi vector<vector<pii> > //For DirGraph
#define vviwv(vecname, N, M, value) vector<vector<int> > vecname(N, vector<int> (M, value)) //For DP
#define vvlwv(vecname, N, M, value) vector<vector<ll> > vecname(N, vector<ll> (M, value)) //For DP
#define pii pair<int,int>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

//Input
#define cini(i) int i; cin>>i;
#define cini2(i,j) int i,j; cin>>i>>j;
#define cini3(i,j,k) int i,j,k; cin>>i>>j>>k;
#define cini4(i,j,k,l) int i,j,k,l; cin>>i>>j>>k>>l;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cins(s) string s; cin>>s;
#define cinv(a, n) vi a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvll(a, n) vll a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvd(a, n) vd a(n+1); FE(i,1,n) { cin>>a[i]; }

int mark = 0;
int J = 0;
vviwv(visited,4,110,0);

int check(int x, int y, vector<pair<pii,int > >& train)
{
    if(x<1 || x>3)
        return 0;
    FE(i,1,train.sz-1)
    {
        if(train[i].se == x)
        {
            if(y>=train[i].fi.fi && y<=train[i].fi.se){
                return 0;
            }
        }
    }
    debug(x, y);
    return 1;
}

void dfs(int X, int Y, vector<pair<pii,int > >& train, int n)
{
    J++;
    if(X<1 || X>3)
        return;
    if(Y >= n+1)
    {
        if(!mark)
            cout<<"YES"<<endl;
        mark = 1 ;
        return ;
    }
    if(visited[X][Y])
        return;

    visited[X][Y] = 1;
    int chk = check(X, Y, train);
    if(!chk)
        return;
    /*
    // move trains now
    FE(i,1,train.sz-1)
    {
        train[i].fi.fi -= 2;
        train[i].fi.se -= 2;
    }

    chk = check(x, y, train);
    if(!chk){
        return ;
    }*/

    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+1,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    return;
}

void solve()
{
    cini2(n,k);
    vector<pair<pii,int > > train(k+1);

    int z = 1, X, Y;

    FE(i,1,3)
    {
        cins(s);
        s = "#" + s;
        for (int j = 1; j <= n; )
        {
            if(s[j]=='s')
            {
                X = i;
                Y = j;
                j++;
            }
            else if(s[j]!='.')
            {
                char c = s[j];
                int start = j;

                while(s[j]==c)
                    j++;

                int end = j-1;
                train[z] = {{start, end}, i};
                z++;
            }
            else
                j++;
        }
    }
    //debug(train);
    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+1,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    if(!mark)
        cout<<"NO"<<endl;
    return;
}

int main()
{
    fastIO;
    cini(t);

    while(t--){
        mark = 0;
        solve();
    }

    return 0;
}


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

//Utility functions
#define pb push_back
#define sz size()
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()

//Constants
#define EPS 1e-6
#define INF 0x3f3f3f3f

//Printing
#define coutRV(a,L,R) FE(i,L,R) cout<<a[i]<<" \n"[i==R] ;
#define coutV(a) coutRV(a,1,a.size()-1)

//For loops
#define FE(i,a,b)  for(int i=a; i<=b; i++)
#define FRE(i,b,a) for(int i=b; i>=a; i--)
#define FA(x,cont) for(auto& x : cont)

//For debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Definitions
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vvi vector<vector<int> > //For UnGraph
#define vvpi vector<vector<pii> > //For DirGraph
#define vviwv(vecname, N, M, value) vector<vector<int> > vecname(N, vector<int> (M, value)) //For DP
#define vvlwv(vecname, N, M, value) vector<vector<ll> > vecname(N, vector<ll> (M, value)) //For DP
#define pii pair<int,int>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//Input
#define cini(i) int i; cin>>i;
#define cini2(i,j) int i,j; cin>>i>>j;
#define cini3(i,j,k) int i,j,k; cin>>i>>j>>k;
#define cini4(i,j,k,l) int i,j,k,l; cin>>i>>j>>k>>l;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cins(s) string s; cin>>s; s = "#"+s;
#define cinv(a, n) vi a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvd(a, n) vd a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvll(a, n) vll a(n+1); FE(i,1,n) { cin>>a[i]; }

int mark = 0, n;
vviwv(visited,4,110,0);

int check(int x, int y, vector<string>& board)
{
    if(x<=0 || x>=4)
        return 0;

    if(y>n)
        return 1;

    if(board[x][y]>='A' && board[x][y]<='Z')
        return 0;

    return 1;
}

void dfs(int X, int Y, vector<string>& board)
{
    if(Y >= n+1)
    {
        if(!mark)
            cout<<"YES"<<endl;
        mark = 1 ;
        return ;
    }
    if(visited[X][Y])
        return;

    visited[X][Y] = 1;
    if( check(X,Y+1,board) && check(X,Y+2,board) && check(X,Y+3,board) )
        dfs(X, Y+3, board);

    if( check(X,Y+1,board) && check(X-1,Y+1,board) && check(X-1,Y+2,board) && check(X-1,Y+3,board) )
        dfs(X-1, Y+3, board);

    if( check(X,Y+1,board) && check(X+1,Y+1,board) && check(X+1,Y+2,board) && check(X+1,Y+3,board) )
        dfs(X+1, Y+3, board);

    return;
}

void solve()
{
    int k;
    cin>>n>>k;

    vector<string> board(4);
    int X,Y;
    FE(i,1,3)
    {
        cins(s);
        board[i] = s;
        for (int j = 1; j <= n; j++)
        {
            if(s[j]=='s')
            {
                X = i;
                Y = j;
                break;
            }
        }
    }
    dfs(X, Y, board);

    if(!mark)
        cout<<"NO"<<endl;
    return;
}

int main()
{
    fastIO;
    cini(t);

    while(t--)
    {
        mark = 0;
        FE(i,1,3)
            FE(j,1,100)
                visited[i][j] = 0;

        solve();
    }

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

//Utility functions
#define pb push_back
#define sz size()
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()

//Constants
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define MOD 1000000007 //998244353

//Printing
#define coutRV(a,L,R) FE(i,L,R) cout<<a[i]<<" \n"[i==R] ;
#define coutV(a) coutRV(a,0,a.size()-1)

//For loops
#define FE(i,a,b)  for(int i=a; i<=b; i++)
#define FRE(i,b,a) for(int i=b; i>=a; i--)
#define FA(x,cont) for(auto& x : cont)

//For debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Definitions
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vvi vector<vector<int> > //For UnGraph
#define vvpi vector<vector<pii> > //For DirGraph
#define vviwv(vecname, N, M, value) vector<vector<int> > vecname(N, vector<int> (M, value)) //For DP
#define vvlwv(vecname, N, M, value) vector<vector<ll> > vecname(N, vector<ll> (M, value)) //For DP
#define pii pair<int,int>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

//Input
#define cini(i) int i; cin>>i;
#define cini2(i,j) int i,j; cin>>i>>j;
#define cini3(i,j,k) int i,j,k; cin>>i>>j>>k;
#define cini4(i,j,k,l) int i,j,k,l; cin>>i>>j>>k>>l;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cins(s) string s; cin>>s;
#define cinv(a, n) vi a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvll(a, n) vll a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvd(a, n) vd a(n+1); FE(i,1,n) { cin>>a[i]; }

int mark = 0;
int J = 0;
vviwv(visited,4,110,0);

int check(int x, int y, vector<pair<pii,int > >& train)
{
    if(x<1 || x>3)
        return 0;
    int n = train.sz;
    FE(i,1,n-1)
    {
        if(train[i].se == x)
        {
            if(y>=train[i].fi.fi && y<=train[i].fi.se){
                return 0;
            }
        }
    }
    debug(x, y);
    return 1;
}

void dfs(int X, int Y, vector<pair<pii,int > >& train, int n)
{
    //J++;
    //if(X<1 || X>3)
    //    return;
    if(Y >= n+1)
    {
        if(!mark)
            cout<<"YES"<<endl;
        mark = 1 ;
        return ;
    }
    if(visited[X][Y])
        return;

    visited[X][Y] = 1;
    //int chk = check(X, Y, train);
    //if(!chk)
    //    return;
    /*
    // move trains now
    FE(i,1,train.sz-1)
    {
        train[i].fi.fi -= 2;
        train[i].fi.se -= 2;
    }

    chk = check(x, y, train);
    if(!chk){
        return ;
    }*/

    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+3,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    return;
}

void solve()
{
    cini2(n,k);
    vector<pair<pii,int > > train(k+1);

    int z = 1, X, Y;

    FE(i,1,3)
    {
        cins(s);
        s = "#" + s;
        for (int j = 1; j <= n; )
        {
            if(s[j]=='s')
            {
                X = i;
                Y = j;
                j++;
            }
            else if(s[j]!='.')
            {
                char c = s[j];
                int start = j;

                while(s[j]==c)
                    j++;

                int end = j-1;
                train[z] = {{start, end}, i};
                z++;
            }
            else
                j++;
        }
    }
    debug(train);
    dfs(X, Y, train, n);

    //if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+3,train) )
    //    dfs(X, Y+3, train, n);
    //
    //if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
    //    dfs(X-1, Y+3, train, n);
    //
    //if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
    //    dfs(X+1, Y+3, train, n);

    if(!mark)
        cout<<"NO"<<endl;
    return;
}

int main()
{
    fastIO;
    cini(t);

    while(t--){
        mark = 0;
        solve();
    }

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

//Utility functions
#define pb push_back
#define sz size()
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()

//Constants
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define MOD 1000000007 //998244353

//Printing
#define coutRV(a,L,R) FE(i,L,R) cout<<a[i]<<" \n"[i==R] ;
#define coutV(a) coutRV(a,0,a.size()-1)

//For loops
#define FE(i,a,b)  for(int i=a; i<=b; i++)
#define FRE(i,b,a) for(int i=b; i>=a; i--)
#define FA(x,cont) for(auto& x : cont)

//For debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Definitions
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vvi vector<vector<int> > //For UnGraph
#define vvpi vector<vector<pii> > //For DirGraph
#define vviwv(vecname, N, M, value) vector<vector<int> > vecname(N, vector<int> (M, value)) //For DP
#define vvlwv(vecname, N, M, value) vector<vector<ll> > vecname(N, vector<ll> (M, value)) //For DP
#define pii pair<int,int>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

//Input
#define cini(i) int i; cin>>i;
#define cini2(i,j) int i,j; cin>>i>>j;
#define cini3(i,j,k) int i,j,k; cin>>i>>j>>k;
#define cini4(i,j,k,l) int i,j,k,l; cin>>i>>j>>k>>l;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cins(s) string s; cin>>s;
#define cinv(a, n) vi a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvll(a, n) vll a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvd(a, n) vd a(n+1); FE(i,1,n) { cin>>a[i]; }

int mark = 0;
int J = 0;
vviwv(visited,4,110,0);

int check(int x, int y, vector<pair<pii,int > >& train)
{
    if(x<1 || x>3)
        return 0;
    FE(i,1,train.sz-1)
    {
        if(train[i].se == x)
        {
            if(y>=train[i].fi.fi && y<=train[i].fi.se){
                return 0;
            }
        }
    }
    debug(x, y);
    return 1;
}

void dfs(int X, int Y, vector<pair<pii,int > >& train, int n)
{
    J++;
    if(X<1 || X>3)
        return;
    if(Y >= n+1)
    {
        if(!mark)
            cout<<"YES"<<endl;
        mark = 1 ;
        return ;
    }
    if(visited[X][Y])
        return;

    visited[X][Y] = 1;
    //int chk = check(X, Y, train);
    //if(!chk)
    //    return;
    /*
    // move trains now
    FE(i,1,train.sz-1)
    {
        train[i].fi.fi -= 2;
        train[i].fi.se -= 2;
    }

    chk = check(x, y, train);
    if(!chk){
        return ;
    }*/

    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+1,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    return;
}

void solve()
{
    cini2(n,k);
    vector<pair<pii,int > > train(k+1);

    int z = 1, X, Y;

    FE(i,1,3)
    {
        cins(s);
        s = "#" + s;
        for (int j = 1; j <= n; )
        {
            if(s[j]=='s')
            {
                X = i;
                Y = j;
                j++;
            }
            else if(s[j]!='.')
            {
                char c = s[j];
                int start = j;

                while(s[j]==c)
                    j++;

                int end = j-1;
                train[z] = {{start, end}, i};
                z++;
            }
            else
                j++;
        }
    }
    //debug(train);
    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+1,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    if(!mark)
        cout<<"NO"<<endl;
    return;
}

int main()
{
    fastIO;
    cini(t);

    while(t--){
        mark = 0;
        solve();
    }

    return 0;
}


#include "bits/stdc++.h"
using namespace std;

//Utility functions
#define pb push_back
#define sz size()
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()

//Constants
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define MOD 1000000007 //998244353

//Printing
#define coutRV(a,L,R) FE(i,L,R) cout<<a[i]<<" \n"[i==R] ;
#define coutV(a) coutRV(a,0,a.size()-1)

//For loops
#define FE(i,a,b)  for(int i=a; i<=b; i++)
#define FRE(i,b,a) for(int i=b; i>=a; i--)
#define FA(x,cont) for(auto& x : cont)

//For debug
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

//Definitions
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vvi vector<vector<int> > //For UnGraph
#define vvpi vector<vector<pii> > //For DirGraph
#define vviwv(vecname, N, M, value) vector<vector<int> > vecname(N, vector<int> (M, value)) //For DP
#define vvlwv(vecname, N, M, value) vector<vector<ll> > vecname(N, vector<ll> (M, value)) //For DP
#define pii pair<int,int>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

//Input
#define cini(i) int i; cin>>i;
#define cini2(i,j) int i,j; cin>>i>>j;
#define cini3(i,j,k) int i,j,k; cin>>i>>j>>k;
#define cini4(i,j,k,l) int i,j,k,l; cin>>i>>j>>k>>l;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cins(s) string s; cin>>s;
#define cinv(a, n) vi a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvll(a, n) vll a(n+1); FE(i,1,n) { cin>>a[i]; }
#define cinvd(a, n) vd a(n+1); FE(i,1,n) { cin>>a[i]; }

int mark = 0;
int J = 0;
vviwv(visited,4,110,0);

int check(int x, int y, vector<pair<pii,int > >& train)
{
    if(x<1 || x>3)
        return 0;
    int n = train.sz;
    FE(i,1,n-1)
    {
        if(train[i].se == x)
        {
            if(y>=train[i].fi.fi && y<=train[i].fi.se){
                return 0;
            }
        }
    }
    debug(x, y);
    return 1;
}

void dfs(int X, int Y, vector<pair<pii,int > >& train, int n)
{
    //J++;
    //if(X<1 || X>3)
    //    return;
    if(Y >= n+1)
    {
        if(!mark)
            cout<<"YES"<<endl;
        mark = 1 ;
        return ;
    }
    if(visited[X][Y])
        return;

    visited[X][Y] = 1;
    //int chk = check(X, Y, train);
    //if(!chk)
    //    return;
    /*
    // move trains now
    FE(i,1,train.sz-1)
    {
        train[i].fi.fi -= 2;
        train[i].fi.se -= 2;
    }

    chk = check(x, y, train);
    if(!chk){
        return ;
    }*/

    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+3,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    return;
}

void solve()
{
    cini2(n,k);
    vector<pair<pii,int > > train(k+1);

    int z = 1, X, Y;

    FE(i,1,3)
    {
        cins(s);
        s = "#" + s;
        for (int j = 1; j <= n; )
        {
            if(s[j]=='s')
            {
                X = i;
                Y = j;
                j++;
            }
            else if(s[j]!='.')
            {
                char c = s[j];
                int start = j;

                while(s[j]==c)
                    j++;

                int end = j-1;
                train[z] = {{start, end}, i};
                z++;
            }
            else
                j++;
        }
    }
    debug(train);
    if( check(X,Y+1,train) && check(X,Y+2,train) && check(X,Y+3,train) )
        dfs(X, Y+3, train, n);

    if( check(X,Y+1,train) && check(X-1,Y+1,train) && check(X-1,Y+2,train) && check(X-1,Y+3,train) )
        dfs(X-1, Y+3, train, n);

    if( check(X,Y+1,train) && check(X+1,Y+1,train) && check(X+1,Y+2,train) && check(X+1,Y+3,train) )
        dfs(X+1, Y+3, train, n);

    if(!mark)
        cout<<"NO"<<endl;
    return;
}

int main()
{
    fastIO;
    cini(t);

    while(t--){
        mark = 0;
        solve();
    }

    return 0;
}


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

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;
typedef vector<vector<ii>> vvii;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EPS 1e-9
#define INF 1e5
#define MOD 1000000007
#define PI 3.14159265358979323846

int findStart(vvc &arr)
{
	for(int i=0;i<3;i++)
		if(arr[i][0]=='s')
			return i;
	return -1;
}
bool isChar(char a)
{
	if(a>='A'&&a<='Z')
		return 1;
	return 0;
}
int solve(int sx,int sy,map<ii,int> &state,vvc &arr)
{
	//cout<<sx<<" "<<sy<<endl;
	if(state[ii(sx,sy)]!=-1)
		return state[ii(sx,sy)];
	for(int i=0;i<3;i++)
	{
		bool flg=0;
		int u =(sx+i)%3,v = sy+3;
		if(isChar(arr[sx][sy+1]))
			flg=1;

		for(int z=sy+1;z<=v;z++)
			if(isChar(arr[u][z]))
				flg=1;

		if((!flg)&&solve(u,v,state,arr))
			return (state[ii(u,v)]=1);
	}
	return ( state[ii(sx,sy)]=0 );
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t,n,k;
	cin>>t;
	while(t--){
		map<ii,int> state;
		cin>>n>>k;
		vvc arr(3,vector<char>(n));
		for(int j=0;j<3;j++)
			for(int i=0;i<n;i++)
				cin>>arr[j][i],state[ii(j,i)]=-1;
		for(int j=0;j<3;j++)
			for(int i=n-1;i<n+2;i++)
				state[ii(j,i)]=1;
		int sx = findStart(arr),sy = 0;
		solve(sx,sy,state,arr);

		if(state[ii(sx,sy)])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
}


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

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;
typedef vector<vector<ii>> vvii;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EPS 1e-9
#define INF 1e5
#define MOD 1000000007
#define PI 3.14159265358979323846

int findStart(vvc &arr)
{
	for(int i=0;i<3;i++)
		if(arr[i][0]=='s')
			return i;
	return -1;
}
bool isChar(char a)
{
	if(a>='A'&&a<='Z')
		return 1;
	return 0;
}
int solve(int sx,int sy,map<ii,int> &state,vvc &arr)
{
	//cout<<sx<<" "<<sy<<endl;
	if(state[ii(sx,sy)]!=-1)
		return state[ii(sx,sy)];
	for(int i=0;i<3;i++)
	{
		bool flg=0;
		int u =(sx+i)%3,v = sy+3;
		if(isChar(arr[sx][sy+1]))
			flg=1;

		for(int z=sy+1;z<=v;z++)
			if(isChar(arr[u][z]))
				flg=1;

		if((!flg)&&solve(u,v,state,arr))
			return (state[ii(sx,sy)]=1);
	}
	return ( state[ii(sx,sy)]=0 );
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t,n,k;
	cin>>t;
	while(t--){
		map<ii,int> state;
		cin>>n>>k;
		vvc arr(3,vector<char>(n));
		for(int j=0;j<3;j++)
			for(int i=0;i<n;i++)
				cin>>arr[j][i],state[ii(j,i)]=-1;
		for(int j=0;j<3;j++)
			for(int i=n-1;i<n+2;i++)
				state[ii(j,i)]=1;
		int sx = findStart(arr),sy = 0;
		solve(sx,sy,state,arr);

		if(state[ii(sx,sy)])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
}


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

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;
typedef vector<vector<ii>> vvii;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EPS 1e-9
#define INF 1e5
#define MOD 1000000007
#define PI 3.14159265358979323846

int findStart(vvc &arr)
{
	for(int i=0;i<3;i++)
		if(arr[i][0]=='s')
			return i;
	return -1;
}
bool isChar(char a)
{
	if(a>='A'&&a<='Z')
		return 1;
	return 0;
}
int solve(int sx,int sy,map<ii,int> &state,vvc &arr)
{
	//cout<<sx<<" "<<sy<<endl;
	if(state[ii(sx,sy)]!=-1)
		return state[ii(sx,sy)];
	for(int i=0;i<3;i++)
	{
		bool flg=0;
		int u =(sx+i)%3,v = sy+3;
		if(isChar(arr[sx][sy+1]))
			flg=1;

		for(int z=sy+1;z<=v;z++)
			if(isChar(arr[u][z]))
				flg=1;

		if((!flg)&&solve(u,v,state,arr))
			return (state[ii(sx,sy)]=1);
	}
	return ( state[ii(sx,sy)]=0 );
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t,n,k;
	cin>>t;
	while(t--){
		map<ii,int> state;
		cin>>n>>k;
		vvc arr(3,vector<char>(n+2));
		for(int j=0;j<3;j++)
			for(int i=0;i<n;i++)
				cin>>arr[j][i],state[ii(j,i)]=-1;

		for(int j=0;j<3;j++){
			for(int i=n-1;i<n+2;i++)
				state[ii(j,i)]=1;
			for(int i=n;i<n+2;i++)
				arr[j][i]='.';
		}
		int sx = findStart(arr),sy = 0;
		solve(sx,sy,state,arr);

		if(state[ii(sx,sy)])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
}


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

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef long double ld;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef pair<ll,ll> pll;
typedef vector<vector<ii>> vvii;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EPS 1e-9
#define INF 1e5
#define MOD 1000000007
#define PI 3.14159265358979323846

int findStart(vvc &arr)
{
	for(int i=0;i<3;i++)
		if(arr[i][0]=='s')
			return i;
	return -1;
}
bool isChar(char a)
{
	if(a>='A'&&a<='Z')
		return 1;
	return 0;
}
int solve(int sx,int sy,map<ii,int> &state,vvc &arr)
{
	//cout<<sx<<" "<<sy<<endl;
	if(state[ii(sx,sy)]!=-1)
		return state[ii(sx,sy)];
	int dir[3]={1,0,-1};
	for(int i=0;i<3;i++)
	{
		bool flg=0;
		int u =sx+dir[i],v = sy+3;
		if(u<0|| u>2)
			continue;
		if(isChar(arr[sx][sy+1]))
			flg=1;

		for(int z=sy+1;z<=v;z++)
			if(isChar(arr[u][z]))
				flg=1;

		if((!flg)&&solve(u,v,state,arr))
			return (state[ii(sx,sy)]=1);
	}
	return ( state[ii(sx,sy)]=0 );
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t,n,k;
	cin>>t;
	while(t--){
		map<ii,int> state;
		cin>>n>>k;
		vvc arr(3,vector<char>(n+2));
		for(int j=0;j<3;j++)
			for(int i=0;i<n;i++)
				cin>>arr[j][i],state[ii(j,i)]=-1;

		for(int j=0;j<3;j++){
			for(int i=n-1;i<n+2;i++)
				state[ii(j,i)]=1;
			for(int i=n;i<n+2;i++)
				arr[j][i]='.';
		}
		int sx = findStart(arr),sy = 0;
		solve(sx,sy,state,arr);

		if(state[ii(sx,sy)])
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];
queue<pair<int,int>> q;

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>=n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        pair<int,int> a;
        int x,y,tx,ty;
        q.push({v,0});
        don[v][0]=1;
        while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            //cout<<x<<" "<<y<<"\n";

            for(l,0,3){
                tx=x+c[l];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,y)==0 && fun(x,ty,y)==0 && fun(tx,ty,y+1)==0 && don[tx][ty]==0){
                    q.push({tx,ty});
                    don[tx][ty]=1;
                    }
                }
            }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){

        cin>>n>>u;

        string s;

        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;

            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        queue<pair<int,int>> q,q1;

        for(f,0,3){
            for(g,0,n)don[f][g]=0;
            }

        q.push({v,0});

        pair<int,int> a;
        int x,y,tx,ty;
        for(j,0,n){
            while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            //cout<<x<<" "<<y<<"\n";
            don[x][y]=1;
            for(j,0,3){
                tx=x+c[j];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,j)==0 && fun(x,ty,j)==0 && fun(tx,ty,j+1)==0 && don[tx][ty]==0)q1.push({tx,ty});
            }

        }
        while(!q1.empty()){
            a=q1.front();
            q1.pop();
            q.push(a);
        }
        }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        queue<pair<int,int>> q;

        pair<int,int> a;
        int x,y,tx,ty;
        q.push({v,0});
        while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            cout<<x<<" "<<y<<"\n";
            don[x][y]=1;
            for(l,0,3){
                tx=x+c[l];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,y)==0 && fun(x,ty,y)==0 && fun(tx,ty,y+1)==0 && don[tx][ty]==0)q.push({tx,ty});
                }
            }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];
queue<pair<int,int>> q;

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        pair<int,int> a;
        int x,y,tx,ty;
        q.push({v,0});
        while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            //cout<<x<<" "<<y<<"\n";
            don[x][y]=1;
            for(l,0,3){
                tx=x+c[l];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,y)==0 && fun(x,ty,y)==0 && fun(tx,ty,y+1)==0 && don[tx][ty]==0)q.push({tx,ty});
                }
            }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        queue<pair<int,int>> q,q1;

        pair<int,int> a;
        int x,y,tx,ty;
        for(j,0,n){
            while(!q.empty()){
                a=q.front();
                q.pop();
                x=a.first;
                y=a.second;
                //cout<<x<<" "<<y<<"\n";
                don[x][y]=1;
                for(l,0,3){
                    tx=x+c[l];
                    ty=y+1;
                    if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,j)==0 && fun(x,ty,j)==0 && fun(tx,ty,j+1)==0 && don[tx][ty]==0)q1.push({tx,ty});
                }

        }
        while(!q1.empty()){
            a=q1.front();
            q1.pop();
            q.push(a);
        }
        }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];
queue<pair<int,int>> q;

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        pair<int,int> a;
        int x,y,tx,ty;
        q.push({v,0});
        don[v][0]=1;
        while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            //cout<<x<<" "<<y<<"\n";

            for(l,0,3){
                tx=x+c[l];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,y)==0 && fun(x,ty,y)==0 && fun(tx,ty,y+1)==0 && don[tx][ty]==0){
                    q.push({tx,ty});
                    don[tx][ty]=1;
                    }
                }
            }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


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

# define for(i,x,y) for(int i=x;i<y;i++)
# define mp(x,y) make_pair(x,y)
int c[3]={-1,0,1};
int don[3][100];
int n,u;
int cur[3][100];

int fun(int a,int b,int c){
    int x,y;
    y=b+2*c;
    x=a;
    if(y>n)return 0;
    else return cur[x][y];
}

int main(){
    int t;
    cin>>t;
    for(i,0,t){
        cin>>n>>u;
        string s;
        for(f,0,3){
            for(g,0,n){
                cur[f][g]=0;
                don[f][g]=0;
            }
        }

        int v;
        for(j,0,3){
            cin>>s;
            for(k,0,n){
                if(s[k]!='.'&&s[k]!='s')cur[j][k]=1;
            }
            if(s[0]=='s')v=j;
        }
        //cout<<v<<"\n";

        queue<pair<int,int>> q;

        pair<int,int> a;
        int x,y,tx,ty;
        q.push({v,0});
        while(!q.empty()){
            a=q.front();
            q.pop();
            x=a.first;
            y=a.second;
            //cout<<x<<" "<<y<<"\n";
            don[x][y]=1;
            for(l,0,3){
                tx=x+c[l];
                ty=y+1;
                if(tx>=0 && tx<3 && ty>=0 && ty<n && fun(tx,ty,y)==0 && fun(x,ty,y)==0 && fun(tx,ty,y+1)==0 && don[tx][ty]==0)q.push({tx,ty});
                }
            }

        if(don[0][n-1]==1 || don[1][n-1]==1 ||don[2][n-1]==1)cout<<"YES"<<"\n";
        else cout<<"NO"<<"\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        if (now.y >= n) return true;
        for (int i = 0; i < 3; i++) {
            node next = now;
            next.x += dir[i][0];
            next.y += dir[i][1];
            if (next.x < 1 || next.x > 3) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            next.y += 2;
            if (next.y >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y]) continue;
            vis[next.x][next.y] = 1;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 0;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (sy == n || bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            next.y += 2;
            if (next.y >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y]) continue;
            vis[next.x][next.y] = 1;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        memset(maze, 0, sizeof(maze));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3 || (next.y + 2) > n) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            if (next.y + 2 >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y + 2]) continue;
            vis[next.x][next.y + 2] = 1;
            next.y += 2;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        memset(maze, 0, sizeof(maze));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            next.y += 2;
            if (next.y >= n) return true;
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (sy == n || bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
#define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int n, k, sx;
char a[5][105];
typedef pair<int, int> P;

bool bfs(int sx) {
    queue<P> q; q.push(P(sx, 1));
    while(q.size()) {
        int x = q.front().first, y = q.front().second; q.pop();
        if(isalpha(a[x][++y])) continue;
        if(y >= n) return true;
        for(int i = -1; i <= 1; ++i) {
            int nx = x + i;
            if(nx < 1 || nx > 3) continue;
            if(isalpha(a[nx][y]) || isalpha(a[nx][y + 1])
                    || isalpha(a[nx][y + 2]) || a[nx][y + 2] == 1) continue;
            int ny = y + 2;
// pr(nx); prln(ny);
            if(ny >= n) return true;
            a[nx][ny] = 1;
            q.push(P(nx, ny));
        }
    }
    return false;
}

int main() {

    ios_base::sync_with_stdio(0);

    int t; scanf("%d", &t);
    while(t--) {
        scanf("%d%d", &n, &k);
        memset(a, 0, sizeof a);
        for(int i = 1; i <= 3; ++i) {
            scanf("%s", a[i] + 1);
            if(a[i][1] == 's') sx = i;
        }
        puts(bfs(sx) ? "YES" : "NO");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3 || (next.y + 2) > n) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            if (next.y + 2 >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y + 2]) continue;
            vis[next.x][next.y + 2] = 1;
            next.y += 2;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3 || (next.y + 2) > n) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }msmet
            if (next.y + 2 >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y + 2]) continue;
            vis[next.x][next.y + 2] = 1;
            next.y += 2;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 150;

int n, m;
struct node {
    int x, y;
};
int sx, sy;
int maze[maxn][maxn];
int dir[3][2] = {{0, 0}, {-1, 0}, {1, 0}};
bool vis[maxn][maxn];

bool bfs(int x, int y) {
    node now, next;
    queue<node> Q;
    now.x = x, now.y = y;
    vis[x][y] = 1;
    Q.push(now);
    while (!Q.empty()) {
        now = Q.front();
        Q.pop();
        // cout << now.x << " " << now.y << "\n";
        if (now.y == n) {
            return true;
        }
        now.y += 1;
        if (maze[now.x][now.y] == 1) continue;
        for (int i = 0; i < 3; i++) {
            next.x = now.x + dir[i][0];
            next.y = now.y + dir[i][1];
            if (next.x < 1 || next.y < 1 || next.x > 3) continue;
            if (maze[next.x][next.y] || maze[next.x][next.y + 1] || maze[next.x][next.y + 2]) {
                continue;
            }
            next.y += 2;
            if (next.y >= n) return true;
         // cout << next.x << " ---- " << next.y << "\n";
            if (vis[next.x][next.y]) continue;
            vis[next.x][next.y] = 1;
          //  cout << next.x << " ***** " << next.y << "\n";
            Q.push(next);
        }
    }
    return false;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while (T--) {
        memset(vis, 0, sizeof(vis));
        cin >> n >> m;
        for (int i = 1; i <= 3; i++) {
            string s; cin >> s;
            for (int j = 0; j < s.size(); j++) {
                if (s[j] == 's') {
                    maze[i][j + 1] = 1;
                    sx = i;
                    sy = j + 1;
                } else if (s[j] == '.') {
                    maze[i][j + 1] = 0;
                } else {
                    maze[i][j + 1] = 1;
                }
            }
        }
        if (bfs(sx, sy)) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 2e2;
char mp[3][maxn];
int T,n,k,sx,sy,vis[3][maxn];
bool flag;
void dfs(int x,int y,int op){
    if(y >= n || flag){
        flag = true;
        return ;
    }
    vis[x][y] = 1;
    if(op&1){
        if(mp[x][y+1]=='.'&&mp[x][y+2]=='.'&&!vis[x][y+2]) dfs(x,y+2,op+1);
    }else{
        if(mp[x][y+1]=='.'){
            if(!vis[x][y+1])dfs(x,y+1,op+1);
            if(x<2&&mp[x+1][y+1]=='.'&&!vis[x+1][y+1]) dfs(x+1,y+1,op+1);
            if(x>0&&mp[x-1][y+1]=='.'&&!vis[x-1][y+1]) dfs(x-1,y+1,op+1);
        }
    }
}
int main(){
    scanf("%d",&T);
    while(T--){
        flag = false;memset(vis,0,sizeof(vis));
        scanf("%d %d %d",&n,&k);
        for(int i = 0;i < 3; ++i) scanf("%s",mp[i]);
        for(int i = 0;i < 3; ++i){
            for(int j = 0;j < n; ++j){
                if(mp[i][j] == 's'){
                    sx = i; sy = j;
                    break;
                }
            }
        }
        for(int i = 0;i < 3; ++i){
            for(int j = n;j<=n+5;++j)mp[i][j]='.';
        }
        dfs(sx,sy,0);
        if(flag) puts("YES");
        else puts("NO");
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
const int maxn = 2e2;
char mp[3][maxn];
int T,n,k,sx,sy,vis[3][maxn];
bool flag;
void dfs(int x,int y,int op){
    if(y >= n || flag){
        flag = true;
        return ;
    }
    vis[x][y] = 1;
    if(op&1){
        if(mp[x][y+1]=='.'&&mp[x][y+2]=='.'&&!vis[x][y+2]) dfs(x,y+2,op+1);
    }else{
        if(mp[x][y+1]=='.'){
            if(!vis[x][y+1])dfs(x,y+1,op+1);
            if(x<2&&mp[x+1][y+1]=='.'&&!vis[x+1][y+1]) dfs(x+1,y+1,op+1);
            if(x>0&&mp[x-1][y+1]=='.'&&!vis[x-1][y+1]) dfs(x-1,y+1,op+1);
        }
    }
}
int main(){
    scanf("%d",&T);
    while(T--){
        flag = false;
        scanf("%d %d %d",&n,&k);
        for(int i = 0;i < 3; ++i) scanf("%s",mp[i]);
        for(int i = 0;i < 3; ++i){
            for(int j = 0;j < n; ++j){
                if(mp[i][j] == 's'){
                    sx = i; sy = j;
                    break;
                }
            }
        }
        for(int i = 0;i < 3; ++i){
            for(int j = n;j<=n+5;++j)mp[i][j]='.';
        }
        dfs(sx,sy,0);
        if(flag) puts("YES");
        else puts("NO");
    }
    return 0;
}


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

const int N = 110;

int pan[5][N][N], dp[5][N];
char buf[N];

int main() {

	ios_base::sync_with_stdio(0);

	int tcase; cin >> tcase;
	while (tcase--) {
		int n, k; cin >> n >> k;
		memset(pan, 0, sizeof pan);
		memset(dp, 0, sizeof dp);
		int sx = 0, sy = 0;
		for (int i = 1; i <= 3; i++) {
			cin >> buf + 1;
			for (int j = 1; j <= n; j++) {
				if ('A' <= buf[j] && buf[j] <= 'Z') pan[i][j][1] = 1;
				else {
					if (buf[j] == 's') sx = i, sy = j;
				}
			}
		}
		for (int i = 1; i <= 3; i++) for (int j = 1; j <= n; j++) if (pan[i][j][1]) {
			for (int k = 2; k <= n; k++) {
				int tar = j - 2 * (k - 1);
				if (tar < 1) continue;
				pan[i][tar][k] = 1;
			}
		}
		dp[sx][sy] = 1;
		for (int i = 1; i < n; i++) {
			for (int x = 1; x <= 3; x++) if (dp[x][i] && !pan[x][i + 1][i]) {
				if (x + 1 <= 3 && !pan[x + 1][i + 1][i + 1] && !pan[x + 1][i + 1][i]) dp[x + 1][i + 1] = 1;
				if (!pan[x][i + 1][i + 1] && !pan[x][i + 1][i]) dp[x][i + 1] = 1;
				if (x - 1 >= 1 && !pan[x - 1][i + 1][i + 1] && !pan[x - 1][i + 1][i]) dp[x - 1][i + 1] = 1;
			}
		}

		int ans = 0;
		for (int i = 1; i <= 3; i++) ans |= dp[i][n];
		if (ans) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct tt{
	int x, y, tim;
	int st, en, ii;
}train[30], ss;

char sen[5][150];
bool ff[150][5][150];
bool vis[5][150];

int main(){

	int T;
	cin >> T;
	while(T --){

		int n, k;
		cin >> n >> k;
		for(int i = 0; i < 3; i ++)cin >> sen[i];

		int cnt = 0;
		for(int i = 0; i < 3; i ++)for(int j = 0; j < n;){
			if(sen[i][j] == 's')ss.x = i, ss.y = j, j ++;
			else if(sen[i][j] != '.'){
				int jj = j;
				char ch = sen[i][j];
				while(ch == sen[i][j] && j < n)j ++;
				train[cnt].en = j - 1;
				train[cnt].ii = i;
				train[cnt ++].st = jj;
			}
			else j ++;
		}

		for(int tme = 0; tme <= n; tme ++) for(int j = 0; j < k; j ++)
			for(int i = train[j].st - 2 * tme; i < train[j].en - 2 * tme; i ++){
				if(i < 0)continue;
				ff[tme][train[j].ii][i] = 1;
			}

		ss.tim = 1;
		queue<tt > Q;
		while(!Q.empty())Q.pop();
		Q.push(ss);
		vis[ss.x][ss.y] = 1;

		bool fff = 0;
		while(!Q.empty()){
			tt cur;
			int x, y, tmm;
			tmm = Q.front().tim;
			x = Q.front().x, y = Q.front().y; Q.pop();
			if(y == n - 1){
				puts("YES");
				fff = 1;
				break;
			}

			cur.y = y + 1; cur.x = x; cur.tim = tmm + 1;
			if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			if(x >= 1){
				cur.x = x - 1;
				if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			}
			if(x <= 1){
				cur.x = x + 1;
				if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			}
		}
		if(!fff)puts("NO");
	}
}


#include <bits/stdc++.h>

using namespace std;

struct tt{
	int x, y, tim;
	int st, en, ii;
}train[30], ss;

char sen[5][150];
bool ff[150][5][150];
bool vis[5][150];

int main(){

	int T;
	cin >> T;
	while(T --){

		int n, k;
		cin >> n >> k;
		for(int i = 0; i < 3; i ++)cin >> sen[i];

		int cnt = 0;
		for(int i = 0; i < 3; i ++)for(int j = 0; j < n;){
			if(sen[i][j] == 's')ss.x = i, ss.y = j, j ++;
			else if(sen[i][j] != '.'){
				int jj = j;
				char ch = sen[i][j];
				while(ch == sen[i][j] && j < n)j ++;
				train[cnt].en = j - 1;
				train[cnt].ii = i;
				train[cnt ++].st = jj;
			}
			else j ++;
		}

		memset(ff, 0, sizeof(ff));
		memset(vis, 0, sizeof(vis));
		for(int tme = 0; tme <= n; tme ++) for(int j = 0; j < k; j ++)
			for(int i = train[j].st - 2 * tme; i <= train[j].en - 2 * tme; i ++){
				if(i < 0)continue;
				ff[tme][train[j].ii][i] = 1;
			}

		ss.tim = 1;
		queue<tt > Q;
		while(!Q.empty())Q.pop();
		Q.push(ss);
		vis[ss.x][ss.y] = 1;

		bool fff = 0;
		while(!Q.empty()){
			tt cur;
			int x, y, tmm;
			tmm = Q.front().tim;
			x = Q.front().x, y = Q.front().y; Q.pop();
			if(y == n - 1){
				puts("YES");
				fff = 1;
				break;
			}

			cur.y = y + 1; cur.x = x; cur.tim = tmm + 1;
			if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			if(x >= 1){
				cur.x = x - 1;
				if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			}
			if(x <= 1){
				cur.x = x + 1;
				if(!ff[tmm][cur.x][cur.y] && !vis[cur.x][cur.y])Q.push(cur), vis[cur.x][cur.y] = 1;
			}
		}
		if(!fff)puts("NO");
	}
}