while true
    a,b = gets.split.map{|x| x.to_i}
    exit if [a,b].uniq==[0]
    n = gets.to_i

    kouji = []
    n.times do kouji << gets.split.map{|x| x.to_i-1} end


    map=[]
    a.times do map << Array.new(b,nil) end
    kouji.each do |k| map[k[0]][k[1]] = 0 end

    map[0][0]=1
    a.times do |x|
        b.times do |y|
            (map[x][y] = map[x-1][y]; next) if (y==0)&&(map[x][y]==nil)
            (map[x][y] = map[x][y-1]; next) if (x==0)&&(map[x][y]==nil)
            map[x][y] = map[x-1][y] + map[x][y-1] if map[x][y]==nil
        end
    end

    puts map[a-1][b-1]

end