//----------------------------

const int N = (int)1e5;

int n = 0, a[N];

Push( int x ) { a[n++] = x; }
int Pop()     { return a[--n]; }

//----------------------------

struct List
{
  List *next;
  int x;
};

typedef List * PList;
List *a = 0;

void Push( PList &a, int x )
{
  PList p = new List();
  *p = {a, x};
  a = *p;
}

int Pop( PList &a )
{
  int res = a->x;
  PList p = a->next;
  delete a;
  a = p; 
  return res;
}

//----------------------------