var n = parseInt(readline());
var mapa = new Array();
mapa['Polycarp'.toUpperCase()] = 1;
var rs = 0;
for (var i = 0; i < n; ++i) {
    var s = readline().split(' ');
    mapa[s[0].toUpperCase()] = mapa[s[2].toUpperCase()] + 1;
    if (mapa[s[0].toUpperCase()] > rs) {
        rs = mapa[s[0].toUpperCase()];
    }
}
print(rs);

'use strict';

// const rlLib = require('readline');

// const rl = rlLib.createInterface({
//   input: process.stdin,
//   output: process.stdout
// });

// let inputs = [];
// let allCount = 1;
// let currentLine = 0;

// rl.on('line', (input) => {
//  inputs.push(input);
//  if (inputs.length === 1) {
//     allCount = +inputs[0] + 1;
//  }
//  if (inputs.length >= allCount) {
//      main();

//      rl.close();
//  }
// });

// function readline() {
//  return inputs[currentLine++];
// }
// function print() {
//  console.log.apply(this, arguments);
// }

// /**
//  * @param {number} s
//  * @param {number[]} nums
//  * @return {number}
//  */
//  function main() {
    var count = +readline();
    // parent => children
    var tree = {'polycarp': []};

    for (var i = 0; i < count; i++) {
        var str = readline().split(' ').map(x => x.toLowerCase());

        tree[str[2]].push(str[0]);

        if (!tree[str[0]]) {
            tree[str[0]] = [];
        }
    }

    // пройдем поиском в ширину и посчитаем

    var st = [];
    var set = new Set();
    var res = 1;

    st.push(['polycarp', 1]);
    set.add('polycarp');

    while (st.length) {
        var data = st.pop();
        var name = data[0];
        var count = data[1];

        if (res < count) {
            res = count;
        }

        tree[name].forEach(function(name) {
            if (!set.has(name)) {
                st.push([name, count + 1]);
                set.add(name);
            }
        });
    }

    print(res);
// };

var i = 0,
    repostsCount = 0,
    maxDeep = 1,
    users = {
        'polycarp': {
            reposts: [],
            repostedFrom: false,
            deep: maxDeep,
        },
    };

var repostsCount = parseInt(readline());

function lower(string) {
    return string.toLowerCase();
}

while(i < repostsCount) {
        var _ = readline().split(' reposted ').map(lower),
            destination = _[0], source = _[1];
        users[source].reposts.push(destination);
        destinationDeep = users[source].deep + 1;
        if(maxDeep < destinationDeep) {
            maxDeep = destinationDeep;
        }
        users[destination] = {
            reposts: [],
            repostedFrom: source,
            deep: users[source].deep + 1,
        }
    i++;
}

    print(maxDeep);

var lengths = [];

function callback(arr, name2, i, d) {
	var indOf = true;

	for (; i < arr.length; i++) {
		if (arr[i][1] === name2) {
			callback(arr, arr[i][0], i + 1, d + 1);
			indOf = false;
		}
	}

	if (indOf) {
		lengths.push(d);
	}
}

function maxLengthOfChain() {
	var n = readline();
    var arr = [];

    for (var i = 0; i < n; i++) {
        arr.push(readline().toLowerCase().split(' reposted '));
    }

	callback(arr, 'polycarp', 0, 1);

	return Math.max(...lengths);
}

print(maxLengthOfChain());

Tree.prototype.traverseDF = function(callback) {

	// это рекурсивная и мгновенно вызываемая функция
	(function recurse(currentNode) {
		// шаг 2
		for (var i = 0, length = currentNode.children.length; i < length; i++) {
			// шаг 3
			recurse(currentNode.children[i]);
		}

		// шаг 4
		callback(currentNode);

		// шаг 1
	})(this._root);
};

Tree.prototype.add = function(data, toData, traversal) {
	var child = new Node(data),
	parent = null,
	callback = function(node) {
		if (node.data === toData) {
			parent = node;
		}
	};

	this.contains(callback, traversal);

	if (parent) {
		parent.children.push(child);
		child.parent = parent;
	} else {
		throw new Error('Cannot add node to a non-existent parent.');
	}
};

Tree.prototype.contains = function(callback, traversal) {
	traversal.call(this, callback);
};

function length(node, startLength) {
	if (node.parent === null) {
		return startLength;
	}
	return length(node.parent, startLength + 1);
}

function maxLengthOfChain() {

    var n = readline();
    var arr = [];
    var line;

    while (line = readline()) {
        arr.push(line);
    }

// 	var s = str.substring(2).toLowerCase();
// 	var arr = s.split('\n');
	var tree = new Tree('polycarp');

	arr.forEach(function(elem) {
		var names = elem.toLowerCase().split(' reposted ');

		tree.add(names[0], names[1], tree.traverseDF);
	});

	var maxLength = 0;
	tree.contains(function(node) {
		var l = length(node, 1);
		if (maxLength < l) {
			maxLength = l;
		}
	}, tree.traverseDF);

	print(maxLength);
}

maxLengthOfChain();

function Node(data) {
	this.data = data;
	this.parent = null;
	this.children = [];
}

function Tree(data) {
	var node = new Node(data);
	this._root = node;
}

var lengths = [];

function callback(arr, name2, i, d) {
	var indOf = true;

	for (; i < arr.length; i++) {
		if (arr[i][1] === name2) {
			callback(arr, arr[i][0], i + 1, d + 1);
			indOf = false;
		}
	}

	if (indOf) {
		lengths.push(d);
	}
}

function maxLengthOfChain() {
	var n = readline();
    var arr = [];
    var line;

    while (line = readline()) {
        arr.push(line.toLowerCase().split(' reposted '));
    }

	callback(arr, 'polycarp', 0, 1);

	return Math.max(...lengths);
}

print(maxLengthOfChain());

var n = readline();
var reposts = {
	polycarp: 1
};
var max = 1;
for (var i=0; i < n; i++) {
	var str = readline().toLowerCase().split(' ');
	var newValue = reposts[str[2]] + 1;
	reposts[str[0]] = newValue;
	if (newValue > max) {
		max = newValue;
	}
}
print(max);

function parseRepost(repostString) {
    var splitNames = repostString.split(" reposted ");
    var parent = splitNames[1];
    var child = splitNames[0];

    return [parent.toLowerCase(), child.toLowerCase()];
}

function getPopularity() {
    var repostMap = {};
    var max = 0;
    var numPosts = parseInt(readline());
    for(var i = 0; i < numPosts; i++) {
        var users = parseRepost(readline());
        if(!repostMap.hasOwnProperty(users[0])) {
            repostMap[users[0]] = 1;
        }

        repostMap[users[1]] = repostMap[users[0]] + 1;
        if(repostMap[users[1]]> max) {
            max = repostMap[users[1]];
        }
    }
    return max;
}

print(getPopularity());

var l = +readline();
var chainLengths = {}

chainLengths["polycarp"] = 1
var maxLen = 0

for (var i = 0; i < l; i++) {
    var rec = readline().split(' reposted ');
    var a = rec[0].toLowerCase()
    var b = rec[1].toLowerCase()
    chainLengths[a] = chainLengths[b] + 1
    if (chainLengths[a] > maxLen) {
        maxLen = chainLengths[a]
    }
}

print(maxLen);

// #################################################################### //
/**
 * @class UserNode will constitute the nodes of our repost tree,
 * with each node in the tree maintaining a count of the longest
 * chain perturbing from this node, and a reference to its parent
 * node.
 *
 * NOTE: the popularity attribute of the node or the popularity of
 * of this node's subtree refers to the length of the longest chain
 * perturbing from this node, with it as root.
 */
