You are given a special jigsaw puzzle consisting of n⋅mn⋅m identical pieces. Every piece has three tabs and one blank, as pictured below.

The jigsaw puzzle is considered solved if the following conditions hold:

The pieces are arranged into a grid with nn rows and mm columns.
For any two pieces that share an edge in the grid, a tab of one piece fits perfectly into a blank of the other piece.
Through rotation and translation of the pieces, determine if it is possible to solve the jigsaw puzzle.

Input

The test consists of multiple test cases. The first line contains a single integer tt (1≤t≤10001≤t≤1000) — the number of test cases. Next tt lines contain descriptions of test cases.

Each test case contains two integers nn and mm (1≤n,m≤1051≤n,m≤105).

Output

For each test case output a single line containing “YES” if it is possible to solve the jigsaw puzzle, or “NO” otherwise. You can print each letter in any case (upper or lower).

Sample Input

3
1 3
100000 100000
2 2

Sample Output

YES
NO
YES

Note

For the first test case, this is an example solution:

For the second test case, we can show that no solution exists.

For the third test case, this is an example solution:

题目大意:

问是否可以将拼图拼成n*m的矩形

解题思路:

①只有一排时,长度是任意的
②当排列为 2*2 时, 8个角都是向外凸起的,此时不能再放拼图

代码如下:

#include<iostream>
#include<algorithm>
#include<cstdio>using namespace std;int main()
{int t,n,m;scanf("%d",&t);while(t--){scanf("%d %d",&n,&m);if(n==1||m==1||(n==2&&m==2)) printf("YES\n");else printf("NO\n");}return 0;
}

Puzzle Pieces相关推荐

  1. 【37.50%】【codeforces 745B】Hongcow Solves A Puzzle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【CodeForces - 745B】Hongcow Solves A Puzzle (思维,乱搞,字符串)

    题干: Hongcow likes solving puzzles. One day, Hongcow finds two identical puzzle pieces, with the inst ...

  3. 数据仓库专题(23):总线矩阵的另类应用-Drill Down into a More Detailed Bus Matrix

    一.前言 Many of you are already familiar with the data warehouse bus architecture and matrix given thei ...

  4. 桌面图标摆放图案_用图标制作醒目的图案

    桌面图标摆放图案 Level up your video calls with a custom backdrop created using Noun Project icons. 使用使用Noun ...

  5. (9)How to take a picture of a black hole

    https://www.ted.com/talks/katie_bouman_what_does_a_black_hole_look_like/transcript 00:13 In the movi ...

  6. hypixel服务器免费低延迟ip,国服hypixel服务器ip

    [详情] The size of the downloaded application is huge, but it's worth it. Sudoku puzzles free has a gr ...

  7. flash拼图游戏源码_在Flash中构建视频拼图游戏

    flash拼图游戏源码 Suppose you could convince your visitors to give their undivided attention to your compa ...

  8. xshell 密钥身份验证_使用密钥斗篷和大使边缘堆栈进行集中式身份验证

    xshell 密钥身份验证 Keycloak is a widely adopted Identity and Access Management (IAM for short) open-sourc ...

  9. hypixel服务器注册,hypixel服务器

    [详情] The size of the downloaded application is huge, but it's worth it. Sudoku puzzles free has a gr ...

最新文章

  1. ADO.NET复习——自己编写SqlHelper类
  2. HDU_2065 红色病毒问题(指数型生成函数)
  3. 笔记本8G+256G固态免费送,吃鸡不吃力,包邮!
  4. ExtJs Grid分页时序号自增的实现,以及查询以后的序号的处理
  5. 太厉害了!2021年互联网大厂Java笔经
  6. 简单的对象定位与登录实例的简单操作
  7. ios信号从4g变成无服务器,苹果信号满格显示是4g却没网络
  8. wsimport命令
  9. 1196踩方格—递推方法!
  10. 二手华为p40手机现在多少钱
  11. 机器学习两种参数估计方法:最大似然估计和最小二乘法估计
  12. BootLoader这个玩意
  13. WAF(网络应用防火墙)是什么
  14. python语言中有哪些函数_Python语言中的函数
  15. Promise请求并发
  16. python中双向索引_Python 字典支持双向索引。Python 集合也支持双向索引
  17. 计算机考研817,2017年南京工业大学计算机科学与技术学院817信号系统与数字电路考研题库...
  18. 军犬舆情热点:诺贝尔颁奖盛典在瑞典举行;多款iPhone禁止销售
  19. 天梯赛练习集 L2-021 点赞狂魔(25分)含测试点解析
  20. 为什么房子要坐南朝北,用地理的知识解释一下

热门文章

  1. nn.Sequential nn.ModuleList
  2. Thinkphp 树形菜单(基于zTree)简单好用
  3. 深蓝主题七夕表白你PPT模板
  4. 利用计算机犯罪的例子,真实的计算机犯罪的案例
  5. mac 显示信任任何来源选项
  6. Android-设置PullToRefresh下拉刷新样式
  7. 基础设施建设推动 Web3 未来
  8. 声网 agora php sdk,快速了解声网Agora SDK 3.0
  9. EasyCVR对接华为eSDK IVS,1400查询采集系统列表和详细信息
  10. 数字图像处理之直方图均衡化(python)