Quality of Life Index
Time limit1sMemory limit1024 MB
Given countries with three indicators and pairwise ranking requirements, decide whether non-negative weights exist that make every requirement hold strictly.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
Consider the indices used to rank countries, such as the Human Development Index, the Democracy Index, the Freedom Index, and the Happiness Index.
These indices usually work as follows. For each country, statistical indicators are collected, for example life expectancy, average years of schooling, and gross domestic product. Each indicator is given a weight . The index value of a country is , and countries are ranked by this value.
Such indices are often criticized for arbitrary weights. The person who builds an index may choose weights that produce the ranking they want.
You are given countries, each with three indicators. You are also given requirements. Each requirement says that country must rank above country , meaning the value of country must be strictly greater than the value of country . Determine whether there exist non-negative real weights that satisfy all requirements.
Input
The first line contains the number of tests ().
The first line of each test contains the number of countries () and the number of requirements ().
Each of the next lines contains three integers , , and (, , ), the statistics of one country. Countries are numbered to in the order they appear in the input.
Each of the next lines contains two distinct integers and (, , ), meaning country must rank above country .
The sum of over all tests is at most . The sum of over all tests is also at most .
Output
For each test, print on its own line JAH if there exist weights that make the ranking satisfy all requirements, or EI if no such weights exist.