var UserNode = function(name){
  // Method to append a child node to children list.
  this.appendChild = function(childName){
    var newChild = new UserNode(childName.toLowerCase());
      newChild.parent = self;
    self.children.push(newChild);
  }
  // Method to get reference to the last child of this node.
  this.getLastChild = function(){
    return self.children[self.children.length-1];
  }
  // Method to determine popularity of this nodes's subtree.
  this.computePopularity = function(){
    var maxPopularity = 0;
    for(var i = 0;i<self.children.length;++i){
      var child = self.children[i];
      maxPopularity = Math.max(maxPopularity,child.popularity);
    }
    self.popularity = maxPopularity+1;
  }
  // For storing children nodes and the one parent node.
  this.children = []; this.parent = null;
  // For storing popularity of node's subtree and username.
  this.popularity = 0; this.username = name;
  // For storing reference to this node.
  var self = this;
};
// #################################################################### //
// Creating root node for polycarp.
var root = new UserNode('polycarp');
// Storing references to nodes of posters at any given moment.
var posters = {'polycarp':root};
// For storing posts collected from codeforces.
var postCount = parseInt(readline());
// Method to update popularity for tree after every insertion.
function updatePopularity(newUser){
  var currNode = newUser;
  while(currNode !== null){
    currNode.computePopularity();
    currNode = currNode.parent;
  }
}
// Inserting nodes into tree.
for(var j = 0;j<postCount;++j){
  // Parsing post.
  var post = readline().split(' reposted ');
  var poster = post[0].toLowerCase();
  var postee = post[1].toLowerCase();
  // Appending Child.
  posters[postee].appendChild(poster);
  // Adding to Hash-Map.
  var lastChild = posters[postee].getLastChild();
  posters[poster] = lastChild;
  // Updating popularity.
  updatePopularity(lastChild);
}
// Solution.
print(root.popularity);
// #################################################################### //

// #################################################################### //
/**
 * @class UserNode will constitute the nodes of our repost tree,
 * with each node in the tree maintaining a count of the longest
 * chain perturbing from this node, and a reference to its parent
 * node.
 *
 * NOTE: the popularity attribute of the node or the popularity of
 * of this node's subtree refers to the length of the longest chain
 * perturbing from this node, with it as root.
 *
 * @authour atifcppprogrammer
 */
var UserNode = function(name){
  // Method to append a child node to children list.
  this.appendChild = function(childName){
    var newChild = new UserNode(childName.toLowerCase());
      newChild.parent = self;
    self.children.push(newChild);
  };
  // Method to get reference to the last child of this node.
  this.getLastChild = function(){
    return self.children[self.children.length-1];
  };
  // Method to determine popularity of this nodes's subtree.
  this.computePopularity = function(){
    var maxPopularity = 0;
    for(var i = 0;i<self.children.length;++i){
      var child = self.children[i];
      maxPopularity = Math.max(maxPopularity,child.popularity);
    }
    self.popularity = maxPopularity+1;
  };
  // For storing children nodes and the one parent node.
  this.children = []; this.parent = null;
  // For storing popularity of node's subtree and username.
  this.popularity = 0; this.username = name;
  // For storing reference to this node.
  var self = this;
};
// #################################################################### //
/**
 * @namespace PostTree uses the above UserNode class to construct an
 * M-Tree datastructure, equipped with methods for tree insertion and
 * and updating popularity of the joke i.e. the length of the longest
 * chain in this tree.
 *
 * NOTE: The tree is intialized with a root node for polycarp since
 * polycarp was the original poster of the joke.
 *
 * @authour atifcppprogrammer
 */
var PostTree = {
  // Method to insert node into tree.
  insertNode:function(){
    var post = readline().split(' reposted ').map(function(e){
      return e.toLowerCase();
    });
    this.posters[post[1]].appendChild(post[0]);
    var lastChild = this.posters[post[1]].getLastChild();
      this.posters[post[0]] = lastChild;
    return lastChild;
  },
  // Method to update popularity of node tree after insertion.
  updatePopularity:function(newUser){
    var currNode = newUser;
    for(;currNode !== null;currNode = currNode.parent){
      currNode.computePopularity();
    }
  },
  // Storing references to nodes of posters at any given moment.
  posters:{},
  // Stores root of the tree.
  root: null,
};
// #################################################################### //
PostTree.root = new UserNode('polycarp');
PostTree.posters.polycarp = PostTree.root;
// Getting node count and starting tree insertion.
var postCount = parseInt(readline());
for(var j = 0;j<postCount;++j){
    PostTree.updatePopularity(PostTree.insertNode());
}
// Solution.
print(PostTree.root.popularity);
// #################################################################### //

var max = 1;
var posts = {
    polycarp: 1
};
for (var i = parseInt(readline()); i > 0; i--) {
    var line = readline().split(" ");
    var len = posts[line[2].toLowerCase()] + 1;
    posts[line[0].toLowerCase()] = len;
    if (max < len) max = len;
}
print(max);

var n = parseInt(readline());
var s, m=0, a = new Array(), b = new Array(), l = new Array();
for(i=0; i<n; i++) {
s = readline().toLowerCase().split(" ");
a[i] = s[0];
b[i] = s[2];
}
for (j = n-1; j>=0; j--) {
l[j] = 2;
kk = b[j];
while (kk != b[0]) {
for (i=0; i<j; i++) {
if (a[i] == kk) {
l[j]++;
kk = b[i];
break;
}
}
}
if (l[j] > m) m = l[j];
}
print(m);

function Stack()
{
    this.a = [];
}

Stack.prototype.empty = function()
{
    return this.a.length == 0;
}

Stack.prototype.push = function(v)
{
    this.a.push(v);
}

Stack.prototype.pop = function()
{
    if (!this.empty())
        return this.a.pop();
    return undefined;
}

Stack.prototype.top = function()
{
    if (!this.empty())
        return this.a[this.a.length - 1];
    return undefined;
}

Stack.prototype.clear = function()
{
    this.a = [];
}

Stack.prototype.size = function()
{
    return this.a.length;
}

function Queue()
{
    this.l = new Stack();
    this.r = new Stack();
}

Queue.prototype.push = function(v)
{
    this.l.push(v);
}

Queue.prototype.empty = function()
{
    return this.r.empty() && this.l.empty();
}

Queue.prototype.pop = function()
{
    if (this.r.empty())
    {
        while(!this.l.empty())
            this.r.push(this.l.pop());
    }
    if (!this.r.empty())
        return this.r.pop();
    return undefined;
}

Queue.prototype.front = function()
{
    if (this.r.empty())
    {
        while(!this.l.empty())
            this.r.push(this.l.pop());
    }
    if (!this.r.empty())
        return this.r.top();
    return undefined;
}

Queue.prototype.size = function()
{
    return l.size() + r.size();
}

Queue.prototype.clear = function()
{
    l.clear();
    r.clear();
}

function Reader()
{
    this.b = [];
    this.c = 0;
}

Reader.prototype.next = function()
{
    if (this.c == this.b.length)
    {
        this.c = 0;
        this.b = readline().split(' ');
    }
    return this.b[this.c++];
}

function Writer()
{
    this.l = [""];
    this.c = 0;
}

Writer.prototype.print = function(s)
{
    this.l[this.c] += s;
}

Writer.prototype.println = function(s)
{
    if (s == undefined)
        s = "";
    this.l[this.c] += s;
    this.l.push("");
    ++this.c;
}

Writer.prototype.flush = function()
{
    print(this.l.join('\n'));
    this.l = [];
}

Math.cmp = function(a, b)
{
    return (+a > +b)-(+a < +b);
}

function Treap(cmp)
{
    if (typeof cmp == "undefined")
        this.cmp = function(a,b){return ((a>b)-(a<b));};
    this.cmp = cmp;
    this._root = null;
}

Treap.Node = function(k, v, p, l, r)
{
    this.k = k;
    this.v = v;
    this.p = p;
    this.l = l;
    this.r = r;
    this.size = 1;
}

Treap.prototype._update = function(n)
{
    if (n)
        n.size = 1 + (n.l?n.l.size:0) + (n.r?n.r.size:0);
}

Treap.prototype._sizeOf = function(n)
{
    return (n?n.size:0);
}

Treap.prototype._split = function(t, k)
{
    if (!t)
        return {l : null, r : null};
    else
    {
        if (this.cmp(k, t.k) < 0)
        {
            var tmp = this._split(t.l, k);
            t.l = tmp.r;
            this._update(t);
            return {l: tmp.l, r: t};
        }
        var tmp = this._split(t.r, k);
        t.r = tmp.l;
        this._update(t);
        return {l : t, r : tmp.r};
    }
}

