#include <bits/stdc++.h>
using namespace std;
double dis[1005][1005];
map< pair< int, int >, int > m;
int N, M, K;
double min( double a, double b ){
if( a < b )
return a;
return b;
}
int main(){
cin >> M >> N;
cin >> K;
dis[0][0]= 0;
for( int i= 1; i<= N; ++i )
dis[i][0]= 100*i;
for( int j= 1; j<= M; ++j )
dis[0][j]= 100*j;
for( int i= 0, x,y; i< K; ++i ){
scanf( "%d%d", &x, &y );
m[{y,x}]++;
}
double shortcut= sqrt(20000);
for( int i= 1; i<= N; ++i )
for( int j= 1; j<= M; ++j ){
//cout << i << " " << j << "\n\t";
if( m[{i,j}] > 0 ){
//cout << dis[i-1][j-1] + sqrt(20000) << " " << dis[i-1][j] + 100 << " " << dis[i][j-1] + 100 << endl ;
dis[i][j]= min( dis[i-1][j-1] + shortcut , min( dis[i-1][j] , dis[i][j-1] ) + 100 ) ;
m[{i,j}]--;
}else{
//cout << dis[i-1][j]+100 << " " << dis[i][j-1] << endl;
dis[i][j]= min( dis[i-1][j], dis[i][j-1] ) + 100;
}
}
//for( int i =0; i<= N; ++i )
// for( int j= 0; j<= M; ++j )
// cout << dis[i][j] << " \n"[j== M];
cout << ceil(dis[N][M]) << endl;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKZG91YmxlIGRpc1sxMDA1XVsxMDA1XTsKCm1hcDwgcGFpcjwgaW50LCBpbnQgPiwgaW50ID4gbTsKCmludCBOLCBNLCBLOwoKZG91YmxlIG1pbiggZG91YmxlIGEsIGRvdWJsZSBiICl7CgoJaWYoIGEgPCBiICkKCQlyZXR1cm4gYTsKCglyZXR1cm4gYjsKfQoKaW50IG1haW4oKXsKCgljaW4gPj4gTSA+PiBOOwoKCWNpbiA+PiBLOwoKCWRpc1swXVswXT0gMDsKCglmb3IoIGludCBpPSAxOyBpPD0gTjsgKytpICkKCQlkaXNbaV1bMF09IDEwMCppOwoKCWZvciggaW50IGo9IDE7IGo8PSBNOyArK2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