#include <iostream>
#include <map>
#include <queue>
using namespace std;
struct point //棋子
{
int x;
int y;
};
struct node //棋盘
{
point p[4]; //四个棋子
int step; //移动步数
} st, ed;
map<__int64, int> mp;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
//判断结点p是否在棋盘范围内
int check(point p)
{
if (p.x < 0 || p.x >= 8 || p.y < 0 || p.y >= 8)
return 0;
else
return 1;
}
//计算结点now的哈希值
__int64 getHash(node now)
{
__int64 ret = 0;
for (int i = 0; i < 4; i++)
ret |= ((__int64)1) << (now.p[i].x * 8 + now.p[i].y);
return ret;
}
//广搜,记录从当前状态走四步,能到达的所有状态
//type:1表示从起始状态走四步,2表示从终止状态走四步
int BFS(int type, node now)
{
if (type == 2) //终止状态与已有状态重合
{
if (mp.find(getHash(now)) != mp.end())
return 1;
}
mp[getHash(now)] = type;
now.step = 0;
queue<node> q;
q.push(now);
while (!q.empty())
{
now = q.front();
q.pop();
if (now.step >= 4)
continue;
int i, j, k;
node next;
for (i = 0; i < 4; i++) //遍历四个方向
{
for (j = 0; j < 4; j++) //遍历四个棋子
{
next = now;
next.step++;
next.p[j].x += dx[i];
next.p[j].y += dy[i];
if (!check(next.p[j]))
continue;
__int64 temp = getHash(next);
for (k = 0; k < 4; k++) //判断是否和其他棋子重合
{
if (k == j)
continue;
if (next.p[j].x == next.p[k].x && next.p[j].y == next.p[k].y)
break;
}
if (k == 4) //不重合
{
if (mp.find(temp) == mp.end()) //该棋盘状态未出现过
{
mp[temp] = type;
q.push(next);
}
else if (mp[temp] != type)
return 1;
}
else //重合
{
//向相同方向再走一步
next.p[j].x += dx[i];
next.p[j].y += dy[i];
temp = getHash(next);
if (!check(next.p[j]))
continue;
for (k = 0; k < 4; k++)
{
if (k == j)
continue;
if (next.p[j].x == next.p[k].x && next.p[j].y == next.p[k].y)
break;
}
if (k < 4)
continue;
if (mp.find(temp) == mp.end())
{
mp[temp] = type;
q.push(next);
}
else if (mp[temp] != type)
return 1;
}
}
}
}
return 0;
}
int main()
{
while (cin >> st.p[0].x >> st.p[0].y)
{
for (int i = 1; i < 4; i++)
cin >> st.p[i].x >> st.p[i].y;
for (int i = 0; i < 4; i++)
cin >> ed.p[i].x >> ed.p[i].y;
for (int i = 0; i < 4; i++)
{
st.p[i].x--;
st.p[i].y--;
ed.p[i].x--;
ed.p[i].y--;
}
mp.clear();
BFS(1, st); //起始状态走四步,记录所有情况(哈希值)
int flag = BFS(2, ed); //终止状态走四步,是否能和已有状态重合
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}