Treap.prototype._insert = function(t, n)
{
    if (!t)
        return n;
    if (n.p > t.p)
    {
        var tmp = this._split(t, n.k);
        n.l = tmp.l;
        n.r = tmp.r;
        this._update(n);
        return n;
    }
    if (this.cmp(n.k, t.k) <= 0)
        t.l = this._insert(t.l, n);
    else
        t.r = this._insert(t.r, n);
    this._update(t);
    return t;
}

Treap.prototype.nth = function(n)
{
    var cur = this._root;
    var lSize = 0;
    while(cur)
    {
        lSize = this._sizeOf(cur.l);
        if (lSize == n)
            return {k: cur.k, v: cur.v};
        cur = lSize > n ? cur.l : cur.r;
        if (lSize < n)
            n -= lSize + 1;
    }
    return null;
}

Treap.prototype._forEach = function(t, cb)
{
    if (t.l)
        this._forEach(t.l, cb);
    cb(t.k, t.v);
    if (t.r)
        this._forEach(t.r, cb);
}

Treap.prototype.forEach = function(cb)
{
    if (this._root)
        this._forEach(this._root, cb);
}

Treap.prototype.insert = function(k, v)
{
    this._root = this._insert(this._root, new Treap.Node(k, v, Math.random()+Math.random(), null, null));
}

Treap.prototype._merge = function(l, r)
{
    if (!l)
    {
        this._update(r);
        return r;
    }
    if (!r)
    {
        this._update(l);
        return l;
    }
    if (l.p > r.p)
    {
        l.r = this._merge(l.r, r)
        this._update(l);
        return l;
    }
    r.l = this._merge(l, r.l);
    this._update(r);
    return r;
}

Treap.prototype._erase = function(t, k)
{
    if (t.k == k)
    {
        var tmp = this._merge(t.l, t.r);
        this._update(tmp);
        return tmp;
    }
    if (this.cmp(k, t.k) <= 0)
        if (t.l)
            t.l = this._erase(t.l, k);
    else
        if (t.r)
            t.r = this._erase(t.r, k);
    this._update(t);
    return t;
}

Treap.prototype.erase = function(k)
{
    if (this._root)
        this._root = this._erase(this._root, k);
}

Treap.prototype._get = function(t, k)
{
    if (!t)
        return undefined;
    if (this.cmp(k, t.k) == 0)
        return t.v;
    if (this.cmp(k, t.k) < 0)
        return this._get(t.l, k);
    return this._get(t.r, k);
}

Treap.prototype.get = function(k)
{
    if (this._root)
        return this._get(this._root, k);
    return undefined;
}

Treap.prototype.clear = function()
{
    this._root = null;
}

Treap.prototype.size = function()
{
    return (this._root?this._root.size:0);
}

function cmp(a, b)
{
    if (a < b)
        return -1;
    if (a > b)
        return 1;
    return 0;
}

function main(cin, cout)
{
    var n = +cin.next();
    var treap = new Treap(cmp);
    treap.insert("polycarp", 1);
    for(var i = 0; i < n; ++i)
    {
        var s = cin.next().toLowerCase();
        cin.next();
        var t = cin.next().toLowerCase();
        treap.insert(s, treap.get(t) + 1);
    }
    var ans = 0;
    treap.forEach(function(k, v){ans=Math.max(ans,v);});
    cout.print(ans);
}

var cin = new Reader();
var cout = new Writer();

main(cin, cout);

cout.flush();

"use strict";
var i = 0,
	depth = {
		'polycarp': 1
	},
	max = 0,
	pair,
	cur,
	n = +readline();

for (; i<n; i++) {
	pair = readline().split(' reposted ');
	cur = depth[pair[1].toLowerCase()] + 1;
	depth[pair[0].toLowerCase()] = cur;
	cur > max && (max = cur);
}
print(max);

var count = readline();
var chain = {polycarp: []};

for(var i = 0; i < count; i++) {
  var names = readline()
  .split(' reposted ')
  .map(function(v) { return v.toLowerCase() });

  if(!chain[names[0]]) chain[names[0]] = chain[names[1]].concat();
  chain[names[0]].push(names[1]);
}

var max = 0;
for(var key in chain) {
  var cur = chain[key].length + 1;
  if(max < cur) max = cur;
}

print(max);

"use strict";
var i = 0,
	depth = {
		'polycarp': 0
	},
	max = 0,
	pair,
	cur,
	n = +readline();

for (; i<n; i++) {
	pair = readline().split(' reposted ');
	cur = depth[pair[1].toLowerCase()] + 1;
	depth[pair[0].toLowerCase()] = cur;
	cur > max && (max = cur);
}
print(max);

var count = readline();
var chain = {};

for(var i = 0; i < count; i++) {
    var names = readline()
    .split(' reposted ')
    .map(function(v) { return v.toLowerCase() });

    if(!chain[names[0]]) chain[names[0]] = chain[names[1]] || [];
    chain[names[0]].push(names[1]);
}

var max = 0;
for(var key in chain) {
    var cur = chain[key].length + 1;
    if(max < cur) max = cur;
}

print(max);

function parseRepost(repostString) {
    var splitNames = repostString.split(" reposted ");
    var parent = splitNames[1];
    var child = splitNames[0];

    return [parent.toLowerCase(), child.toLowerCase()];
}

function getPopularity() {
    var repostMap = {};
    var max = 0;
    var numPosts = parseInt(readline());
    for(var i = 0; i < numPosts; i++) {
        var users = parseRepost(readline());
        if(!repostMap.hasOwnProperty(users[0])) {
            repostMap[users[0]] = 0;
        }

        repostMap[users[1]] = repostMap[users[0]] + 1;
        if(repostMap[users[1]]> max) {
            max = repostMap[users[1]];
        }
    }
    return max;
}

print(getPopularity());


//Perfect Permutation

const {EOL} = require('os');

let inp = '';

process.stdin.on('data', c => inp += c);

process.stdin.on('end', () => {
    let n = +inp.split(EOL)[0];

    if(n % 2 == 1)  {
    	process.stdout.write("-1");
    	return;
    }

    for(let i = 1; i <= n; i += 2)  {
    	process.stdout.write((i + 1) + " " + i + " ");
    }

    return;
});

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function isPrime(x) {
	let s = Math.sqrt(x);
	let i = 2;
	while (i <= s) {
		if (x % i === 0) {
			return false;
		}
		i++;
	}
	return true;
}

function main() {
	let n = readLine() >> 0;
	if ((n & 1) === 1) {
		console.log(-1);
		return;
	}

	let arr = [];
	for (let i = 1; i <= n; i += 2) {
		arr[i - 1] = i + 1;
		arr[i] = i;
	}

	console.log(arr.join(' '));
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}

function main() {
    let input = parseInt(readLine());
    if (input % 2 !== 0) {
        console.log(-1);
        return;
    }
    let finalArray = [];

    for (let i = 1; i <= input; i++) {
        if (i % 2 === 0) {
            finalArray.push(i - 1);
        } else {
            finalArray.push(i + 1);
        }
    }
    let final = finalArray.join(' ');

    console.log(final);
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let len = +readLine();
  if (len % 2 !== 0) {
    console.log(-1);
    return;
  }
  let result = [];
  let [even, odd] = [2, 1];

  for (let i = 1; i <= len; i++) {
    if (i % 2 === 0) {
      result.push(odd);
      odd += 2;
    } else {
      result.push(even);
      even += 2;
    }
  }
  console.log(result.join(" "));
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  if(N % 2 == 1){
    myout(-1);
    return;
  }
  var output = [];
  for(var i = 1; i <= N; i += 2){
    output.push(i + 1);
    output.push(i);
  }
  myout(myconv(output, 8));
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;

  if (n % 2 === 1) {
    console.log(-1);
    return;
  }

  let ans = [];
  for (let i = 1; i <= n; i++) {
    if (i % 2 === 1) {
      ans.push(i + 1);
    }
    else {
      ans.push(i - 1);
    }
  }

  console.log(ans.join(' '));
});

var n=+readline();

if(n%2){
	print(-1);
}else{
	var p=[];
	for(var i=2; i<=n; i+=2){
		p.push(i);
		p.push(i-1);
	}
	print(p.join(' '));
}

