#include <iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<vector>
using namespace std;
 
bool compare( const pair<int,int>&i, const pair<int,int>&j)
{
 return i.first<j.first;
}
 
int main() {
	// your code goes here
	int n,m,p,i,j,x,y;
	cin>>n>>m>>p;
 
	int pa[p+1][2];
 
	vector<pair<int,int> >pos;
 
    vector<pair<int,int> > :: iterator it;
 
	for(i=0;i<p;i++)
	{
	 cin>>x>>y;
	 pos.push_back(pair<int,int>(x,y));
	}
 
	sort(pos.begin(), pos.end(), compare);
 
	i=0;
 
	for(it=pos.begin(); it!=pos.end(); it++)
	{
	 //cout<<(*it).first<<" "<<(*it).second<<endl;
	 pa[i][0]=(*it).first;
	 pa[i][1]=(*it).second;
	 i++;
	}
 
	string cnt(m+1,'0');
	string temp(m+1,'0');
 
	for(i=0;i<=m;i++)
	{
	 temp[i]=i+'0';
	 //cout<<temp[i];
	}
 
	//cout<<temp<<endl;
 
	int posi=1,ans=m-1,val;
	string final(m+1,'0'),f;
	i=0;
 
   /* for(i=0;i<p;i++)
    {
     cout<<pa[i][0]<<" "<<pa[i][1]<<endl;
    }
     cout<<"working\n";
     */
     int cnt1,cnt2;
 
     //for(i=0;i<=p;i++)
     while(posi<=n)
     {
      if(pa[i][0]!=posi)
      {
       //cout<<" string for n = "<<posi<<" is "<<cnt<<endl;
 
       cnt1= (int)cnt[1]-'0'; cnt2= (int)cnt[m]-'0'; // for finding the cnt for column 1 and m
 
       //cout<<cnt1<<" "<<cnt2<<endl;
 
       // next line increments the string by their index values
 
       transform(cnt.begin(), cnt.end(),temp.begin(), cnt.begin(), std::plus<int>());
 
              //cout<<" string for n = "<<posi<<" is "<<cnt<<endl;
 
       f=cnt; // storing in another string for sorting and then comparing with the initial one
 
       sort(f.begin(), f.end());
              //cout<<" string for n = "<<posi<<" is "<<f<<endl;
 
       if(cnt.compare(f)!=0)
       {
       ans=-1;
       }
       else
       {
        ans+=cnt2-cnt1;
       }
       cout<<ans<<endl;
       posi++;
       ans=m-1;
 
       cnt.assign(m+1,'0');
      }
      if(i<p && pa[i][0]==posi)
      {
       cnt[pa[i][1]]=(char)((int)(cnt[pa[i][1]]) + 1);
       i++;
 
      }
     }
	return 0;
} 
				I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPHN0cmluZz4KI2luY2x1ZGU8c3N0cmVhbT4KI2luY2x1ZGU8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmJvb2wgY29tcGFyZSggY29uc3QgcGFpcjxpbnQsaW50PiZpLCBjb25zdCBwYWlyPGludCxpbnQ+JmopCnsKIHJldHVybiBpLmZpcnN0PGouZmlyc3Q7Cn0KIAppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWludCBuLG0scCxpLGoseCx5OwoJY2luPj5uPj5tPj5wOwoJCglpbnQgcGFbcCsxXVsyXTsKCQoJdmVjdG9yPHBhaXI8aW50LGludD4gPnBvczsKIAogICAgdmVjdG9yPHBhaXI8aW50LGludD4gPiA6OiBpdGVyYXRvciBpdDsKCQoJZm9yKGk9MDtpPHA7aSsrKQoJewoJIGNpbj4+eD4+eTsKCSBwb3MucHVzaF9iYWNrKHBhaXI8aW50LGludD4oeCx5KSk7Cgl9CgkKCXNvcnQocG9zLmJlZ2luKCksIHBvcy5lbmQoKSwgY29tcGFyZSk7CgkKCWk9MDsKCQoJZm9yKGl0PXBvcy5iZWdpbigpOyBpdCE9cG9zLmVuZCgpOyBpdCsrKQoJewoJIC8vY291dDw8KCppdCkuZmlyc3Q8PCIgIjw8KCppdCkuc2Vjb25kPDxlbmRsOwoJIHBhW2ldWzBdPSgqaXQpLmZpcnN0OwoJIHBhW2ldWzFdPSgqaXQpLnNlY29uZDsKCSBpKys7Cgl9CgkKCXN0cmluZyBjbnQobSsxLCcwJyk7CglzdHJpbmcgdGVtcChtKzEsJzAnKTsKCQoJZm9yKGk9MDtpPD1tO2krKykKCXsKCSB0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zb3J0aW5nIGFuZCB0aGVuIGNvbXBhcmluZyB3aXRoIHRoZSBpbml0aWFsIG9uZQogICAgICAgCiAgICAgICBzb3J0KGYuYmVnaW4oKSwgZi5lbmQoKSk7CiAgICAgICAgICAgICAgLy9jb3V0PDwiIHN0cmluZyBmb3IgbiA9ICI8PHBvc2k8PCIgaXMgIjw8Zjw8ZW5kbDsKICAgICAgICAgICAgICAKICAgICAgIGlmKGNudC5jb21wYXJlKGYpIT0wKQogICAgICAgewogICAgICAgYW5zPS0xOwogICAgICAgfQogICAgICAgZWxzZQogICAgICAgewogICAgICAgIGFucys9Y250Mi1jbnQxOwogICAgICAgfQogICAgICAgY291dDw8YW5zPDxlbmRsOwogICAgICAgcG9zaSsrOwogICAgICAgYW5zPW0tMTsKICAgICAKICAgICAgIGNudC5hc3NpZ24obSsxLCcwJyk7CiAgICAgIH0KICAgICAgaWYoaTxwICYmIHBhW2ldWzBdPT1wb3NpKQogICAgICB7CiAgICAgICBjbnRbcGFbaV1bMV1dPShjaGFyKSgoaW50KShjbnRbcGFbaV1bMV1dKSArIDEpOwogICAgICAgaSsrOwogICAgICAgCiAgICAgIH0KICAgICB9CglyZXR1cm4gMDsKfSA=