#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct student
{
int num;
int score;
struct student *next;
}*head;
int main()
{
int n,m,l,nu,sc;
cin>>n>>m;
l=n+m;
head=new student;
head->next=NULL;
struct student *q,*p,*k;
p=head;
while(l--){
q=new student;
q->next=NULL;
cin>>nu>>sc;
p->num=nu;
p->score=sc;
p->next=q;
p=q;
}
k=head;
while(k->next!=NULL){
cout<<k->num<<" "<<k->score<<endl;
k=k->next;
}
return ;
}