;(function () {

	var n = +readline();

	if (n%2 !== 0) {
		print(-1);
		return;
	}

	var t = [];
	for (var i = 0; i < n; i += 2) t.push(i + 2, i + 1)
	print( t.join(' ') );

}).call(this);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var n = parseInt(readline());
	if (n%2 == 1) {
		print(-1);
	} else {
		var result = [];
		for (var i = 1; 2*i <= n; ++i) {
			result.push(2*i);
			result.push(2*i-1);
		}
		print(result.join(' '));
	}
}

main();

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;

  if (n === 1) {
    console.log(-1);
    return;
  }

  let ans = [];
  for (let i = 1; i <= n; i++) {
    if (i % 2 === 1) {
      ans.push(i + 1);
    }
    else {
      ans.push(i - 1);
    }
  }

  console.log(ans.join(' '));
});

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  if(N == 1){
    myout(-1);
    return;
  }
  var output = [];
  for(var i = 2; i <= N; i++){
    output.push(i);
  }
  output.push(1);
  myout(myconv(output, 8));
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;

  if (n === 1) {
    console.log(-1);
    return;
  }

  const ans = [n];
  for (let i = 1; i < n; i++) {
    ans.push(i);
  }

  console.log(ans.join(' '));
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', (d) => {
  const n = +d;

  if (n === 1) {
    console.log(-1);
    return;
  }

  const ans = [];
  for (let i = n; i > 0; i--) {
    ans.push(i);
  }

  console.log(ans.join(' '));
});


function solve() {
   var nr = read().split(' ').map(BigInt);
   var n = nr[0];
   var r = nr[1];
   if (r < n) {
      write('' + (r * (r + 1n) / 2n));
   } else {
      write('' + (n * (n - 1n) / 2n + 1n))
   }

}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', init);
   }
} else {
   init();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = ''
let currentLine = 0

process.stdin.on('data', inputStdin => {
    inputString += inputStdin
})

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n')

    main()
})

function readLine() {
    return inputString[currentLine++]
}

const s2i = s => parseInt(s, 10)

const readLineOfInts = () => {
  const split = readLine().split(' ')
  const result = []
  for (let i = 0, l = split.length; i < l; i++) {
    result.push(s2i(split[i]));
  }
  return result
}

function main() {
  let T = s2i(readLine())
  let out = ''

  while (T--) {
    const [n, r] = readLineOfInts()

    const min = BigInt(Math.min(n-1, r))

    const result = (n <= r ? 1n : 0n) + (min * (min + 1n) / 2n)

    out += result.toString() + '\n'
  }
  console.log(out)
}

    // Lang: Node.js
    'use strict';
    let x = '', y = 0;
    let print = x => console.log(x);

    process.stdin.on('data', inputStdin => x += inputStdin);
    process.stdin.on('end', () => { x = x.split('\n'); main(); });
    let readline = () => x[y++];

    // ************************ Code Start ***************************

    function main() {
      var Tc = parseInt(readline());
      while (Tc-- > 0) {
        var Arr = readline().split(" ").map(BigInt);
        var n = Arr[0];
        var r = Arr[1];
        if (r < n) {
          print("" + (r * (r + 1n)) / 2n);
        } else {
          print("" + ((n * (n - 1n)) / 2n + 1n));
        }
      }
    }

const process = require('process');

let inp = "";

function min(ba, bb) {
    if (ba < bb) return ba;
    return bb;
}

process.stdin.on('data', chunk => inp += chunk);
process.stdin.on('end', () => {
    inp = inp.split('\n');
    let ic = 0;
    let ntest = +inp[ic++];
    while (ntest--) {
        let [n, r] = inp[ic++].split(' ').map(BigInt);

        let t = min(n - 1n, r);
        let ans = t * (t + 1n) / 2n;
        if (r >= n) {
            ++ans;
        }
        console.log(ans.toString());

    }
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	while(hasNext()){
		var H = nextInt();
		var W = nextInt();
		var s = new Array(H);
		for(var i = 0; i < H; i++){
			s[i] = nextCharArray();
		}
		var queue = [];
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] != "."){
					queue.push([i,j]);
				}
			}
		}
		if(queue.length == 0){
			queue.push([0,0]);
			s[0][0] = "R";
		}
		while(queue.length > 0){
			var tmp = queue.shift();
			var y = tmp[0];
			var x = tmp[1];
			for(var j = 0; j < dy.length; j++){
				var nextY = y + dy[j];
				var nextX = x + dx[j];
				if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W){
					if(s[nextY][nextX] == "."){
						if(s[y][x] == "R"){
							s[nextY][nextX] = "W";
						}else{
							s[nextY][nextX] = "R";
						}
						queue.push([nextY, nextX]);
					}
				}
			}
		}
		var isOK = true;
		for(var i = 0; i < H - 1; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] == s[i + 1][j]){
					isOK = false;
				}
			}
		}
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W - 1; j++){
				if(s[i][j] == s[i][j + 1]){
					isOK = false;
				}
			}
		}
		myout((isOK) ? "Yes" : "No");
		if(isOK){
			for(var i = 0; i < H; i++){
				myout(myconv(s[i], 0));
			}
		}
	}
}

let i = "";
process.stdin.on("data", c => (i += c));
process.stdin.on("end", () => {
	const { EOL } = require("os");
	const lines = i.split(EOL);
	solve(lines);
});

function solve(lines) {
	const t = lines[0];
	let index = 1;
	for (let i = 0; i < t; i++) {
		const ij = lines[index++];
		const [n, m] = ij.split(" ").map(c => +c);
		let map = { R: [], W: [], ".": [] };
		for (let j = 0; j < n; j++) {
			const line = lines[index++];
			line.split("").forEach((c, k) => {
				map[c].push([(k + j) % 2, j, k]);
			});
		}
		let rVal = -1;
		map["R"].forEach(element => {
			if (rVal === -1) {
				rVal = element[0];
			} else if (element[0] !== rVal) {
				rVal = -2;
			}
		});
		let wVal = -1;
		map["W"].forEach(element => {
			if (wVal === -1) {
				wVal = element[0];
			} else if (element[0] !== wVal) {
				wVal = -2;
			}
		});
		if (rVal === -2 || wVal === -2 || (rVal === wVal && rVal !== -1) ) {
			console.log("NO");
		} else {
			console.log("YES");
			if (rVal === -1) {
                if(wVal === 1)
				    rVal = 0;
                else
                    rVal = 1;
			}
			for (let l = 0; l < n; l++) {
				let res = "";
				for (let c = 0; c < m; c++) {
					if (rVal === (c + l) % 2) {
						res += "R";
					} else {
						res += "W";
					}
				}
				console.log(res);
			}
		}
	}
}

/**
 * Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
 *
 * To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other
 */

// Write your solution here
const {EOL} = require("os");

function alternate_color(current_color) {
    return current_color === 'R' ? 'W' : 'R';
}

function is_valid(flag, start_color) {
    for (const row of flag) {
        let expected_color = start_color;
        for (const actual_color of row) {
            if (actual_color !== '.' && actual_color !== expected_color) {
                return false;
            }
            expected_color = alternate_color(expected_color);
        }
        start_color = alternate_color(start_color);
    }
    return true;
}

function print_solution(start_color, height, width) {
    for (let row_no = 0; row_no < height; row_no += 1) {
        let row_str = '';
        let color = start_color;
        for (let col_no = 0; col_no < width; col_no += 1) {
            row_str += color;
            color = alternate_color(color);
        }
        console.log(row_str);
        start_color = alternate_color(start_color);
    }

}

function solution({height, width, flag}) {
    for (const start_color of ['R', 'W']) {
        if (is_valid(flag, start_color)) {
            console.log('YES');
            print_solution(start_color, height, width);
            return;
        }
    }
    console.log('NO');
}

function parse(input) {
    const [height, width] = input.shift().split(' ').map(Number);
    return {
        height, width,
        flag: input.splice(0, height).map(row => row.trim())
    };
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(EOL);
    const number_of_test_cases = Number(input.shift());
    for (let _ = 0; _ < number_of_test_cases; _ += 1) {
        solution(parse(input));
    }
    process.exit();
});

const {EOL} = require("os");

