using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ int H = Gy+1; int W = Gx+1; int[][] dp = new int[H][]; int Inf = (int)1e9; for(int i=0;i=0;i--){ for(int j=W-1;j>=0;j--){ if(dp[i][j] == Inf) continue; int ny = i + Y[k]; int nx = j + X[k]; int nc = dp[i][j] + C[k]; if(InRange(ny,0,H) && InRange(nx,0,W)){ dp[ny][nx] = Math.Min(dp[ny][nx],nc); } } } //for(int i=0;iint.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }