Algorithm


A. Laptops
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly smaller) than the price of the second laptop but the quality of the first laptop is higher (strictly greater) than the quality of the second laptop.

Please, check the guess of Alex. You are given descriptions of n laptops. Determine whether two described above laptops exist.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of laptops.

Next n lines contain two integers each, ai and bi (1 ≤ ai, bi ≤ n), where ai is the price of the i-th laptop, and bi is the number that represents the quality of the i-th laptop (the larger the number is, the higher is the quality).

All ai are distinct. All bi are distinct.

Output

If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes).

Examples
input
Copy
2
1 2
2 1
output
Copy
Happy Alex



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int const N = 1e5 + 1;
int n;
pair<int, int> a[N];

bool cmp(pair<int, int> a, pair<int, int> b) {
  if(a.F != b.F)
    return a.F < b.F;
  if(a.S != b.S)
    return b.S > a.S;
  return true;
}

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; ++i)
    scanf("%d %d", &a[i].F, &a[i].S);
  sort(a, a + n, cmp);
  
  for(int i = 0; i < n - 1; ++i) {
    if(a[i].F < a[i + 1].F && a[i].S > a[i + 1].S) {
      puts("Happy Alex");
      return 0;
    }
  }
  puts("Poor Alex");
  
  return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2
1 2
2 1

Output

x
+
cmd
Happy Alex
Advertisements

Demonstration


Codeforces Solution-Laptops-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+