function alternate_color(current_color) {
    return current_color === 'R' ? 'W' : 'R';
}

function is_valid(flag, start_color) {
    for (const row of flag) {
        let expected_color = start_color;
        for (const actual_color of row) {
            if (actual_color !== '.' && actual_color !== expected_color) {
                return false;
            }
            expected_color = alternate_color(expected_color);
        }
        start_color = alternate_color(start_color);
    }
    return true;
}

function print_solution(start_color, height, width) {
    for (let row_no = 0; row_no < height; row_no += 1) {
        let row_str = '';
        let color = start_color;
        for (let col_no = 0; col_no < width; col_no += 1) {
            row_str += color;
            color = alternate_color(color);
        }
        console.log(row_str);
        start_color = alternate_color(start_color);
    }

}

function solution({height, width, flag}) {
    for (const start_color of ['R', 'W']) {
        if (is_valid(flag, start_color)) {
            console.log('YES');
            print_solution(start_color, height, width);
            return;
        }
    }
    console.log('NO');
}

function parse(input) {
    const [height, width] = input.shift().split(' ').map(Number);
    return {
        height, width,
        flag: input.splice(0, height).map(row => row.trim())
    };
}

let lines = '';

process.stdin.on('data', data => lines += data);

process.stdin.on('end', () => {
    const input = lines.split(EOL);
    const number_of_test_cases = Number(input.shift());
    for (let _ = 0; _ < number_of_test_cases; _ += 1) {
        solution(parse(input));
    }
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(str => str.trim());

    main();
});

function readLine() {
    return inputString[currentLine++];
}
var gcd = function(a, b) {
    if (!b) {
      return a;
    }

    return gcd(b, a % b);
}

function main()
{
    //const name=readLine();
    //console.log(name);

    let test=readLine();
    while(test--)
    {
        nn=readLine();
        nn=nn.split(" ");
        n=parseInt(nn[0]);
        m=parseInt(nn[1]);
        grid=[];
        pos_x=-1,pos_y=-1;
        for(i=0;i<n;i++)
        {
            nn=readLine();
            nn.split(" ");
            temp=[];
            for(j=0;j<m;j++)
            {
                temp.push(nn[j]);
                if(pos_x===-1 && pos_y===-1 && nn[j]!='.')
                {
                    pos_x=i;
                    pos_y=j;
                }
            }
            grid.push(temp);
        }
        if(pos_x===-1 && pos_y===-1)
        {
            //cout<<"YES"<<endl;
            console.log("YES");
            for(i=0;i<n;i++)
            {

                previous='';
                if(i===0)
                    previous='s';
                else
                    previous=grid[i-1][0];
                str=""
                for(j=0;j<m;j++)
                {
                    give='';
                    if(i===0 && j===0)
                        give='W';
                    if(previous==='R')
                        give='W';
                    else if(previous==='W')
                        give='R';
                    grid[i][j]=give;
                    previous=give;
                    str+=grid[i][j]
                    //cout<<grid[i][j];

                }
                console.log(str);
               // cout<<endl;
            }
            continue;
        }

        chk=true;
        ///line left
        ch=grid[pos_x][pos_y];
        //cout<<ch<<endl;
        for(j=pos_y-1;j>=0;j--)
        {
            if(ch=='R')
            {
                cur='W';
                temp=grid[pos_x][j];
                if(temp===ch)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[pos_x][j]=cur;
                    ch=cur;
                }
            }
            else
            {
                cur='R';
                temp=grid[pos_x][j];
                if(temp===ch)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[pos_x][j]=cur;
                    ch=cur;
                }
            }
        }

        ///line right
        ch=grid[pos_x][pos_y];
        for(j=pos_y+1;j<m ;j++)
        {
            if(ch==='R')
            {
                cur='W';
                temp=grid[pos_x][j];
                if(temp===ch)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[pos_x][j]=cur;
                    ch=cur;
                }
            }
            else
            {
                cur='R';
                temp=grid[pos_x][j];
                if(temp===ch)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[pos_x][j]=cur;
                    ch=cur;
                }
            }
        }

        ///up
        for(i=pos_x-1;i>=0;i--)
        {
            now=grid[i+1][0];
            for(j=0;j<m;j++)
            {
                give='';
                if(now==='R')
                    give='W';
                else
                    give='R';
                if(grid[i][j]===now)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[i][j]=give;
                    now=give;
                }

            }
            if(chk==false)
                break;
        }

        ///down

        for(i=pos_x+1;i<n;i++)
        {
            now=grid[i-1][0];
            for(j=0;j<m;j++)
            {
                give='';
                if(now==='R')
                    give='W';
                else
                    give='R';
                if(grid[i][j]===now)
                {
                    chk=false;
                    break;
                }
                else
                {
                    grid[i][j]=give;
                    now=give;
                }

            }
            if(chk===false)
                break;
        }

        if(chk===false)
        {
            console.log("NO")
            //cout<<"NO"<<endl;
            continue;
        }
        console.log("YES");
        //cout<<"YES"<<endl;

        for(i=0;i<n;i++)
        {
            out="";
            for(j=0;j<m;j++)
                out+=grid[i][j];
            console.log(out);
        }

    }
}

///////////////////////////////// pre-define ////////////////////////////////////////////////////////////////////////////////
const pr = console.log;
const mi = Math.min;
const mx = Math.max;
const mxll = (...args) => args.reduce((m, e) => e > m ? e : m);
const mill = (...args) => args.reduce((m, e) => e < m ? e : m);
const sqll = (v) => { if (v < 0n) throw 'negative input'; if (v < 2n) return v; const dfs = (n, x0) => { let x1 = ((n / x0) + x0) >> 1n; if (x0 === x1 || x0 === (x1 - 1n)) return x0; return dfs(n, x1); }; return dfs(v, 1n); }; // has >> 0
const abs = Math.abs;
const fl = Math.floor;
const ce = Math.ceil;
const sq = Math.sqrt;
const lge = Math.log;
const lg10 = Math.log10;
const ll = BigInt;
const combination = (m, n) => { return factorial(m, n) / factorial(n, n); };
const factorial = (m, n) => { let num = 1n; let cnt = 0; for (let i = ll(m); i > 0; i--) { if (cnt == n) break; num *= i; cnt++; } return num; };
const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);
const lcm = (a, b) => (a / gcd(a, b)) * b;
const bitCount = (n) => { n = n - ((n >> 1) & 0x55555555); n = (n & 0x33333333) + ((n >> 2) & 0x33333333); return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; };
const powmod = (a, b, mod) => { let r = 1n; while (b > 0n) { if (b % 2n == 1) r = r * a % mod; b >>= 1n; a = a * a % mod; } return r; };
const amax = (a) => mx.apply(Math, a);
const amin = (a) => mi.apply(Math, a);
const sm = (a) => a.reduce(((x, y) => x + y), 0);
const aeq = (a, b) => JSON.stringify(a) == JSON.stringify(b);
const swap = (a, i, j) => [a[i], a[j]] = [a[j], a[i]];
const stin = (a) => a.sort((x, y) => x - y);
const stde = (a) => a.sort((x, y) => y - x);
const sortPart = (a, k) => { let l = a.slice(0, k); l.sort((x, y) => x - y); let r = a.slice(k); return l.concat(r); }; // sort first kth
const initialize2DArrayNew = (m, n) => { let data = []; for (let i = 0; i < m; i++) { let tmp = Array(n).fill(0); data.push(tmp); } return data; };
const stmkey_in = (m) => new Map([...m].sort((x, y) => x[0] - y[0]));
const stmkey_de = (m) => new Map([...m].sort((x, y) => y[0] - x[0]));
const stmvalue_in = (m) => new Map([...m].sort((x, y) => x[1] - y[1]));
const stmvalue_de = (m) => new Map([...m].sort((x, y) => y[1] - x[1]));
const counter = (a_or_s) => { let map = new Map(); for (const i of a_or_s) map.set(i, map.get(i) + 1 || 1); return map; };
const counter_value_in_indexA_in = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).push(i); } return m; };
const counter_value_in_indexA_de = (a_or_s) => { let m = new Map(); let n = a_or_s.length; for (let i = 0; i < n; i++) { if (!m.has(a_or_s[i])) m.set(a_or_s[i], []); m.get(a_or_s[i]).unshift(i); } return m; };
const reverse2 = (s) => { let res = ""; for (let i = s.length - 1; i >= 0; i--) { res += s[i]; } return res; };
const isPalindrome = (s) => { let n = s.length; let i = 0; let j = n - 1; while (i < j) { if (s[i++] != s[j--]) return false; } return true; };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const solve = (n, m, g) => {
    // pr(n, m, g);
    let res1 = generate(n, m, 'W');
    let res2 = generate(n, m, 'R');
    if (ok(g, res1)) {
        pr('YES');
        // pr("res1", res1);
        res1 = res1.map(x => x.join(""));
        for (const s of res1) pr(s);
    } else if (ok(g, res2)) {
        pr('YES');
        res2 = res2.map(x => x.join(""));
        for (const s of res2) pr(s);
    } else {
        pr('NO');
    }
};

