#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std; 
int N;
vector<int> graph[103];
bool vis[103];
void DFS(int depth){
    vis[depth] = true;
    for(int i=0;i<graph[depth].size();i++)
    {
        int next = graph[depth][i];
        if(vis[next]) continue;
        DFS(next);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        fill(vis, vis+103, false);
        for(int i=0;i<103;i++)
            graph[i].clear(); 
        vector<pair<int,int>> tmp;
        cin >> N;
        for(int i=0;i<N+2;i++)
        {
            int y,x;
            cin >> y >> x;
            tmp.push_back({y,x});
        }
        for(int i=0;i<N+1;i++)
        {
            for(int j=i+1;j<N+2;j++)
            {
                if(abs(tmp[i].first-tmp[j].first)+abs(tmp[i].second-tmp[j].second) <= 50*20)
                {
                    graph[i].push_back(j);
                    graph[j].push_back(i); 
                }
            }
        }
        DFS(0);
        if(vis[N+1])
            cout << "happy"<<'\n';
        else
            cout << "sad" << '\n';
    }
    return 0;
}
- 핵심
- 각 정점끼리 이동할 수 있는 조건은 맥주 
20개로 즉, 1000미터 안에 있는 점이라는 것 
- 조건에 따라 연결된 간선을 
양방향으로 넣어두고 출발지 ~ 도착지까지 연결되어 있는지 검사 
 
- 깨달은 것
다익스트라 / 벨만포드 / 플로이드 워셜 등이 어떨 때 쓰이는지 정리할 수 있었음 
vector.clear()를 통해서 size를 0으로 만들 수 있음 --> push_back 가능
(단, capacity는 그대로라서 메모리적으로 효율을 가질수는 없음, 사용에 이점만 가능)