process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function main() { var n = parseInt(readLine()); var x_storage = []; var y_storage = []; for(var a0 = 0; a0 < n; a0++){ var x_temp = readLine().split(' '); var x = parseInt(x_temp[0]); var y = parseInt(x_temp[1]); if (x_storage.length === 0) { x_storage.push(x) } if (y_storage.length === 0) { y_storage.push(y) } else if (x_storage[0] === x) { x_storage.push(x) } else if (y_storage[0] === y) { y_storage.push(y) } } if (x_storage.length === n || y_storage.length === n) { console.log('YES') } else { console.log('NO') } }