#include <iostream>                                                                                                                                                                                         
#include <cstdlib>                                                                                                                                                                                          
#include <utility> // for pair                                                                                                                                                                              
#include <vector>                                                                                                                                                                                           
using namespace std;                                                                                                                                                                                        
                                                                                                                                                                                                            
int main(){                                                                                                                                                                                                 
    int N, M;                                                                                                                                                                                               
    cin >> N >> M;                                                                                                                                                                                          
    int a[N+2];                                                                                                                                                                                             
    int b[N+2];                                                                                                                                                                                             
    int c[M+2];                                                                                                                                                                                             
    int d[M+2];                                                                                                                                                                                             
    for(int i=0;i<N;i++){                                                                                                                                                                                   
        cin >> a[i] >> b[i];                                                                                                                                                                                
    }                                                                                                                                                                                                       
    for(int i=0;i<M;i++){                                                                                                                                                                                   
        cin >> c[i] >> d[i];                                                                                                                                                                                
    }                                                                                                                                                                                                       
                                                                                                                                                                                                            
    int min_check[N+2]; // = {0};                                                                                                                                                                           
    int temp ; // how to put inf_min                                                                                                                                                                        
    int dest[N+2]; //= {0}; // how to workaounrd "variable-sized objects may not be initialized"?                                                                                                           
    for(int i=0;i<N;i++){dest[i]=0;}                                                                                                                                                                        
    for(int i=0;i<N;i++){                                                                                                                                                                                   
        for(int j=M-1;j>=0;j--){                                                                                                                                                                            
            temp = abs(a[i] - c[j]) + abs(b[i] - d[j]);                                                                                                                                                     
            if(j == M-1){                                                                                                                                                                                   
                min_check[i] = temp;                                                                                                                                                                        
                dest[i] = j+1;                                                                                                                                                                              
            }else if(temp <= min_check[i]){                                                                                                                                                                 
                min_check[i] = temp;                                                                                                                                                                        
                dest[i] = j+1;                                                                                                                                                                              
            }                                                                                                                                                                                               
        }                                                                                                                                                                                                   
    }                                                                                                                                                                                                       
                                                                                                                                                                                                            
    for(int i=0;i<N;i++){                                                                                                                                                                                   
        cout << dest[i] << endl;                                                                                                                                                                            
    }                                                                                                                                                                                                       
                                                                                                                                                                                                            
    return 0;                                                                                                                                                                                               
}    

Measured memory_bytes: 256