const ok = (g, t) => {
    let n = g.length;
    let m = g[0].length;
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (g[i][j] == '.') continue;
            if (g[i][j] != t[i][j]) return false;
        }
    }
    return true;
};

const generate = (n, m, start) => {
    let res = [];
    let c = start;
    for (let i = 0; i < n; i++) {
        let tmp = [];
        for (let j = 0; j < m; j++) {
            tmp.push(c = transfer(c));
        }
        start = transfer(start);
        c = start;
        res.push(tmp);
    }
    return res;
};

const transfer = (c) => {
    return c == 'W' ? 'R' : 'W';
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    let input = [];
    rl.on('line', (line) => {
        input.push(line);
    });
    rl.on('close', () => {
        let t = Number(input[0]);
        let i = 1;
        while (t--) {
            let s = input[i];
            let a = s.split(" ").map(Number);
            let [n, m] = [a[0], a[1]];
            let tmp = input.slice(i + 1, i + n + 1);
            tmp = tmp.map(s => s.split(""));
            solve(n, m, tmp);
            i += n + 1;
        }
    });
};

main()

const lib = require('readline');
const rl = lib.createInterface({
    input: process.stdin,
    output: process.stdout
});

const getLine = (function () {
    const getLineGen = (async function* () {
        for await (const line of rl) {
            yield line;
        }
    })();
    return async () => ((await getLineGen.next()).value);
})();

let solve = async () => {
    const nsc = parseInt(await getLine());
    for (let sc = 0; sc < nsc; sc++) {
        let n, m;
        [n, m] = (await getLine()).split(' ').map(num => parseInt(num));
        const table = new Array(n);
        for (let i = 0; i < n; i++)
            table[i] = (await getLine()).split("");
        let fail = false;
        let dfs = function (row, col) {
            let delta = [-1, 0, 1];
            for (let i = 0; i < 3; i++)
                for (let j = 0; j < 3; j++) {
                    if (Math.abs(delta[i]) + Math.abs(delta[j]) === 1) {
                        let nrow = row + delta[i];
                        let ncol = col + delta[j];
                        if (nrow >= 0 && nrow < n && ncol >= 0 && ncol < m) {
                            if (table[nrow][ncol] === table[row][col])
                                return -1;
                            else if (table[nrow][ncol] === '.') {
                                if (table[row][col] == 'R')
                                    table[nrow][ncol] = 'W';
                                else
                                    table[nrow][ncol] = 'R';
                                if (dfs(nrow, ncol) < 0)
                                    return -1;
                            }
                        }
                    }
                }
            return 0;
        }

        for (let row = 0; row < n && !fail; row++)
            for (let col = 0; col < m && !fail; col++)
                if (table[row][col] !== '.') {
                    if (dfs(row, col) < 0) {
                        fail = true;
                    }
                }
        if (table[0][0] === '.') {
            table[0][0] = 'R';
            if (dfs(0,0) < 0)
                faile = true;
        }
        if (fail)
            console.log('NO');
        else {
            console.log('YES');
            for (let row = 0; row < n; row++)
                console.log(table[row].join(''));
        }
    }
}

solve();

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
   inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

// End of Codeforces interface

function fillLine(c1, c2, index, length) {
  let line = '';
  for (let i = 0; i < length; i++) {
    const first = index % 2 == i % 2;
    line += (first ? c1 : c2);
  }
  return line;
}

function fillGrid(x, y, c1, c2) {
  const grid = [];
  for (let i = 0; i < x; i++) {
    grid.push(fillLine(c1, c2, i, y));
  }
  return grid;
}

function isOkGrid(initialGrid, finalGrid) {
  try {
    initialGrid.forEach((x, i) => {
      for (let y = 0; y < x.length; y++) {
        if (x.charAt(y) != '.') {
          if (x.charAt(y) != finalGrid[i].charAt(y)) throw new Error();
        }
      }
    });
    return true;
  } catch (e) {
    return false;
  }
}

function main() {
  let testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    let [x, y] = readline().split(" ").map(n => parseInt(n));
    let initialGrid = [];
    let finalGrid;
    let isOkTestCase;

    for (let j = 0; j < x; j++) {
      initialGrid.push(readline());
    }

    finalGrid = fillGrid(x, y, 'R', 'W');
    isOkTestCase = isOkGrid(initialGrid, finalGrid);

    if (!isOkTestCase) {
      finalGrid = fillGrid(x, y, 'W', 'R');
      isOkTestCase = isOkGrid(initialGrid, finalGrid);
    }

    if (isOkTestCase) {
      console.log('YES');
      for (let line of finalGrid) {
        console.log(line);
      }
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x] = readline().split(" ").map(n => parseInt(n));
    const grid = [];
    let isOkTestCase = true;
    let first = '.';
    let second = '.';

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
      const r = line.indexOf('R');
      const w = line.indexOf('W');
      if (first == '.' && second == '.') {
        if (r !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'R';
            second = 'W';
          } else {
            first = 'W';
            second = 'R';
          }
        }
        if (w !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'W';
            second = 'R';
          } else {
            first = 'R';
            second = 'W';
          }
        }
      }
    }

    if (first == '.' || second == '.') {
      first = 'R';
      second = 'W';
    }

    let color = '.';
    forloop:
    for (let x = 0; x < grid.length; x++) {
      for (let y = 0; y < grid[x].length; y++) {
        if (x % 2 == 0 && y % 2 == 0 || x % 2 != 0 && y % 2 != 0) {
          color = first;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        } else {
          color = second;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        }
      }
    }

    if (isOkTestCase) {
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x] = readline().split(" ").map(n => parseInt(n));
    const grid = [];
    let isOkTestCase = true;
    let first = '.';
    let second = '.';

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
      const r = line.indexOf('R');
      const w = line.indexOf('W');
      if (first == '.' && second == '.') {
        if (r !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'R';
            second = 'W';
          } else {
            first = 'W';
            second = 'R';
          }
        }
        if (w !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'W';
            second = 'R';
          } else {
            first = 'R';
            second = 'W';
          }
        }
      }
    }

    let color = '.';
    forloop:
    for (let x = 0; x < grid.length; x++) {
      for (let y = 0; y < grid[x].length; y++) {
        if (x % 2 == 0 && y % 2 == 0 || x % 2 != 0 && y % 2 != 0) {
          color = first;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        } else {
          color = second;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        }
      }
    }

    if (isOkTestCase) {
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];
    let isOkTestCase = true;
    let first = '.';
    let second = '.';

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
      const r = line.indexOf('R');
      const w = line.indexOf('W');
      if (first == '.' && second == '.') {
        if (r !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'R';
            second = 'W';
          } else {
            first = 'W';
            second = 'R';
          }
        }
        if (w !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'W';
            second = 'R';
          } else {
            first = 'R';
            second = 'W';
          }
        }
      }
    }

    let color = '.';
    forloop:
    for (let x = 0; x < grid.length; x++) {
      for (let y = 0; y < grid[x].length; y++) {
        if (x % 2 == 0 && y % 2 == 0 || x % 2 != 0 && y % 2 != 0) {
          color = first;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        } else {
          color = second;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        }
      }
    }

    if (isOkTestCase) {
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function isDifferentNeighborTwo(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 != c2) return true; else return false;
}

function isEqualNeighbor(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 == c2) return true; else return false;
}

function isOkGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      for (let i = -2; i <= 2; i = i + 4) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x][y2]))
            return false;
      }
      for (let i = -1; i <= 1; i = i + 2) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x][y2]))
            return false;
      }
    }
  }
  return true;
}

function isGridComplete(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (grid[x][y] == '.') return false;
    }
  }
  return true;
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];
    let isOkTestCase = true;
    let first = '.';
    let second = '.';

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
      const r = line.indexOf('R');
      const w = line.indexOf('W');
      if (first == '.' && second == '.') {
        if (r !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'R';
            second = 'W';
          } else {
            first = 'W';
            second = 'R';
          }
        }
        if (w !== -1) {
          if (j % 2 == 0 && r % 2 == 0 || j % 2 != 0 && r % 2 != 0) {
            first = 'W';
            second = 'R';
          } else {
            first = 'R';
            second = 'W';
          }
        }
      }
    }

    let color = '.';
    forloop:
    for (let x = 0; x < grid.length; x++) {
      for (let y = 0; y < grid[x].length; y++) {
        if (x % 2 == 0 && y % 2 == 0 || x % 2 != 0 && y % 2 != 0) {
          color = first;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        } else {
          color = second;
          if (grid[x][y] == '.') {
            grid[x][y] = color;
          } else if (grid[x][y] != color) {
            isOkTestCase = false;
            break forloop;
          }
        }
      }
    }

    if (isOkTestCase) {
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function isDifferentNeighborTwo(x1, y1, x2, y2, grid) {
  if (x2 < 0 || y2 < 0) return false;
  if (x2 >= grid.length || y2 >= grid[x2].length) return false;
  if (grid[x1][y1] == '.' || grid[x2][y2] == '.') return false;
  if (grid[x1][y1] != grid[x2][y2]) return true; else return false;
}

function isEqualNeighbor(x1, y1, x2, y2, grid) {
  if (x2 < 0 || y2 < 0) return false;
  if (x2 >= grid.length || y2 >= grid[x2].length) return false;
  if (grid[x1][y1] == '.' || grid[x2][y2] == '.') return false;
  if (grid[x1][y1] == grid[x2][y2]) return true; else return false;
}

function isOkCell(x, y, grid) {
  if (
    isEqualNeighbor(x, y, x-1, y, grid) ||
    isEqualNeighbor(x, y, x+1, y, grid) ||
    isEqualNeighbor(x, y, x, y-1, grid) ||
    isEqualNeighbor(x, y, x, y+1, grid) ||

    isDifferentNeighborTwo(x, y, x-2, y, grid) ||
    isDifferentNeighborTwo(x, y, x+2, y, grid) ||
    isDifferentNeighborTwo(x, y, x, y-2, grid) ||
    isDifferentNeighborTwo(x, y, x, y+2, grid)
  ) return false; else return true;
}

function isOkGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (!isOkCell(x, y, grid)) return false;
    }
  }
  return true;
}

function fillCell(x, y, grid, color) {
  if (x < 0 || y < 0) return;
  if (x >= grid.length || y >= grid[x].length) return;
  if (grid[x][y] != '.') return;
  grid[x][y] = color;
}

function fillNeighborCells(x, y, grid) {
  if (grid[x][y] == 'R') {
    fillCell(x-1, y, grid, 'W');
    fillCell(x+1, y, grid, 'W');
    fillCell(x, y-1, grid, 'W');
    fillCell(x, y+1, grid, 'W');
  } else {
    fillCell(x-1, y, grid, 'R');
    fillCell(x+1, y, grid, 'R');
    fillCell(x, y-1, grid, 'R');
    fillCell(x, y+1, grid, 'R');
  }
}

function isGridComplete(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (grid[x][y] == '.') return false;
    }
  }
  return true;
}

function fillGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      fillNeighborCells(x, y, grid);
    }
  }
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();
  const testCases = [];

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
    }

    testCases.push({ x, y, grid });
  }

  testCases.forEach((testCase) => {
    if (isOkGrid(testCase.grid)) {
      testCase.isOk = true;
    } else {
      testCase.isOk = false;
    }
  });

  testCases.forEach((testCase) => {
    if (testCase.isOk) {
      fillGrid(testCase.grid);
    }
  });

  testCases.forEach((testCase) => {
    if (isOkGrid(testCase.grid)) {
      testCase.isOk = true;
    } else {
      testCase.isOk = false;
    }
  });

  testCases.forEach((testCase) => {
    if (testCase.isOk) {
      console.log('YES');
      printGrid(testCase.grid);
    } else {
      console.log('NO');
    }
  });
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function isDifferentNeighborTwo(x1, y1, x2, y2, grid) {
  if (x2 < 0 || y2 < 0) return false;
  if (x2 >= grid.length || y2 >= grid[x2].length) return false;
  if (grid[x1][y1] == '.' || grid[x2][y2] == '.') return false;
  if (grid[x1][y1] != grid[x2][y2]) return true; else return false;
}

function isEqualNeighbor(x1, y1, x2, y2, grid) {
  if (x2 < 0 || y2 < 0) return false;
  if (x2 >= grid.length || y2 >= grid[x2].length) return false;
  if (grid[x1][y1] == '.' || grid[x2][y2] == '.') return false;
  if (grid[x1][y1] == grid[x2][y2]) return true; else return false;
}

function isOkCell(x, y, grid) {
  if (
    isEqualNeighbor(x, y, x-1, y, grid) ||
    isEqualNeighbor(x, y, x+1, y, grid) ||
    isEqualNeighbor(x, y, x, y-1, grid) ||
    isEqualNeighbor(x, y, x, y+1, grid) ||

    isDifferentNeighborTwo(x, y, x-2, y, grid) ||
    isDifferentNeighborTwo(x, y, x+2, y, grid) ||
    isDifferentNeighborTwo(x, y, x, y-2, grid) ||
    isDifferentNeighborTwo(x, y, x, y+2, grid)
  ) return false; else return true;
}

function isOkGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (!isOkCell(x, y, grid)) return false;
    }
  }
  return true;
}

function fillCell(x, y, grid, color) {
  if (x < 0 || y < 0) return;
  if (x >= grid.length || y >= grid[x].length) return;
  if (grid[x][y] != '.') return;
  grid[x][y] = color;
}

function fillNeighborCells(x, y, grid) {
  if (grid[x][y] == 'R') {
    fillCell(x-1, y, grid, 'W');
    fillCell(x+1, y, grid, 'W');
    fillCell(x, y-1, grid, 'W');
    fillCell(x, y+1, grid, 'W');
  } else {
    fillCell(x-1, y, grid, 'R');
    fillCell(x+1, y, grid, 'R');
    fillCell(x, y-1, grid, 'R');
    fillCell(x, y+1, grid, 'R');
  }
}

function isGridComplete(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (grid[x][y] == '.') return false;
    }
  }
  return true;
}

function fillGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      fillNeighborCells(x, y, grid);
    }
  }
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();
  const testCases = [];

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
    }

    testCases.push({ x, y, grid });
  }

  testCases.forEach((testCase) => {
    if (isOkGrid(testCase.grid)) {
      testCase.isOk = true;
    } else {
      testCase.isOk = false;
    }
  });

  testCases.forEach((testCase) => {
    if (testCase.isOk) {
      fillGrid(testCase.grid);
    }
  });

  testCases.forEach((testCase) => {
    if (testCase.isOk) {
      console.log('YES');
      printGrid(testCase.grid);
    } else {
      console.log('NO');
    }
  });
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function isDifferentNeighborTwo(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 != c2) return true; else return false;
}

function isEqualNeighbor(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 == c2) return true; else return false;
}

function isOkGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      for (let i = -2; i <= 2; i = i + 4) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x][y2]))
            return false;
      }
      for (let i = -1; i <= 1; i = i + 2) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x][y2]))
            return false;
      }
    }
  }
  return true;
}

