#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
LL gcd(LL a, LL b)
{
while(a)
swap(a, b%=a);
return b;
}
class ConvexPolygonGame { public:
string winner(vector <int> X, vector <int> Y)
{
return has_int_triangle(X, Y) ? "Masha" : "Petya";
}
bool has_int_triangle(const vector<int>& X, const vector<int>& Y)
{
const int xm = *min_element(X.begin(), X.end());
const int xM = *max_element(X.begin(), X.end());
vector< pair<int,int> > p;
int nc = 0, two = 0, dis = 0;
for(int x=xm; x<=xM; ++x)
{
int ym, yM;
tie(ym, yM) = y_range(x, X, Y);
if(ym <= yM) {
dis ++;
nc += (yM - ym + 1);
if(yM-ym+1 >= 2)
two ++;
else
p.emplace_back(x, ym);
}
// cerr << nc << "," << two << " : " << x << " " << ym << " ~ " << yM << endl;
if(nc>=3 && two>=1 && dis>=2)
return true;
}
if(nc>=3 && two==0 && dis>=2)
{
double am, aM;
for(int i=1; i<p.size(); ++i)
{
double a = double(p[i].second - p[0].second) / (p[i].first - p[0].first);
if(i==1)am=aM=a;
else am=min(am, a), aM=max(aM,a);
}
return (aM-am) > 1e-9;
}
return false;
}
tuple<int,int> y_range(int x, const vector<int>& X, const vector<int>& Y)
{
vector< pair<LL,LL> > cross;
vector< pair<LL,LL> > exact;
const int N = X.size();
for(int i=0; i<N; ++i)
{
int x1=X[i], x2=X[(i+1)%N];
int y1=Y[i], y2=Y[(i+1)%N];
if(x1 > x2)
swap(x1, x2), swap(y1, y2);
if(x1 == x2)
{
if(x == x1) {
cross.emplace_back(y1,1);
cross.emplace_back(y2,1);
exact.emplace_back(y1,1);
exact.emplace_back(y2,1);
}
}
else
{
if(x<x1 || x2<x)
continue;
LL q = LL(y2-y1)*(x-x1) + LL(y1)*(x2-x1);
LL d = LL(x2-x1);
LL g = gcd(abs(q), d);
cross.emplace_back(q/g, d/g);
if(x==x1 || x==x2)
exact.emplace_back(q/g, d/g);
}
}
sort(cross.begin(), cross.end());
cross.erase(unique(cross.begin(), cross.end()), cross.end());
if(cross.size() == 2) {
LL q1 = cross[0].first;
LL d1 = cross[0].second;
LL q2 = cross[1].first;
LL d2 = cross[1].second;
if(q1*d2 > q2*d1)
swap(q1,q2), swap(d1,d2);
int ym = ceil_div(q1, d1);
int yM = floor_div(q2, d2);
bool ym_exact = false, yM_exact = false;
for(int i=0; i<exact.size(); ++i) {
if(ym*exact[i].second == exact[i].first)
ym_exact = true;
if(yM*exact[i].second == exact[i].first)
yM_exact = true;
}
return make_tuple(ym_exact ? ym+1 : ym, yM_exact ? yM-1 : yM);
}
return make_tuple(-9998, -9999);
}
static int floor_div(LL a, LL b)
{
if(a>=0) return int(a/b);
return int(-((-a+b-1)/b));
}
static int ceil_div(LL a, LL b)
{
if(a>=0) return int((a+b-1)/b);
return int(-((-a)/b));
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, ConvexPolygonGame().winner(X, Y));}
int main(){
CASE(0)
int X_[] = {0, 1, 0};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, 0, 1};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Petya";
END
CASE(1)
int X_[] = {0, 4, 2};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, 0, 2};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Masha";
END
CASE(2)
int X_[] = {0, 100, 100, 0};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, 0, 100, 100};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Masha";
END
CASE(3)
int X_[] = {0, 50, 100, 50};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, -1, 0, 1};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Petya";
END
CASE(4)
int X_[] = {-100000, 100000, 100000, -100000};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {-1, -1, 1, 1};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Masha";
END
CASE(5)
// 1 1 1 (yoko)
int X_[] = {0, 3, 5, 3};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, 0, 1, 1};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Masha";
END
CASE(5)
// 1 1 1 (tate)
int X_[] = {0, 1, 1, 0};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, 3, 5, 3};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Masha";
END
CASE(6)
// 3 (tate) // yoko ha sample
int X_[] = {-1, 0, 1, 0};
vector <int> X(X_, X_+sizeof(X_)/sizeof(*X_));
int Y_[] = {0, -2, 0, 2};
vector <int> Y(Y_, Y_+sizeof(Y_)/sizeof(*Y_));
string _ = "Petya";
END
}
// END CUT HERE