//***只要你 目光是瞄准月亮 迷失过 又有何妨***//
#include<bits/stdc++.h>
using namespace std;
int n,m,t;
int op,idx;
void solve()
{
    cin>>n>>m>>t;
    map<int,int>mp1;
    map<int,int>mp2;
    for (int i=1;i<=t;i++)
    {
        cin>>op>>idx;
        if (op==1)
        {
            mp1[idx]=i;
        }
        else
        {
            mp2[idx]=i;
        }
    }
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            int ans=max(mp1[i],mp2[j]);
            cout<<ans<<" ";
        }
        cout<<'\n';
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}