import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.typecons;
import std.variant;

size_t[] solve(string a, string b) {
	size_t[] result;
	foreach (i; 0 .. a.length) {
		if (a[i] != b[i]) {
			result.assumeSafeAppend ~= i + 1;
			result.assumeSafeAppend ~= 1;
			result.assumeSafeAppend ~= i + 1;
		}
	}
	return result;
}

void main() {
	long tt = readln().chomp.to!long;
	foreach (t; 0 .. tt) {
		readln();
		string a = readln().chomp;
		string b = readln().chomp;
		if (a == b) {
			writeln("0");
		}
		else {
			auto arr = solve(a, b);
			writeln(arr.length, " ", arr.map!(to!string).join(" "));
		}
	}
}

// 00A00B 00C00D
// b11a11 00C00D
// 0A00B1 00C00D