function isGridComplete(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (grid[x][y] == '.') return false;
    }
  }
  return true;
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
    }

    if (isOkGrid(grid)) {
      let color = '.';
      for (let x = 0; x < grid.length; x++) {
        for (let y = 0; y < grid[x].length; y++) {
          if (grid[x][y] == 'R') {
            color = 'W';
          } else {
            color = 'R';
          }
          for (let i = -1; i <= 1; i = i + 2) {
            const x2 = x + i;
            if (x2 >= 0 && x2 < grid.length) {
              if (grid[x2][y] == '.')
                grid[x2][y] = color;
            }
            const y2 = y + i;
            if (y2 >= 0 && y2 < grid[x].length) {
              if (grid[x][y2] == '.')
                grid[x][y2] = color;
            }
          }
        }
      }
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function isDifferentNeighborTwo(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 != c2) return true; else return false;
}

function isEqualNeighbor(c1, c2) {
  if (!c1 || !c2 || c1 == '.' || c2 == '.') return false;
  if (c1 == c2) return true; else return false;
}

function isOkGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      for (let i = -2; i <= 2; i = i + 4) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isDifferentNeighborTwo(grid[x][y], grid[x][y2]))
            return false;
      }
      for (let i = -1; i <= 1; i = i + 2) {
        const x2 = x + i;
        if (x2 >= 0 && x2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x2][y]))
            return false;
        const y2 = y + i;
        if (y2 >= 0 && y2 < grid.length)
          if (isEqualNeighbor(grid[x][y], grid[x][y2]))
            return false;
      }
    }
  }
  return true;
}

function isGridComplete(grid) {
  for (let x = 0; x < grid.length; x++) {
    for (let y = 0; y < grid[x].length; y++) {
      if (grid[x][y] == '.') return false;
    }
  }
  return true;
}

function printGrid(grid) {
  for (let x = 0; x < grid.length; x++) {
    console.log(grid[x].join(''));
  }
}

function main() {
  const testCaseCount = readline();

  for (let i = 0; i < testCaseCount; i++) {
    const [x, y] = readline().split(" ").map(n => parseInt(n));
    const grid = [];

    for (let j = 0; j < x; j++) {
      const line = readline().split("");
      grid.push(line);
    }

    if (isOkGrid(grid)) {
      let color = '.';
      for (let x = 0; x < grid.length; x++) {
        for (let y = 0; y < grid[x].length; y++) {
          if (grid[x][y] == 'R') {
            color = 'W';
          } else {
            color = 'R';
          }
          for (let i = -1; i <= 1; i = i + 2) {
            const x2 = x + i;
            if (x2 >= 0 && x2 < grid.length) {
              grid[x2][y] = color;
            }
            const y2 = y + i;
            if (y2 >= 0 && y2 < grid[x].length) {
              grid[x][y2] = color;
            }
          }
        }
      }
      console.log('YES');
      printGrid(grid);
    } else {
      console.log('NO');
    }
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	while(hasNext()){
		var H = nextInt();
		var W = nextInt();
		var s = new Array(H);
		for(var i = 0; i < H; i++){
			s[i] = nextCharArray();
		}
		var queue = [];
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] != "."){
					queue.push([i,j]);
				}
			}
		}
		if(queue.length == 0){
			queue.push([0,0]);
		}
		while(queue.length > 0){
			var tmp = queue.shift();
			var y = tmp[0];
			var x = tmp[1];
			for(var j = 0; j < dy.length; j++){
				var nextY = y + dy[j];
				var nextX = x + dx[j];
				if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W){
					if(s[nextY][nextX] == "."){
						if(s[y][x] == "R"){
							s[nextY][nextX] = "W";
						}else{
							s[nextY][nextX] = "R";
						}
						queue.push([nextY, nextX]);
					}
				}
			}
		}
		var isOK = true;
		for(var i = 0; i < H - 1; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] == s[i + 1][j]){
					isOK = false;
				}
			}
		}
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W - 1; j++){
				if(s[i][j] == s[i][j + 1]){
					isOK = false;
				}
			}
		}
		myout((isOK) ? "Yes" : "No");
		if(isOK){
			for(var i = 0; i < H; i++){
				myout(myconv(s[i], 0));
			}
		}
	}
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = BigInt(next());
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var dy = [-1,0,1,0];
	var dx = [0,-1,0,1];
	while(hasNext()){
		var H = nextInt();
		var W = nextInt();
		var s = new Array(H);
		for(var i = 0; i < H; i++){
			s[i] = nextCharArray();
		}
		var queue = [];
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] != "."){
					queue.push([i,j]);
				}
			}
		}
		while(queue.length > 0){
			var tmp = queue.shift();
			var y = tmp[0];
			var x = tmp[1];
			for(var j = 0; j < dy.length; j++){
				var nextY = y + dy[j];
				var nextX = x + dx[j];
				if(nextY >= 0 && nextY < H && nextX >= 0 && nextX < W){
					if(s[nextY][nextX] == "."){
						if(s[y][x] == "R"){
							s[nextY][nextX] = "W";
						}else{
							s[nextY][nextX] = "R";
						}
						queue.push([nextY, nextX]);
					}
				}
			}
		}
		var isOK = true;
		for(var i = 0; i < H - 1; i++){
			for(var j = 0; j < W; j++){
				if(s[i][j] == s[i + 1][j]){
					isOK = false;
				}
			}
		}
		for(var i = 0; i < H; i++){
			for(var j = 0; j < W - 1; j++){
				if(s[i][j] == s[i][j + 1]){
					isOK = false;
				}
			}
		}
		myout((isOK) ? "Yes" : "No");
		if(isOK){
			for(var i = 0; i < H; i++){
				myout(myconv(s[i], 0));
			}
		}
	}
}

let i = "";
process.stdin.on("data", c => (i += c));
process.stdin.on("end", () => {
	const { EOL } = require("os");
	const lines = i.split(EOL);
	solve(lines);
});

function solve(lines) {
	const t = lines[0];
	let index = 1;
	for (let i = 0; i < t; i++) {
		const ij = lines[index++];
		const [n, m] = ij.split(" ").map(c => +c);
		let map = { R: [], W: [], ".": [] };
		for (let j = 0; j < n; j++) {
			const line = lines[index++];
			line.split("").forEach((c, k) => {
				map[c].push([(k + j) % 2, j, k]);
			});
		}
		let rVal = -1;
		map["R"].forEach(element => {
			if (rVal === -1) {
				rVal = element[0];
			} else if (element[0] !== rVal) {
				rVal = -2;
			}
		});
		let wVal = -1;
		map["W"].forEach(element => {
			if (wVal === -1) {
				wVal = element[0];
			} else if (element[0] !== wVal) {
				wVal = -2;
			}
		});
		if (rVal === -2 || wVal === -2 || rVal === wVal) {
			console.log("NO");
		} else {
			console.log("YES");
			if (rVal === -1) {
                if(wVal === 1)
				    rVal = 0;
                else
                    rVal = 1;
			}
			for (let l = 0; l < n; l++) {
				let res = "";
				for (let c = 0; c < m; c++) {
					if (rVal === (c + l) % 2) {
						res += "R";
					} else {
						res += "W";
					}
				}
				console.log(res);
			}
		}
	}
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL);
    solve(lines);
});

function solve(lines){
  const t = lines[0];
  let index = 1;
  for(let i =0; i < t; i++) {
      const ij = lines[index++];
      const [ n, m ] =  ij.split(" ").map(c=>+c);
      let map = { "R": [], "W": [], ".": [] };
      for(let j = 0; j < n; j++) {
          const line = lines[index++];
          line.split("").forEach((c, k) => {
            map[c].push([(k+j)%2 ,j, k]);

          });

      }
      let rVal = -1;
      map["R"].forEach((element) => {
          if(rVal === -1) {
              rVal = element[0];
          } else if(element[0] !== rVal){
              rVal = -2;
          }
      });
      let wVal = -1;
      map["W"].forEach((element) => {
          if(wVal === -1) {
            wVal = element[0];
          } else if(element[0] !== wVal){
            wVal = -2;
          }
      });
      if(rVal === -2 || wVal === -2 || rVal === wVal) {
          console.log("NO")
      } else {
          console.log("YES");
          for(let l = 0; l < n ; l++){
              let res = "";
              for(let c = 0; c < m ; c++) {
                  if(rVal === (c+l)%2) {
                      res+="R";
                  } else {
                      res+="W";
                  }
              }
              console.log(res);
          }
      }
  }
}