#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ipc.h> 
#include <sys/shm.h> 
#include <sys/mman.h>
#include <pthread.h>


#define max      304        // max means total number of locations
#define true     1
#define false    0
#define infinity 10000      // infinity means no way

// video display
#define SDRAM_BASE            0xC0000000
#define SDRAM_END             0xC3FFFFFF
#define SDRAM_SPAN	          0x04000000
// characters
#define FPGA_CHAR_BASE        0xC9000000 
#define FPGA_CHAR_END         0xC9001FFF
#define FPGA_CHAR_SPAN        0x00002000
/* Cyclone V FPGA devices */
#define HW_REGS_BASE          0xff200000
#define HW_REGS_SPAN          0x00005000 
#define HW_REGS_MASK          0x00004fff

#define CLK_HPS_PIO_BASE          0x00
#define RESET_PIO_BASE            0x10
#define START_PIO_BASE            0x20
#define STATE_PIO_BASE            0x30
#define TRANS_COUNT_PIO_BASE      0x40
#define NEIGHBOR_OUT_PIO_BASE     0x50
#define DISTANCE_OUT_PIO_BASE     0x60

// mouse
#define MOVE_STEP 1

// 16-bit primary colors
#define red  (0+(0<<5)+(31<<11))
#define dark_red (0+(0<<5)+(15<<11))
#define green (0+(63<<5)+(0<<11))
#define dark_green (0+(31<<5)+(0<<11))
#define blue (31+(0<<5)+(0<<11))
#define dark_blue (15+(0<<5)+(0<<11))
#define yellow (0+(63<<5)+(31<<11))
#define cyan (31+(63<<5)+(0<<11))
#define magenta (31+(0<<5)+(31<<11))
#define black (0x0000)
#define gray (15+(31<<5)+(51<<11))
#define white (0xffff)
int colors[] = {red, dark_red, green, dark_green, blue, dark_blue, yellow, cyan, magenta, gray, black, white};

// pixel macro
#define VGA_PIXEL(x,y,color) do{\
	int  *pixel_ptr ;\
	pixel_ptr = (int*)((char *)vga_pixel_ptr + (((y)*640+(x))<<1)) ; \
	*(short *)pixel_ptr = (color);\
} while(0)

// the light weight bus base
void *h2p_lw_virtual_base;

// pixel buffer
volatile unsigned int * vga_pixel_ptr = NULL ;
void *vga_pixel_virtual_base;

// character buffer
volatile unsigned int * vga_char_ptr = NULL ;
void *vga_char_virtual_base;

// /dev/mem file id
int fd;
// shared memory 
key_t mem_key=0xf0;

typedef struct {
   unsigned short int type;         /* Image type identifier   */
   unsigned int size;               /* File size in bytes  */
   unsigned short int reserved1;
   unsigned short int reserved2;
   unsigned int offset;             /* Offset to image data, bytes */
} HEADER;


typedef struct {
   unsigned int size;               /* Header size in bytes      */
   int width;
   int height;                      /* Width and height of image */
   unsigned short int planes;       /* Number of colour planes   */
   unsigned short int bits;         /* Bits per pixel            */
   unsigned int compression;        /* Compression type          */
   unsigned int imagesize;          /* Image size in bytes       */
   int xresolution;
   int yresolution;                 /* Pixels per meter          */
   unsigned int ncolours;           /* Number of colours         */
   unsigned int importantcolours;   /* Important colours         */
} INFOHEADER;

typedef struct {
   unsigned char r,g,b,junk;
} COLOURINDEX;


int distance[max];
int map[max][max];
int shortest[max];
int neighbor[max];

int x_coord[max];
int y_coord[max];

struct timeval t1, t2;     
double elapsedTime;

int stop_or_resume = 0;

int temp = 78;  // default start location and destination

////////////////////////////////////////////////////////////////
// Declaration
////////////////////////////////////////////////////////////////

int map_display(int,char **);
int ReadUShort(FILE *,unsigned short *,int);
int ReadUInt(FILE *,unsigned int *,int);
void min_path(int,int);
void delay();
int keyboard();
void number2name(int);
void *Mouse();
int VGA_read_pixel(int,int);
void Cursor(int,int,short); 

// graphics primitives
void VGA_text (int, int, char *);
void VGA_text_clear();
void VGA_box (int, int, int, int, short);
void VGA_rect (int, int, int, int, short);
void VGA_line(int, int, int, int, short) ;
void VGA_Vline(int, int, int, short) ;
void VGA_Hline(int, int, int, short) ;
void VGA_disc (int, int, int, short);
void VGA_circle (int, int, int, int);

////////////////////////////////////////////////////////////////
// Pthread
//////////////////////////////////////////////////////////////// 

pthread_t final_thread;

pthread_mutex_t stop_or_resume_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t temp_lock = PTHREAD_MUTEX_INITIALIZER;


////////////////////////////////////////////////////////////////
// main function
////////////////////////////////////////////////////////////////

int main(int argc,char **argv)
{
  // === get FPGA addresses ==================
 
  // Open /dev/mem
  if( ( fd = open( "/dev/mem", ( O_RDWR | O_SYNC ) ) ) == -1 ) 	{
	printf( "ERROR: could not open \"/dev/mem\"...\n" );
	return( 1 );
  }
    
  // get virtual addr that maps to physical
  h2p_lw_virtual_base = mmap( NULL, HW_REGS_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd, HW_REGS_BASE );	
  if( h2p_lw_virtual_base == MAP_FAILED ) {
      printf( "ERROR: mmap1() failed...\n" );
      close( fd );
      return(1);
  }

  // === get VGA char addr =====================
  // get virtual addr that maps to physical
  vga_char_virtual_base = mmap( NULL, FPGA_CHAR_SPAN, ( 	PROT_READ | PROT_WRITE ), MAP_SHARED, fd, FPGA_CHAR_BASE );	
  if( vga_char_virtual_base == MAP_FAILED ) {
      printf( "ERROR: mmap2() failed...\n" );
      close( fd );
      return(1);
  }

  // Get the address that maps to the FPGA LED control 
  vga_char_ptr =(unsigned int *)(vga_char_virtual_base);

  // === get VGA pixel addr ====================
  // get virtual addr that maps to physical
  vga_pixel_virtual_base = mmap( NULL, SDRAM_SPAN, ( PROT_READ | PROT_WRITE ), MAP_SHARED, fd, SDRAM_BASE);	
  if( vga_pixel_virtual_base == MAP_FAILED ) {
      printf( "ERROR: mmap3() failed...\n" );
      close( fd );
      return(1);
  }

  // Get the address that maps to the FPGA pixel buffer
  vga_pixel_ptr =(unsigned int *)(vga_pixel_virtual_base);


  // ========================
  // WE ADDED
  // ========================

  volatile signed int   *h2p_lw_clk_HPS_addr = NULL;
  volatile signed int   *h2p_lw_reset_addr = NULL;
  volatile signed int   *h2p_lw_start_addr = NULL;
  volatile signed int   *p2h_lw_state_addr = NULL;
  volatile signed int   *h2p_lw_trans_count_addr = NULL;
  volatile signed int   *p2h_lw_neighbor_out_addr = NULL;
  volatile signed int   *p2h_lw_distance_out_addr = NULL;  


	h2p_lw_clk_HPS_addr=(signed int *)(h2p_lw_virtual_base + (( CLK_HPS_PIO_BASE)& (HW_REGS_MASK)));

	h2p_lw_reset_addr=(signed int *)(h2p_lw_virtual_base + (( RESET_PIO_BASE)& (HW_REGS_MASK)));   

  h2p_lw_start_addr=(signed int *)(h2p_lw_virtual_base + (( START_PIO_BASE)& (HW_REGS_MASK)));

	p2h_lw_state_addr=(signed int *)(h2p_lw_virtual_base + (( STATE_PIO_BASE)& (HW_REGS_MASK)));  

  h2p_lw_trans_count_addr=(signed int *)(h2p_lw_virtual_base + (( TRANS_COUNT_PIO_BASE)& (HW_REGS_MASK)));

	p2h_lw_neighbor_out_addr=(signed int *)(h2p_lw_virtual_base + (( NEIGHBOR_OUT_PIO_BASE)& (HW_REGS_MASK)));   
 
  p2h_lw_distance_out_addr=(signed int *)(h2p_lw_virtual_base + (( DISTANCE_OUT_PIO_BASE)& (HW_REGS_MASK)));   


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  // coordinate initializaiton
  FILE* FP = 0;
  FP = fopen("coordinate.txt","r");
    
  int i;
    
  for(i=0; i<max; i++)
    {
      fscanf(FP, "%d", &x_coord[i]);
      fscanf(FP, "%d", &y_coord[i]);
    }

  pthread_create(&final_thread, NULL, &Mouse, NULL);

  // clear the screen
	VGA_box (0, 0, 639, 479, 0x0000);
  // clear the text
	VGA_text_clear();
 
  // map display
  map_display(argc,argv);
  
  // Button GO!
  VGA_disc (50, 430, 10, dark_green);

  while(1) {
  
  int start;               // start means the start location

  printf("\nstart location:\n");
  start = keyboard();
  
  while(stop_or_resume == 1)
  { start = temp;
    delay(); 
  }
  
  VGA_disc(x_coord[start], y_coord[start], 2, blue);
    
  *h2p_lw_start_addr = start;

  int dest;                // dest  means the destination

  printf("\ndestination:\n");
  dest = keyboard(); 
  
  while(stop_or_resume == 1)
  { dest = temp;
    delay(); 
  } 
  
  VGA_disc(x_coord[dest], y_coord[dest], 2, green); 
 
  
  *h2p_lw_clk_HPS_addr = 0;
  *h2p_lw_trans_count_addr = 0;
  
  *h2p_lw_reset_addr = 0;

  // clear the screen
	VGA_box (0, 0, 639, 479, 0x0000);
  // clear the text
	VGA_text_clear();
 
  // map display
  map_display(argc,argv);
  // Button GO!
  VGA_disc (50, 430, 10, dark_green);
  
  VGA_disc(x_coord[start], y_coord[start], 2, blue);
  VGA_disc(x_coord[dest], y_coord[dest], 2, green); 
  
  // Dijkstra Module on FPGA set

  *h2p_lw_reset_addr = 1;
  
 // start timer

  gettimeofday(&t1, NULL); 
  
  while( *p2h_lw_state_addr != 7)
       { delay(); };

  // stop timer

  gettimeofday(&t2, NULL); 

  // calculate the time 

  elapsedTime =  (t2.tv_sec  - t1.tv_sec)  * 1000.0;   // sec to ms
  elapsedTime =  (t2.tv_usec - t1.tv_usec) / 1000.0;   // us  to ms

  // display the time

  printf("\nT = %7.5f mSec\n\n", elapsedTime);
  
  while( *h2p_lw_trans_count_addr <= 303 )
    {
      *h2p_lw_clk_HPS_addr = 1;
       delay();
       neighbor[*h2p_lw_trans_count_addr] = *p2h_lw_neighbor_out_addr;
       distance[*h2p_lw_trans_count_addr] = *p2h_lw_distance_out_addr;
      *h2p_lw_trans_count_addr = *h2p_lw_trans_count_addr + 1;
      *h2p_lw_clk_HPS_addr = 0;  
       delay(); 
    } 
  
  // display the shortest distance between start location and destination 

  printf("shortest distance is: %d\n\n", distance[dest]);

  // display the shortest route between start location and destination

  printf("shortest route is:\n\n");
  min_path(start,dest);
  number2name(dest);
  printf("\n\n");
}
  return 0;
}

////////////////////////////////////////////////////////////////
// Mouse
////////////////////////////////////////////////////////////////

void *Mouse()
{
  // params for mouse input
	unsigned char data[3];
	int left_click=0, middle_click=0, right_click=0;
	signed char x=0, y=0;

	int x_cood=0,y_cood=0;
	
	// variables for mouse signals
  int fd1, bytes=-1;
  // Open Mouse
  const char *pDevice = "/dev/input/mice";
  fd1 = open(pDevice, O_RDWR);
  if(fd1 == -1)
  {
	  printf("ERROR Opening %s\n", pDevice);
  }
	
	// mouse cursor relative
	int color_sol[9] = {0,0,0,0,0,0,0,0,0};
	
	// detecting mousing changes 
	int clickflag = 0;
 
 	while(1){
  
  		// Read Mouse     
    	bytes = read(fd1, data, sizeof(data));
    	if(bytes < 0){
    		continue;
    	}

    	if(bytes > 0)
    		{
      		left_click = data[0] & 0x1;
      		right_click = data[0] & 0x2;
      		middle_click = data[0] & 0x4;

      		x = data[1];	
      		y = data[2];
			
			if(x!=0 || y!=0){
				
				VGA_PIXEL(x_cood,y_cood,color_sol[0]);
				VGA_PIXEL(x_cood-1,y_cood,color_sol[1]);
				VGA_PIXEL(x_cood-2,y_cood,color_sol[2]);
				VGA_PIXEL(x_cood+1,y_cood,color_sol[3]);
				VGA_PIXEL(x_cood+2,y_cood,color_sol[4]);
				VGA_PIXEL(x_cood,y_cood-1,color_sol[5]);
				VGA_PIXEL(x_cood,y_cood-2,color_sol[6]);
				VGA_PIXEL(x_cood,y_cood+1,color_sol[7]);
				VGA_PIXEL(x_cood,y_cood+2,color_sol[8]);

				x_cood = x_cood + x;
				y_cood = y_cood - y;
        
  		  if(x_cood>640){
				  x_cood = 640;
			  }
			  if(x_cood< 0){
				  x_cood = 0;
			  }
			  if(y_cood>480){
				  y_cood = 480;
			  }
			  if(y_cood<0){
				  y_cood = 0;
		  	}

				color_sol[0] = VGA_read_pixel(x_cood,y_cood);
				color_sol[1] = VGA_read_pixel(x_cood-1,y_cood);
				color_sol[2] = VGA_read_pixel(x_cood-2,y_cood);
				color_sol[3] = VGA_read_pixel(x_cood+1,y_cood);
				color_sol[4] = VGA_read_pixel(x_cood+2,y_cood);
				color_sol[5] = VGA_read_pixel(x_cood,y_cood-1);
				color_sol[6] = VGA_read_pixel(x_cood,y_cood-2);
				color_sol[7] = VGA_read_pixel(x_cood,y_cood+1);
				color_sol[8] = VGA_read_pixel(x_cood,y_cood+2);

                Cursor(x_cood, y_cood, blue);
				
				//printf("x=%d, y=%d\n", x_cood, y_cood);
			
			}
							
			if(left_click==1 && clickflag==0 && stop_or_resume == 1){
        
                if (40 < x_cood && x_cood < 60 && 420 < y_cood && y_cood < 440) {
				    printf("Go!\n"); pthread_mutex_lock(&stop_or_resume_lock); stop_or_resume = 0; pthread_mutex_unlock(&stop_or_resume_lock);                        
					clickflag = 1;} 
					
   			    if (517 < x_cood && x_cood < 525 && 34 < y_cood && y_cood < 42) {
	                printf("Gulian\n"); pthread_mutex_lock(&temp_lock); temp = 0; pthread_mutex_unlock(&temp_lock);
	                Cursor(x_cood,y_cood,red); clickflag = 1;}

                if (527 < x_cood && x_cood < 535 && 40 < y_cood && y_cood < 48) {
                	printf("Tahe\n"); pthread_mutex_lock(&temp_lock); temp = 1; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (527 < x_cood && x_cood < 535 && 50 < y_cood && y_cood < 58) {
                	printf("Jiagedaqi\n"); pthread_mutex_lock(&temp_lock); temp = 2; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}

                if (514 < x_cood && x_cood < 522 && 50 < y_cood && y_cood < 58) {
                	printf("Yitulihe\n"); pthread_mutex_lock(&temp_lock); temp = 3; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (537 < x_cood && x_cood < 545 && 60 < y_cood && y_cood < 68) {
                	printf("Nenjiang\n"); pthread_mutex_lock(&temp_lock); temp = 4; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (537 < x_cood && x_cood < 545 && 66 < y_cood && y_cood < 74) {
                	printf("Nehe\n"); pthread_mutex_lock(&temp_lock); temp = 5; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (514 < x_cood && x_cood < 522 && 42 < y_cood && y_cood < 50) {
                	printf("Mangui\n"); pthread_mutex_lock(&temp_lock); temp = 6; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (514 < x_cood && x_cood < 522 && 62 < y_cood && y_cood < 70) {
                	printf("Yakeshi\n"); pthread_mutex_lock(&temp_lock); temp = 7; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (503 < x_cood && x_cood < 511 && 62 < y_cood && y_cood < 70) {
                	printf("Hailaer\n"); pthread_mutex_lock(&temp_lock); temp = 8; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (499 < x_cood && x_cood < 507 && 67 < y_cood && y_cood < 75) {
                	printf("Yimin\n"); pthread_mutex_lock(&temp_lock); temp = 9; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (477 < x_cood && x_cood < 485 && 62 < y_cood && y_cood < 70) {
                	printf("Manzhouli\n"); pthread_mutex_lock(&temp_lock); temp = 10; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (519 < x_cood && x_cood < 527 && 67 < y_cood && y_cood < 75) {
                	printf("Boketu\n"); pthread_mutex_lock(&temp_lock); temp = 11; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (509 < x_cood && x_cood < 517 && 73 < y_cood && y_cood < 81) {
                	printf("Taerqi\n"); pthread_mutex_lock(&temp_lock); temp = 12; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (530 < x_cood && x_cood < 538 && 78 < y_cood && y_cood < 86) {
                	printf("Qiqihaer\n"); pthread_mutex_lock(&temp_lock); temp = 13; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (537 < x_cood && x_cood < 545 && 72 < y_cood && y_cood < 80) {
                	printf("Fuyu\n"); pthread_mutex_lock(&temp_lock); temp = 14; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (556 < x_cood && x_cood < 564 && 65 < y_cood && y_cood < 73) {
                	printf("Beian\n"); pthread_mutex_lock(&temp_lock); temp = 15; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (556 < x_cood && x_cood < 564 && 51 < y_cood && y_cood < 59) {
                	printf("Heihe\n"); pthread_mutex_lock(&temp_lock); temp = 16; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (567 < x_cood && x_cood < 575 && 76 < y_cood && y_cood < 84) {
                	printf("Suihua\n"); pthread_mutex_lock(&temp_lock); temp = 17; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (576 < x_cood && x_cood < 584 && 76 < y_cood && y_cood < 84) {
                	printf("Nancha\n"); pthread_mutex_lock(&temp_lock); temp = 18; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (576 < x_cood && x_cood < 584 && 60 < y_cood && y_cood < 68) {
                	printf("Wuyiling\n"); pthread_mutex_lock(&temp_lock); temp = 19; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (593 < x_cood && x_cood < 601 && 76 < y_cood && y_cood < 84) {
                	printf("Jiamusi\n"); pthread_mutex_lock(&temp_lock); temp = 20; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (583 < x_cood && x_cood < 591 && 66 < y_cood && y_cood < 74) {
                	printf("Hebei\n"); pthread_mutex_lock(&temp_lock); temp = 21; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (599 < x_cood && x_cood < 607 && 69 < y_cood && y_cood < 77) {
                	printf("Qianjin\n"); pthread_mutex_lock(&temp_lock); temp = 22; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (601 < x_cood && x_cood < 609 && 82 < y_cood && y_cood < 90) {
                	printf("Dongfanghong\n"); pthread_mutex_lock(&temp_lock); temp = 23; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (590 < x_cood && x_cood < 598 && 87 < y_cood && y_cood < 95) {
                	printf("Jixi\n"); pthread_mutex_lock(&temp_lock); temp = 24; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (585 < x_cood && x_cood < 593 && 87 < y_cood && y_cood < 95) {
                	printf("Linkou\n"); pthread_mutex_lock(&temp_lock); temp = 25; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (579 < x_cood && x_cood < 587 && 94 < y_cood && y_cood < 102) {
                	printf("Mudanjiang\n"); pthread_mutex_lock(&temp_lock); temp = 26; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (597 < x_cood && x_cood < 605 && 94 < y_cood && y_cood < 102) {
                	printf("Suifenhe\n"); pthread_mutex_lock(&temp_lock); temp = 27; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (566 < x_cood && x_cood < 574 && 94 < y_cood && y_cood < 102) {
                	printf("Haerbin\n"); pthread_mutex_lock(&temp_lock); temp = 28; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (551 < x_cood && x_cood < 559 && 87 < y_cood && y_cood < 95) {
                	printf("Daqing\n"); pthread_mutex_lock(&temp_lock); temp = 29; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (544 < x_cood && x_cood < 552 && 87 < y_cood && y_cood < 95) {
                	printf("Ranghulu\n"); pthread_mutex_lock(&temp_lock); temp = 30; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (503 < x_cood && x_cood < 511 && 84 < y_cood && y_cood < 92) {
                	printf("Yiershi\n"); pthread_mutex_lock(&temp_lock); temp = 31; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (518 < x_cood && x_cood < 526 && 100 < y_cood && y_cood < 108) {
                	printf("Wulanhaote\n"); pthread_mutex_lock(&temp_lock); temp = 32; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (525 < x_cood && x_cood < 533 && 106 < y_cood && y_cood < 114) {
                	printf("Baicheng\n"); pthread_mutex_lock(&temp_lock); temp = 33; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (544 < x_cood && x_cood < 552 && 106 < y_cood && y_cood < 114) {
                	printf("Daan\n"); pthread_mutex_lock(&temp_lock); temp = 34; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (560 < x_cood && x_cood < 568 && 122 < y_cood && y_cood < 130) {
                	printf("Changchun\n"); pthread_mutex_lock(&temp_lock); temp = 35; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (566 < x_cood && x_cood < 574 && 113 < y_cood && y_cood < 121) {
                	printf("Yushu\n"); pthread_mutex_lock(&temp_lock); temp = 36; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (568 < x_cood && x_cood < 576 && 122 < y_cood && y_cood < 130) {
                	printf("Jilin\n"); pthread_mutex_lock(&temp_lock); temp = 37; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (574 < x_cood && x_cood < 582 && 122 < y_cood && y_cood < 130) {
                	printf("Jiaohe\n"); pthread_mutex_lock(&temp_lock); temp = 38; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (579 < x_cood && x_cood < 587 && 126 < y_cood && y_cood < 134) {
                	printf("Dunhua\n"); pthread_mutex_lock(&temp_lock); temp = 39; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (584 < x_cood && x_cood < 592 && 126 < y_cood && y_cood < 134) {
                	printf("Yanji\n"); pthread_mutex_lock(&temp_lock); temp = 40; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (590 < x_cood && x_cood < 598 && 126 < y_cood && y_cood < 134) {
                	printf("Tumen\n"); pthread_mutex_lock(&temp_lock); temp = 41; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (583 < x_cood && x_cood < 591 && 133 < y_cood && y_cood < 141) {
                	printf("Helong\n"); pthread_mutex_lock(&temp_lock); temp = 42; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (568 < x_cood && x_cood < 576 && 132 < y_cood && y_cood < 140) {
                	printf("Yantongshan\n"); pthread_mutex_lock(&temp_lock); temp = 43; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (576 < x_cood && x_cood < 584 && 132 < y_cood && y_cood < 140) {
                	printf("Baishanzhen\n"); pthread_mutex_lock(&temp_lock); temp = 44; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (534 < x_cood && x_cood < 542 && 120 < y_cood && y_cood < 128) {
                	printf("Taipingchuan\n"); pthread_mutex_lock(&temp_lock); temp = 45; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 117 < y_cood && y_cood < 125) {
                	printf("Huolinhe\n"); pthread_mutex_lock(&temp_lock); temp = 46; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (509 < x_cood && x_cood < 517 && 117 < y_cood && y_cood < 125) {
                	printf("Taligentu\n"); pthread_mutex_lock(&temp_lock); temp = 47; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (526 < x_cood && x_cood < 534 && 132 < y_cood && y_cood < 140) {
                	printf("Tongliao\n"); pthread_mutex_lock(&temp_lock); temp = 48; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (546 < x_cood && x_cood < 554 && 132 < y_cood && y_cood < 140) {
                	printf("Zhengjiatun\n"); pthread_mutex_lock(&temp_lock); temp = 49; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (550 < x_cood && x_cood < 558 && 136 < y_cood && y_cood < 144) {
                	printf("Siping\n"); pthread_mutex_lock(&temp_lock); temp = 50; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (567 < x_cood && x_cood < 575 && 153 < y_cood && y_cood < 161) {
                	printf("Tonghua\n"); pthread_mutex_lock(&temp_lock); temp = 51; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (582 < x_cood && x_cood < 590 && 141 < y_cood && y_cood < 149) {
                	printf("Baihe\n"); pthread_mutex_lock(&temp_lock); temp = 52; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (573 < x_cood && x_cood < 581 && 157 < y_cood && y_cood < 165) {
                	printf("Jian\n"); pthread_mutex_lock(&temp_lock); temp = 53; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (544 < x_cood && x_cood < 552 && 143 < y_cood && y_cood < 151) {
                	printf("Tieling\n"); pthread_mutex_lock(&temp_lock); temp = 54; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (544 < x_cood && x_cood < 552 && 157 < y_cood && y_cood < 165) {
                	printf("Shenyang\n"); pthread_mutex_lock(&temp_lock); temp = 55; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (526 < x_cood && x_cood < 534 && 150 < y_cood && y_cood < 158) {
                	printf("Xinlitun\n"); pthread_mutex_lock(&temp_lock); temp = 56; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (544 < x_cood && x_cood < 552 && 163 < y_cood && y_cood < 171) {
                	printf("Anshan\n"); pthread_mutex_lock(&temp_lock); temp = 57; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (551 < x_cood && x_cood < 559 && 163 < y_cood && y_cood < 171) {
                	printf("Benxi\n"); pthread_mutex_lock(&temp_lock); temp = 58; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (560 < x_cood && x_cood < 568 && 164 < y_cood && y_cood < 172) {
                	printf("Kuandian\n"); pthread_mutex_lock(&temp_lock); temp = 59; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (560 < x_cood && x_cood < 568 && 172 < y_cood && y_cood < 180) {
                	printf("Dandong\n"); pthread_mutex_lock(&temp_lock); temp = 60; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (533 < x_cood && x_cood < 541 && 173 < y_cood && y_cood < 181) {
                	printf("Dashiqiao\n"); pthread_mutex_lock(&temp_lock); temp = 61; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (529 < x_cood && x_cood < 537 && 169 < y_cood && y_cood < 177) {
                	printf("Yingkou\n"); pthread_mutex_lock(&temp_lock); temp = 62; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (533 < x_cood && x_cood < 541 && 180 < y_cood && y_cood < 188) {
                	printf("Wafangdian\n"); pthread_mutex_lock(&temp_lock); temp = 63; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (529 < x_cood && x_cood < 537 && 184 < y_cood && y_cood < 192) {
                	printf("Pulandian\n"); pthread_mutex_lock(&temp_lock); temp = 64; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (523 < x_cood && x_cood < 531 && 188 < y_cood && y_cood < 196) {
                	printf("Lvshun\n"); pthread_mutex_lock(&temp_lock); temp = 65; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (529 < x_cood && x_cood < 537 && 192 < y_cood && y_cood < 200) {
                	printf("Dalian\n"); pthread_mutex_lock(&temp_lock); temp = 66; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (519 < x_cood && x_cood < 527 && 164 < y_cood && y_cood < 172) {
                	printf("Jinzhou\n"); pthread_mutex_lock(&temp_lock); temp = 67; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (513 < x_cood && x_cood < 521 && 170 < y_cood && y_cood < 178) {
                	printf("Huludao\n"); pthread_mutex_lock(&temp_lock); temp = 68; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (494 < x_cood && x_cood < 502 && 165 < y_cood && y_cood < 173) {
                	printf("Yebaishou\n"); pthread_mutex_lock(&temp_lock); temp = 69; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (494 < x_cood && x_cood < 502 && 151 < y_cood && y_cood < 159) {
                	printf("Chifeng\n"); pthread_mutex_lock(&temp_lock); temp = 70; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (486 < x_cood && x_cood < 494 && 169 < y_cood && y_cood < 177) {
                	printf("Shangbancheng\n"); pthread_mutex_lock(&temp_lock); temp = 71; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (486 < x_cood && x_cood < 494 && 164 < y_cood && y_cood < 172) {
                	printf("Chengde\n"); pthread_mutex_lock(&temp_lock); temp = 72; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 188 < y_cood && y_cood < 196) {
                	printf("Qinhuangdao\n"); pthread_mutex_lock(&temp_lock); temp = 73; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (472 < x_cood && x_cood < 480 && 174 < y_cood && y_cood < 182) {
                	printf("Huairou\n"); pthread_mutex_lock(&temp_lock); temp = 74; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 196 < y_cood && y_cood < 204) {
                	printf("Tianjin\n"); pthread_mutex_lock(&temp_lock); temp = 75; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (486 < x_cood && x_cood < 494 && 196 < y_cood && y_cood < 204) {
                	printf("Tangshan\n"); pthread_mutex_lock(&temp_lock); temp = 76; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (446 < x_cood && x_cood < 454 && 168 < y_cood && y_cood < 176) {
                	printf("Zhangjiakou\n"); pthread_mutex_lock(&temp_lock); temp = 77; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (462 < x_cood && x_cood < 470 && 183 < y_cood && y_cood < 191) {
                	printf("Beijing\n"); pthread_mutex_lock(&temp_lock); temp = 78; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (462 < x_cood && x_cood < 470 && 196 < y_cood && y_cood < 204) {
                	printf("Bazhou\n"); pthread_mutex_lock(&temp_lock); temp = 79; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (476 < x_cood && x_cood < 484 && 132 < y_cood && y_cood < 140) {
                	printf("Daban\n"); pthread_mutex_lock(&temp_lock); temp = 80; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (451 < x_cood && x_cood < 459 && 156 < y_cood && y_cood < 164) {
                	printf("Sanggendalai\n"); pthread_mutex_lock(&temp_lock); temp = 81; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (444 < x_cood && x_cood < 452 && 135 < y_cood && y_cood < 143) {
                	printf("Xilinhaote\n"); pthread_mutex_lock(&temp_lock); temp = 82; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (424 < x_cood && x_cood < 432 && 156 < y_cood && y_cood < 164) {
                	printf("Benhong\n"); pthread_mutex_lock(&temp_lock); temp = 83; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (424 < x_cood && x_cood < 432 && 163 < y_cood && y_cood < 171) {
                	printf("Jiningnan\n"); pthread_mutex_lock(&temp_lock); temp = 84; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (400 < x_cood && x_cood < 408 && 163 < y_cood && y_cood < 171) {
                	printf("Huhehaote\n"); pthread_mutex_lock(&temp_lock); temp = 85; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (373 < x_cood && x_cood < 381 && 163 < y_cood && y_cood < 171) {
                	printf("Baotou\n"); pthread_mutex_lock(&temp_lock); temp = 86; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (373 < x_cood && x_cood < 381 && 149 < y_cood && y_cood < 157) {
                	printf("Baiyunebo\n"); pthread_mutex_lock(&temp_lock); temp = 87; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (373 < x_cood && x_cood < 381 && 178 < y_cood && y_cood < 186) {
                	printf("Dongsheng\n"); pthread_mutex_lock(&temp_lock); temp = 88; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (339 < x_cood && x_cood < 347 && 163 < y_cood && y_cood < 171) {
                	printf("Linhe\n"); pthread_mutex_lock(&temp_lock); temp = 89; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (340 < x_cood && x_cood < 348 && 177 < y_cood && y_cood < 185) {
                	printf("Wuhaixi\n"); pthread_mutex_lock(&temp_lock); temp = 90; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (324 < x_cood && x_cood < 332 && 167 < y_cood && y_cood < 175) {
                	printf("Jilantai\n"); pthread_mutex_lock(&temp_lock); temp = 91; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (339 < x_cood && x_cood < 347 && 184 < y_cood && y_cood < 192) {
                	printf("Shizuishan\n"); pthread_mutex_lock(&temp_lock); temp = 92; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (330 < x_cood && x_cood < 338 && 192 < y_cood && y_cood < 200) {
                	printf("Yinchuan\n"); pthread_mutex_lock(&temp_lock); temp = 93; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (423 < x_cood && x_cood < 431 && 179 < y_cood && y_cood < 187) {
                	printf("Datong\n"); pthread_mutex_lock(&temp_lock); temp = 94; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (397 < x_cood && x_cood < 405 && 131 < y_cood && y_cood < 139) {
                	printf("Erlianhaote\n"); pthread_mutex_lock(&temp_lock); temp = 95; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (386 < x_cood && x_cood < 394 && 191 < y_cood && y_cood < 199) {
                	printf("Shenmubei\n"); pthread_mutex_lock(&temp_lock); temp = 96; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (418 < x_cood && x_cood < 426 && 190 < y_cood && y_cood < 198) {
                	printf("Daxin\n"); pthread_mutex_lock(&temp_lock); temp = 97; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (413 < x_cood && x_cood < 421 && 194 < y_cood && y_cood < 202) {
                	printf("Shuozhou\n"); pthread_mutex_lock(&temp_lock); temp = 98; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (418 < x_cood && x_cood < 426 && 200 < y_cood && y_cood < 208) {
                	printf("Yuanping\n"); pthread_mutex_lock(&temp_lock); temp = 99; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (410 < x_cood && x_cood < 418 && 203 < y_cood && y_cood < 211) {
                	printf("Kelan\n"); pthread_mutex_lock(&temp_lock); temp = 100; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (381 < x_cood && x_cood < 389 && 207 < y_cood && y_cood < 215) {
                	printf("Yulinzhen\n"); pthread_mutex_lock(&temp_lock); temp = 101; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (378 < x_cood && x_cood < 386 && 225 < y_cood && y_cood < 233) {
                	printf("Yanan\n"); pthread_mutex_lock(&temp_lock); temp = 102; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (395 < x_cood && x_cood < 403 && 216 < y_cood && y_cood < 224) {
                	printf("Liulin\n"); pthread_mutex_lock(&temp_lock); temp = 103; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (418 < x_cood && x_cood < 426 && 210 < y_cood && y_cood < 218) {
                	printf("Taiyuan\n"); pthread_mutex_lock(&temp_lock); temp = 104; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (424 < x_cood && x_cood < 432 && 216 < y_cood && y_cood < 224) {
                	printf("Yuci\n"); pthread_mutex_lock(&temp_lock); temp = 105; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (410 < x_cood && x_cood < 418 && 216 < y_cood && y_cood < 224) {
                	printf("Jiexiu\n"); pthread_mutex_lock(&temp_lock); temp = 106; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (441 < x_cood && x_cood < 449 && 210 < y_cood && y_cood < 218) {
                	printf("Shijiazhuang\n"); pthread_mutex_lock(&temp_lock); temp = 107; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 205 < y_cood && y_cood < 213) {
                	printf("Suning\n"); pthread_mutex_lock(&temp_lock); temp = 108; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 205 < y_cood && y_cood < 213) {
                	printf("Cangzhou\n"); pthread_mutex_lock(&temp_lock); temp = 109; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 216 < y_cood && y_cood < 224) {
                	printf("Hengshui\n"); pthread_mutex_lock(&temp_lock); temp = 110; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 216 < y_cood && y_cood < 224) {
                	printf("Dezhou\n"); pthread_mutex_lock(&temp_lock); temp = 111; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 213 < y_cood && y_cood < 221) {
                	printf("Dongying\n"); pthread_mutex_lock(&temp_lock); temp = 112; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (423 < x_cood && x_cood < 431 && 233 < y_cood && y_cood < 241) {
                	printf("Changzhi\n"); pthread_mutex_lock(&temp_lock); temp = 113; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (441 < x_cood && x_cood < 449 && 227 < y_cood && y_cood < 235) {
                	printf("Handan\n"); pthread_mutex_lock(&temp_lock); temp = 114; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (459 < x_cood && x_cood < 467 && 231 < y_cood && y_cood < 239) {
                	printf("Liaocheng\n"); pthread_mutex_lock(&temp_lock); temp = 115; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (486 < x_cood && x_cood < 494 && 226 < y_cood && y_cood < 234) {
                	printf("Jinan\n"); pthread_mutex_lock(&temp_lock); temp = 116; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 226 < y_cood && y_cood < 234) {
                	printf("Zibo\n"); pthread_mutex_lock(&temp_lock); temp = 117; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (504 < x_cood && x_cood < 512 && 226 < y_cood && y_cood < 234) {
                	printf("Qingzhoushi\n"); pthread_mutex_lock(&temp_lock); temp = 118; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (517 < x_cood && x_cood < 525 && 226 < y_cood && y_cood < 234) {
                	printf("Weifang\n"); pthread_mutex_lock(&temp_lock); temp = 119; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (524 < x_cood && x_cood < 532 && 232 < y_cood && y_cood < 240) {
                	printf("Qingdao\n"); pthread_mutex_lock(&temp_lock); temp = 120; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (528 < x_cood && x_cood < 536 && 208 < y_cood && y_cood < 216) {
                	printf("Yantai\n"); pthread_mutex_lock(&temp_lock); temp = 121; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (534 < x_cood && x_cood < 542 && 210 < y_cood && y_cood < 218) {
                	printf("Weihai\n"); pthread_mutex_lock(&temp_lock); temp = 122; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (404 < x_cood && x_cood < 412 && 241 < y_cood && y_cood < 249) {
                	printf("Houma\n"); pthread_mutex_lock(&temp_lock); temp = 123; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (424 < x_cood && x_cood < 432 && 245 < y_cood && y_cood < 253) {
                	printf("Yueshan\n"); pthread_mutex_lock(&temp_lock); temp = 124; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (442 < x_cood && x_cood < 450 && 236 < y_cood && y_cood < 244) {
                	printf("Anyang\n"); pthread_mutex_lock(&temp_lock); temp = 125; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 246 < y_cood && y_cood < 254) {
                	printf("Heze\n"); pthread_mutex_lock(&temp_lock); temp = 126; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (474 < x_cood && x_cood < 482 && 245 < y_cood && y_cood < 253) {
                	printf("Yanzhou\n"); pthread_mutex_lock(&temp_lock); temp = 127; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (486 < x_cood && x_cood < 494 && 233 < y_cood && y_cood < 241) {
                	printf("Taishan\n"); pthread_mutex_lock(&temp_lock); temp = 128; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (368 < x_cood && x_cood < 376 && 250 < y_cood && y_cood < 258) {
                	printf("Sanyuan\n"); pthread_mutex_lock(&temp_lock); temp = 129; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (378 < x_cood && x_cood < 386 && 250 < y_cood && y_cood < 258) {
                	printf("Zhongjiacun\n"); pthread_mutex_lock(&temp_lock); temp = 130; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (389 < x_cood && x_cood < 397 && 256 < y_cood && y_cood < 264) {
                	printf("Huashan\n"); pthread_mutex_lock(&temp_lock); temp = 131; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (413 < x_cood && x_cood < 421 && 256 < y_cood && y_cood < 264) {
                	printf("Luoyang\n"); pthread_mutex_lock(&temp_lock); temp = 132; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (431 < x_cood && x_cood < 439 && 256 < y_cood && y_cood < 264) {
                	printf("Zhengzhou\n"); pthread_mutex_lock(&temp_lock); temp = 133; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (441 < x_cood && x_cood < 449 && 245 < y_cood && y_cood < 253) {
                	printf("Xinxiang\n"); pthread_mutex_lock(&temp_lock); temp = 134; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (446 < x_cood && x_cood < 454 && 256 < y_cood && y_cood < 264) {
                	printf("Kaifeng\n"); pthread_mutex_lock(&temp_lock); temp = 135; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 256 < y_cood && y_cood < 264) {
                	printf("Shangqiu\n"); pthread_mutex_lock(&temp_lock); temp = 136; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (474 < x_cood && x_cood < 482 && 256 < y_cood && y_cood < 264) {
                	printf("Xvzhou\n"); pthread_mutex_lock(&temp_lock); temp = 137; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (492 < x_cood && x_cood < 500 && 245 < y_cood && y_cood < 253) {
                	printf("Linyi\n"); pthread_mutex_lock(&temp_lock); temp = 138; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (506 < x_cood && x_cood < 514 && 245 < y_cood && y_cood < 253) {
                	printf("Rizhao\n"); pthread_mutex_lock(&temp_lock); temp = 139; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (363 < x_cood && x_cood < 371 && 256 < y_cood && y_cood < 264) {
                	printf("Xianyang\n"); pthread_mutex_lock(&temp_lock); temp = 140; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (372 < x_cood && x_cood < 380 && 256 < y_cood && y_cood < 264) {
                	printf("Xian\n"); pthread_mutex_lock(&temp_lock); temp = 141; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (365 < x_cood && x_cood < 373 && 277 < y_cood && y_cood < 285) {
                	printf("Ankang\n"); pthread_mutex_lock(&temp_lock); temp = 142; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (402 < x_cood && x_cood < 410 && 283 < y_cood && y_cood < 291) {
                	printf("Danjiang\n"); pthread_mutex_lock(&temp_lock); temp = 143; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (412 < x_cood && x_cood < 420 && 271 < y_cood && y_cood < 279) {
                	printf("Baofeng\n"); pthread_mutex_lock(&temp_lock); temp = 144; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (412 < x_cood && x_cood < 420 && 279 < y_cood && y_cood < 287) {
                	printf("Nanyang\n"); pthread_mutex_lock(&temp_lock); temp = 145; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (431 < x_cood && x_cood < 439 && 271 < y_cood && y_cood < 279) {
                	printf("Luohe\n"); pthread_mutex_lock(&temp_lock); temp = 146; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 271 < y_cood && y_cood < 279) {
                	printf("Fuyang\n"); pthread_mutex_lock(&temp_lock); temp = 147; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (474 < x_cood && x_cood < 482 && 264 < y_cood && y_cood < 272) {
                	printf("Fuliji\n"); pthread_mutex_lock(&temp_lock); temp = 148; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (494 < x_cood && x_cood < 502 && 256 < y_cood && y_cood < 264) {
                	printf("Xinyi\n"); pthread_mutex_lock(&temp_lock); temp = 149; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (508 < x_cood && x_cood < 516 && 256 < y_cood && y_cood < 264) {
                	printf("Yuntai\n"); pthread_mutex_lock(&temp_lock); temp = 150; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (480 < x_cood && x_cood < 488 && 275 < y_cood && y_cood < 283) {
                	printf("Bengbu\n"); pthread_mutex_lock(&temp_lock); temp = 151; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 283 < y_cood && y_cood < 291) {
                	printf("Nanjing\n"); pthread_mutex_lock(&temp_lock); temp = 152; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (499 < x_cood && x_cood < 507 && 274 < y_cood && y_cood < 282) {
                	printf("Yangzhou\n"); pthread_mutex_lock(&temp_lock); temp = 153; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (502 < x_cood && x_cood < 510 && 283 < y_cood && y_cood < 291) {
                	printf("Zhenjiang\n"); pthread_mutex_lock(&temp_lock); temp = 154; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (509 < x_cood && x_cood < 517 && 273 < y_cood && y_cood < 281) {
                	printf("Haian\n"); pthread_mutex_lock(&temp_lock); temp = 155; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (519 < x_cood && x_cood < 527 && 282 < y_cood && y_cood < 290) {
                	printf("Nantong\n"); pthread_mutex_lock(&temp_lock); temp = 156; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (413 < x_cood && x_cood < 421 && 290 < y_cood && y_cood < 298) {
                	printf("Xiangfan\n"); pthread_mutex_lock(&temp_lock); temp = 157; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (430 < x_cood && x_cood < 438 && 291 < y_cood && y_cood < 299) {
                	printf("Xinyang\n"); pthread_mutex_lock(&temp_lock); temp = 158; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (442 < x_cood && x_cood < 450 && 289 < y_cood && y_cood < 297) {
                	printf("Hanchuan\n"); pthread_mutex_lock(&temp_lock); temp = 159; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 280 < y_cood && y_cood < 288) {
                	printf("Shuijiahu\n"); pthread_mutex_lock(&temp_lock); temp = 160; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 294 < y_cood && y_cood < 302) {
                	printf("Hefei\n"); pthread_mutex_lock(&temp_lock); temp = 161; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (506 < x_cood && x_cood < 514 && 287 < y_cood && y_cood < 295) {
                	printf("Danyang\n"); pthread_mutex_lock(&temp_lock); temp = 162; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (516 < x_cood && x_cood < 524 && 292 < y_cood && y_cood < 300) {
                	printf("Wuxi\n"); pthread_mutex_lock(&temp_lock); temp = 163; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (512 < x_cood && x_cood < 520 && 288 < y_cood && y_cood < 296) {
                	printf("Changzhou\n"); pthread_mutex_lock(&temp_lock); temp = 164; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (522 < x_cood && x_cood < 530 && 292 < y_cood && y_cood < 300) {
                	printf("Suzhou\n"); pthread_mutex_lock(&temp_lock); temp = 165; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (527 < x_cood && x_cood < 535 && 298 < y_cood && y_cood < 306) {
                	printf("Shanghai\n"); pthread_mutex_lock(&temp_lock); temp = 166; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (413 < x_cood && x_cood < 421 && 302 < y_cood && y_cood < 310) {
                	printf("Jingmen\n"); pthread_mutex_lock(&temp_lock); temp = 167; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (431 < x_cood && x_cood < 439 && 308 < y_cood && y_cood < 316) {
                	printf("Wuhan\n"); pthread_mutex_lock(&temp_lock); temp = 168; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (430 < x_cood && x_cood < 438 && 301 < y_cood && y_cood < 309) {
                	printf("Hankou\n"); pthread_mutex_lock(&temp_lock); temp = 169; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (442 < x_cood && x_cood < 450 && 297 < y_cood && y_cood < 305) {
                	printf("Macheng\n"); pthread_mutex_lock(&temp_lock); temp = 170; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 302 < y_cood && y_cood < 310) {
                	printf("Wuhu\n"); pthread_mutex_lock(&temp_lock); temp = 172; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (490 < x_cood && x_cood < 498 && 301 < y_cood && y_cood < 309) {
                	printf("Wuhubei\n"); pthread_mutex_lock(&temp_lock); temp = 173; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (488 < x_cood && x_cood < 496 && 307 < y_cood && y_cood < 315) {
                	printf("Tonglingbei\n"); pthread_mutex_lock(&temp_lock); temp = 174; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (504 < x_cood && x_cood < 512 && 301 < y_cood && y_cood < 309) {
                	printf("Xuancheng\n"); pthread_mutex_lock(&temp_lock); temp = 175; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (517 < x_cood && x_cood < 525 && 301 < y_cood && y_cood < 309) {
                	printf("Changxing\n"); pthread_mutex_lock(&temp_lock); temp = 176; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (517 < x_cood && x_cood < 525 && 308 < y_cood && y_cood < 316) {
                	printf("Hangzhou\n"); pthread_mutex_lock(&temp_lock); temp = 177; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 314 < y_cood && y_cood < 322) {
                	printf("Anqing\n"); pthread_mutex_lock(&temp_lock); temp = 178; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (392 < x_cood && x_cood < 400 && 308 < y_cood && y_cood < 316) {
                	printf("Yichang\n"); pthread_mutex_lock(&temp_lock); temp = 179; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (403 < x_cood && x_cood < 411 && 312 < y_cood && y_cood < 320) {
                	printf("Zhicheng\n"); pthread_mutex_lock(&temp_lock); temp = 180; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (402 < x_cood && x_cood < 410 && 325 < y_cood && y_cood < 333) {
                	printf("Shimen\n"); pthread_mutex_lock(&temp_lock); temp = 181; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (410 < x_cood && x_cood < 418 && 331 < y_cood && y_cood < 339) {
                	printf("Yiyang\n"); pthread_mutex_lock(&temp_lock); temp = 182; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (417 < x_cood && x_cood < 425 && 337 < y_cood && y_cood < 345) {
                	printf("Changsha\n"); pthread_mutex_lock(&temp_lock); temp = 183; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (417 < x_cood && x_cood < 425 && 321 < y_cood && y_cood < 329) {
                	printf("Yueyang\n"); pthread_mutex_lock(&temp_lock); temp = 184; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (382 < x_cood && x_cood < 390 && 345 < y_cood && y_cood < 353) {
                	printf("Huaihua\n"); pthread_mutex_lock(&temp_lock); temp = 185; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (403 < x_cood && x_cood < 411 && 344 < y_cood && y_cood < 352) {
                	printf("Loudi\n"); pthread_mutex_lock(&temp_lock); temp = 186; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (417 < x_cood && x_cood < 425 && 345 < y_cood && y_cood < 353) {
                	printf("Zhuzhou\n"); pthread_mutex_lock(&temp_lock); temp = 187; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (440 < x_cood && x_cood < 448 && 338 < y_cood && y_cood < 346) {
                	printf("Xinyu\n"); pthread_mutex_lock(&temp_lock); temp = 188; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (430 < x_cood && x_cood < 438 && 347 < y_cood && y_cood < 355) {
                	printf("Wenzhu\n"); pthread_mutex_lock(&temp_lock); temp = 189; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 337 < y_cood && y_cood < 345) {
                	printf("Xiangtang\n"); pthread_mutex_lock(&temp_lock); temp = 190; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 331 < y_cood && y_cood < 339) {
                	printf("Nanchang\n"); pthread_mutex_lock(&temp_lock); temp = 191; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (460 < x_cood && x_cood < 468 && 322 < y_cood && y_cood < 330) {
                	printf("Jiujiang\n"); pthread_mutex_lock(&temp_lock); temp = 192; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (475 < x_cood && x_cood < 483 && 319 < y_cood && y_cood < 327) {
                	printf("Chizhou\n"); pthread_mutex_lock(&temp_lock); temp = 193; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (480 < x_cood && x_cood < 488 && 337 < y_cood && y_cood < 345) {
                	printf("Yingtan\n"); pthread_mutex_lock(&temp_lock); temp = 194; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (489 < x_cood && x_cood < 497 && 316 < y_cood && y_cood < 324) {
                	printf("Huangshan\n"); pthread_mutex_lock(&temp_lock); temp = 195; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (488 < x_cood && x_cood < 496 && 338 < y_cood && y_cood < 346) {
                	printf("Hengfeng\n"); pthread_mutex_lock(&temp_lock); temp = 196; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (517 < x_cood && x_cood < 525 && 327 < y_cood && y_cood < 335) {
                	printf("Jinhuaxi\n"); pthread_mutex_lock(&temp_lock); temp = 197; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (511 < x_cood && x_cood < 519 && 322 < y_cood && y_cood < 330) {
                	printf("Qiandaohu\n"); pthread_mutex_lock(&temp_lock); temp = 198; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (517 < x_cood && x_cood < 525 && 314 < y_cood && y_cood < 322) {
                	printf("Xiaoshan\n"); pthread_mutex_lock(&temp_lock); temp = 199; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (534 < x_cood && x_cood < 542 && 314 < y_cood && y_cood < 322) {
                	printf("Ningbo\n"); pthread_mutex_lock(&temp_lock); temp = 200; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (529 < x_cood && x_cood < 537 && 341 < y_cood && y_cood < 349) {
                	printf("Wenzhou\n"); pthread_mutex_lock(&temp_lock); temp = 201; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 344 < y_cood && y_cood < 352) {
                	printf("Wuyishan\n"); pthread_mutex_lock(&temp_lock); temp = 202; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (400 < x_cood && x_cood < 408 && 354 < y_cood && y_cood < 362) {
                	printf("Shaoyang\n"); pthread_mutex_lock(&temp_lock); temp = 203; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (399 < x_cood && x_cood < 407 && 363 < y_cood && y_cood < 371) {
                	printf("Yongzhou\n"); pthread_mutex_lock(&temp_lock); temp = 204; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (384 < x_cood && x_cood < 392 && 377 < y_cood && y_cood < 385) {
                	printf("Guilin\n"); pthread_mutex_lock(&temp_lock); temp = 205; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (400 < x_cood && x_cood < 408 && 382 < y_cood && y_cood < 390) {
                	printf("Hezhou\n"); pthread_mutex_lock(&temp_lock); temp = 206; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (417 < x_cood && x_cood < 425 && 363 < y_cood && y_cood < 371) {
                	printf("Hengyang\n"); pthread_mutex_lock(&temp_lock); temp = 207; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (423 < x_cood && x_cood < 431 && 375 < y_cood && y_cood < 383) {
                	printf("Binzhou\n"); pthread_mutex_lock(&temp_lock); temp = 208; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (440 < x_cood && x_cood < 448 && 356 < y_cood && y_cood < 364) {
                	printf("Jinggangshan\n"); pthread_mutex_lock(&temp_lock); temp = 209; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (447 < x_cood && x_cood < 455 && 350 < y_cood && y_cood < 358) {
                	printf("Jianzhen\n"); pthread_mutex_lock(&temp_lock); temp = 210; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (447 < x_cood && x_cood < 455 && 368 < y_cood && y_cood < 376) {
                	printf("Ganzhou\n"); pthread_mutex_lock(&temp_lock); temp = 211; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (480 < x_cood && x_cood < 488 && 374 < y_cood && y_cood < 382) {
                	printf("Zhangping\n"); pthread_mutex_lock(&temp_lock); temp = 212; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (491 < x_cood && x_cood < 499 && 354 < y_cood && y_cood < 362) {
                	printf("Laizhou\n"); pthread_mutex_lock(&temp_lock); temp = 213; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 360 < y_cood && y_cood < 368) {
                	printf("Nanping\n"); pthread_mutex_lock(&temp_lock); temp = 214; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (508 < x_cood && x_cood < 516 && 372 < y_cood && y_cood < 380) {
                	printf("Fuzhou\n"); pthread_mutex_lock(&temp_lock); temp = 215; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (495 < x_cood && x_cood < 503 && 377 < y_cood && y_cood < 385) {
                	printf("Xiaocuo\n"); pthread_mutex_lock(&temp_lock); temp = 216; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (374 < x_cood && x_cood < 382 && 387 < y_cood && y_cood < 395) {
                	printf("Liuzhou\n"); pthread_mutex_lock(&temp_lock); temp = 219; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (374 < x_cood && x_cood < 382 && 403 < y_cood && y_cood < 411) {
                	printf("Litang\n"); pthread_mutex_lock(&temp_lock); temp = 220; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (369 < x_cood && x_cood < 377 && 410 < y_cood && y_cood < 418) {
                	printf("Nanning\n"); pthread_mutex_lock(&temp_lock); temp = 221; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (363 < x_cood && x_cood < 371 && 421 < y_cood && y_cood < 429) {
                	printf("Pingxiang\n"); pthread_mutex_lock(&temp_lock); temp = 222; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (369 < x_cood && x_cood < 377 && 418 < y_cood && y_cood < 426) {
                	printf("Fangchenggang\n"); pthread_mutex_lock(&temp_lock); temp = 223; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (375 < x_cood && x_cood < 383 && 418 < y_cood && y_cood < 426) {
                	printf("Qinzhou\n"); pthread_mutex_lock(&temp_lock); temp = 224; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (378 < x_cood && x_cood < 386 && 425 < y_cood && y_cood < 433) {
                	printf("Beihai\n"); pthread_mutex_lock(&temp_lock); temp = 225; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (389 < x_cood && x_cood < 397 && 428 < y_cood && y_cood < 436) {
                	printf("Zhanjiang\n"); pthread_mutex_lock(&temp_lock); temp = 226; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (389 < x_cood && x_cood < 397 && 455 < y_cood && y_cood < 463) {
                	printf("Haikou\n"); pthread_mutex_lock(&temp_lock); temp = 227; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (379 < x_cood && x_cood < 387 && 459 < y_cood && y_cood < 467) {
                	printf("Shilu\n"); pthread_mutex_lock(&temp_lock); temp = 228; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (385 < x_cood && x_cood < 393 && 465 < y_cood && y_cood < 473) {
                	printf("Sanya\n"); pthread_mutex_lock(&temp_lock); temp = 229; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (381 < x_cood && x_cood < 389 && 409 < y_cood && y_cood < 417) {
                	printf("Yulin\n"); pthread_mutex_lock(&temp_lock); temp = 230; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (393 < x_cood && x_cood < 401 && 400 < y_cood && y_cood < 408) {
                	printf("Wuzhou\n"); pthread_mutex_lock(&temp_lock); temp = 231; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (415 < x_cood && x_cood < 423 && 404 < y_cood && y_cood < 412) {
                	printf("Sanshui\n"); pthread_mutex_lock(&temp_lock); temp = 232; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (423 < x_cood && x_cood < 431 && 404 < y_cood && y_cood < 412) {
                	printf("Guangzhou\n"); pthread_mutex_lock(&temp_lock); temp = 233; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (424 < x_cood && x_cood < 432 && 383 < y_cood && y_cood < 391) {
                	printf("Shaoguan\n"); pthread_mutex_lock(&temp_lock); temp = 234; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (429 < x_cood && x_cood < 437 && 410 < y_cood && y_cood < 418) {
                	printf("Dongguan\n"); pthread_mutex_lock(&temp_lock); temp = 235; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (433 < x_cood && x_cood < 441 && 413 < y_cood && y_cood < 421) {
                	printf("Shenzhen\n"); pthread_mutex_lock(&temp_lock); temp = 236; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (433 < x_cood && x_cood < 441 && 420 < y_cood && y_cood < 428) {
                	printf("Hongkong\n"); pthread_mutex_lock(&temp_lock); temp = 237; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (447 < x_cood && x_cood < 455 && 391 < y_cood && y_cood < 399) {
                	printf("Longchuan\n"); pthread_mutex_lock(&temp_lock); temp = 238; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (457 < x_cood && x_cood < 465 && 391 < y_cood && y_cood < 399) {
                	printf("Meizhou\n"); pthread_mutex_lock(&temp_lock); temp = 239; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (463 < x_cood && x_cood < 471 && 399 < y_cood && y_cood < 407) {
                	printf("Shantou\n"); pthread_mutex_lock(&temp_lock); temp = 240; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (474 < x_cood && x_cood < 482 && 380 < y_cood && y_cood < 388) {
                	printf("Longyan\n"); pthread_mutex_lock(&temp_lock); temp = 241; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (482 < x_cood && x_cood < 490 && 386 < y_cood && y_cood < 394) {
                	printf("Zhangzhou\n"); pthread_mutex_lock(&temp_lock); temp = 242; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (491 < x_cood && x_cood < 499 && 385 < y_cood && y_cood < 393) {
                	printf("Xiamen\n"); pthread_mutex_lock(&temp_lock); temp = 243; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (389 < x_cood && x_cood < 397 && 417 < y_cood && y_cood < 425) {
                	printf("Hechun\n"); pthread_mutex_lock(&temp_lock); temp = 244; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (396 < x_cood && x_cood < 404 && 424 < y_cood && y_cood < 432) {
                	printf("Maoming\n"); pthread_mutex_lock(&temp_lock); temp = 245; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (316 < x_cood && x_cood < 324 && 386 < y_cood && y_cood < 394) {
                	printf("Baise\n"); pthread_mutex_lock(&temp_lock); temp = 246; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (347 < x_cood && x_cood < 355 && 371 < y_cood && y_cood < 379) {
                	printf("Jinchengjiang\n"); pthread_mutex_lock(&temp_lock); temp = 247; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (334 < x_cood && x_cood < 342 && 344 < y_cood && y_cood < 352) {
                	printf("Guiding\n"); pthread_mutex_lock(&temp_lock); temp = 248; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (322 < x_cood && x_cood < 330 && 344 < y_cood && y_cood < 352) {
                	printf("Guiyang\n"); pthread_mutex_lock(&temp_lock); temp = 249; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (300 < x_cood && x_cood < 308 && 360 < y_cood && y_cood < 368) {
                	printf("Weishe\n"); pthread_mutex_lock(&temp_lock); temp = 250; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (282 < x_cood && x_cood < 290 && 364 < y_cood && y_cood < 372) {
                	printf("Kunming\n"); pthread_mutex_lock(&temp_lock); temp = 251; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (295 < x_cood && x_cood < 303 && 351 < y_cood && y_cood < 359) {
                	printf("Zhanyi\n"); pthread_mutex_lock(&temp_lock); temp = 252; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (300 < x_cood && x_cood < 308 && 353 < y_cood && y_cood < 361) {
                	printf("Hongguo\n"); pthread_mutex_lock(&temp_lock); temp = 253; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (282 < x_cood && x_cood < 290 && 373 < y_cood && y_cood < 381) {
                	printf("Yuxi\n"); pthread_mutex_lock(&temp_lock); temp = 254; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (260 < x_cood && x_cood < 268 && 349 < y_cood && y_cood < 357) {
                	printf("Lijiang\n"); pthread_mutex_lock(&temp_lock); temp = 255; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (284 < x_cood && x_cood < 292 && 331 < y_cood && y_cood < 339) {
                	printf("Xichang\n"); pthread_mutex_lock(&temp_lock); temp = 256; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (321 < x_cood && x_cood < 329 && 329 < y_cood && y_cood < 337) {
                	printf("Zunyi\n"); pthread_mutex_lock(&temp_lock); temp = 257; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (294 < x_cood && x_cood < 302 && 282 < y_cood && y_cood < 290) {
                	printf("Dujiangyan\n"); pthread_mutex_lock(&temp_lock); temp = 258; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (306 < x_cood && x_cood < 314 && 287 < y_cood && y_cood < 295) {
                	printf("Mianyang\n"); pthread_mutex_lock(&temp_lock); temp = 259; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (338 < x_cood && x_cood < 346 && 300 < y_cood && y_cood < 308) {
                	printf("Wanzhou\n"); pthread_mutex_lock(&temp_lock); temp = 260; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (299 < x_cood && x_cood < 307 && 321 < y_cood && y_cood < 329) {
                	printf("Yibin\n"); pthread_mutex_lock(&temp_lock); temp = 261; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (276 < x_cood && x_cood < 284 && 364 < y_cood && y_cood < 372) {
                	printf("Guangtong\n"); pthread_mutex_lock(&temp_lock); temp = 262; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (261 < x_cood && x_cood < 269 && 359 < y_cood && y_cood < 367) {
                	printf("Dali\n"); pthread_mutex_lock(&temp_lock); temp = 263; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (285 < x_cood && x_cood < 293 && 343 < y_cood && y_cood < 351) {
                	printf("Panzhihua\n"); pthread_mutex_lock(&temp_lock); temp = 264; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (302 < x_cood && x_cood < 310 && 345 < y_cood && y_cood < 353) {
                	printf("Liupanshui\n"); pthread_mutex_lock(&temp_lock); temp = 265; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (305 < x_cood && x_cood < 313 && 315 < y_cood && y_cood < 323) {
                	printf("Neijiang\n"); pthread_mutex_lock(&temp_lock); temp = 266; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (321 < x_cood && x_cood < 329 && 315 < y_cood && y_cood < 323) {
                	printf("Chongqing\n"); pthread_mutex_lock(&temp_lock); temp = 267; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (292 < x_cood && x_cood < 300 && 300 < y_cood && y_cood < 308) {
                	printf("Emei\n"); pthread_mutex_lock(&temp_lock); temp = 268; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (297 < x_cood && x_cood < 305 && 294 < y_cood && y_cood < 302) {
                	printf("Chengdu\n"); pthread_mutex_lock(&temp_lock); temp = 269; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (315 < x_cood && x_cood < 323 && 277 < y_cood && y_cood < 285) {
                	printf("Guangyuan\n"); pthread_mutex_lock(&temp_lock); temp = 270; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (327 < x_cood && x_cood < 335 && 277 < y_cood && y_cood < 285) {
                	printf("Yangpingguan\n"); pthread_mutex_lock(&temp_lock); temp = 271; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (329 < x_cood && x_cood < 337 && 257 < y_cood && y_cood < 265) {
                	printf("Baoji\n"); pthread_mutex_lock(&temp_lock); temp = 272; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (317 < x_cood && x_cood < 325 && 245 < y_cood && y_cood < 253) {
                	printf("Tianshui\n"); pthread_mutex_lock(&temp_lock); temp = 273; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (328 < x_cood && x_cood < 336 && 241 < y_cood && y_cood < 249) {
                	printf("Pingliang\n"); pthread_mutex_lock(&temp_lock); temp = 274; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (286 < x_cood && x_cood < 294 && 230 < y_cood && y_cood < 238) {
                	printf("Lanzhou\n"); pthread_mutex_lock(&temp_lock); temp = 275; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (266 < x_cood && x_cood < 274 && 220 < y_cood && y_cood < 228) {
                	printf("Xining\n"); pthread_mutex_lock(&temp_lock); temp = 276; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (259 < x_cood && x_cood < 267 && 214 < y_cood && y_cood < 222) {
                	printf("Haergai\n"); pthread_mutex_lock(&temp_lock); temp = 277; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (306 < x_cood && x_cood < 314 && 218 < y_cood && y_cood < 226) {
                	printf("Zhongwei\n"); pthread_mutex_lock(&temp_lock); temp = 278; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (296 < x_cood && x_cood < 304 && 218 < y_cood && y_cood < 226) {
                	printf("Gantang\n"); pthread_mutex_lock(&temp_lock); temp = 279; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (306 < x_cood && x_cood < 314 && 230 < y_cood && y_cood < 238) {
                	printf("Honghui\n"); pthread_mutex_lock(&temp_lock); temp = 280; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (286 < x_cood && x_cood < 294 && 218 < y_cood && y_cood < 226) {
                	printf("Wuweinan\n"); pthread_mutex_lock(&temp_lock); temp = 281; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (213 < x_cood && x_cood < 221 && 214 < y_cood && y_cood < 222) {
                	printf("Geermu\n"); pthread_mutex_lock(&temp_lock); temp = 282; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (179 < x_cood && x_cood < 187 && 300 < y_cood && y_cood < 308) {
                	printf("Lasa\n"); pthread_mutex_lock(&temp_lock); temp = 283; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (255 < x_cood && x_cood < 263 && 168 < y_cood && y_cood < 176) {
                	printf("Jiayuguan\n"); pthread_mutex_lock(&temp_lock); temp = 284; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (247 < x_cood && x_cood < 255 && 174 < y_cood && y_cood < 182) {
                	printf("Jingtieshan\n"); pthread_mutex_lock(&temp_lock); temp = 285; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (233 < x_cood && x_cood < 241 && 146 < y_cood && y_cood < 154) {
                	printf("Liugou\n"); pthread_mutex_lock(&temp_lock); temp = 286; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (224 < x_cood && x_cood < 232 && 155 < y_cood && y_cood < 163) {
                	printf("Dunhuang\n"); pthread_mutex_lock(&temp_lock); temp = 287; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (222 < x_cood && x_cood < 230 && 135 < y_cood && y_cood < 143) {
                	printf("Hami\n"); pthread_mutex_lock(&temp_lock); temp = 288; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (211 < x_cood && x_cood < 219 && 135 < y_cood && y_cood < 143) {
                	printf("Liaodun\n"); pthread_mutex_lock(&temp_lock); temp = 289; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (174 < x_cood && x_cood < 182 && 122 < y_cood && y_cood < 130) {
                	printf("Tulufan\n"); pthread_mutex_lock(&temp_lock); temp = 290; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (157 < x_cood && x_cood < 165 && 104 < y_cood && y_cood < 112) {
                	printf("Wulumuqi\n"); pthread_mutex_lock(&temp_lock); temp = 291; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (141 < x_cood && x_cood < 149 && 104 < y_cood && y_cood < 112) {
                	printf("Kuitun\n"); pthread_mutex_lock(&temp_lock); temp = 292; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (184 < x_cood && x_cood < 192 && 72 < y_cood && y_cood < 80) {
                	printf("Beitun\n"); pthread_mutex_lock(&temp_lock); temp = 293; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (122 < x_cood && x_cood < 130 && 92 < y_cood && y_cood < 100) {
                	printf("Alashankou\n"); pthread_mutex_lock(&temp_lock); temp = 294; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (113 < x_cood && x_cood < 121 && 99 < y_cood && y_cood < 107) {
                	printf("Yining\n"); pthread_mutex_lock(&temp_lock); temp = 295; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (96 < x_cood && x_cood < 104 && 99 < y_cood && y_cood < 107) {
                	printf("Huoerguosi\n"); pthread_mutex_lock(&temp_lock); temp = 296; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (140 < x_cood && x_cood < 148 && 122 < y_cood && y_cood < 130) {
                	printf("Baluntai\n"); pthread_mutex_lock(&temp_lock); temp = 297; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (140 < x_cood && x_cood < 148 && 136 < y_cood && y_cood < 144) {
                	printf("Kuerle\n"); pthread_mutex_lock(&temp_lock); temp = 298; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (114 < x_cood && x_cood < 122 && 136 < y_cood && y_cood < 144) {
                	printf("Akesu\n"); pthread_mutex_lock(&temp_lock); temp = 299; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (100 < x_cood && x_cood < 108 && 150 < y_cood && y_cood < 158) {
                	printf("Bachu\n"); pthread_mutex_lock(&temp_lock); temp = 300; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (72 < x_cood && x_cood < 80 && 150 < y_cood && y_cood < 158) {
                	printf("Kashi\n"); pthread_mutex_lock(&temp_lock); temp = 301; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (332 < x_cood && x_cood < 340 && 295 < y_cood && y_cood < 303) {
                	printf("Dazhou\n"); pthread_mutex_lock(&temp_lock); temp = 302; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}
                
                if (314 < x_cood && x_cood < 322 && 300 < y_cood && y_cood < 308) {
                	printf("Suining\n"); pthread_mutex_lock(&temp_lock); temp = 303; pthread_mutex_unlock(&temp_lock);
                	Cursor(x_cood,y_cood,red); clickflag = 1;}			
            }
			else if(left_click==0 && clickflag==1 && stop_or_resume == 1){
             clickflag = 0;                    
			}
			else {
				     continue;
			}
      
			
		}
	}
}

////////////////////////////////////////////////////////////////
// VGA_read_pixel
////////////////////////////////////////////////////////////////

int VGA_read_pixel(int x, int y){

	int color; 
 	int  *pixel_ptr ;
	pixel_ptr = (int*)((char *)vga_pixel_ptr + (((y)*640+(x))<<1)) ; 
	color = *(short *)pixel_ptr ;
	
	return color;    
}

////////////////////////////////////////////////////////////////
// Cursor
////////////////////////////////////////////////////////////////

void Cursor(int x, int y, short color) {
 
            VGA_PIXEL(x,y,color);
            VGA_PIXEL(x-1,y,color);
				    VGA_PIXEL(x-2,y,color);
				    VGA_PIXEL(x+1,y,color);
				    VGA_PIXEL(x+2,y,color);
				    VGA_PIXEL(x,y-1,color);
				    VGA_PIXEL(x,y-2,color);
				    VGA_PIXEL(x,y+1,color);
				    VGA_PIXEL(x,y+2,color); 
}
  
////////////////////////////////////////////////////////////////
// map display
////////////////////////////////////////////////////////////////

int map_display(int argc,char **argv){

    HEADER fileHeader;
    INFOHEADER infoHeader;

    FILE*f = fopen(argv[1], "r");
    
    // reading headers 
    ReadUShort(f,&fileHeader.type,0);
    ReadUInt(f,&fileHeader.size,0);
    ReadUShort(f,&fileHeader.reserved1,0);
    ReadUShort(f,&fileHeader.reserved2,0);
    ReadUInt(f,&fileHeader.offset,0);
       
    if (fread(&infoHeader,sizeof(INFOHEADER),1,f) != 1) {
      fprintf(stderr,"Failed to read BMP info header\n\n");
      exit(-1);
    }
    
    //fprintf(stderr,"Image size = %d x %d\n",infoHeader.height,infoHeader.width);

    // reading image data
     unsigned char b[infoHeader.height][infoHeader.width];
     unsigned char g[infoHeader.height][infoHeader.width];
     unsigned char r[infoHeader.height][infoHeader.width];
     unsigned short c[infoHeader.height][infoHeader.width];

    int i;
    int j;
    
    for(i=infoHeader.height-1; i >=0; i--){
        for(j=0; j < infoHeader.width; j++){
            fread(&b[i][j], sizeof(unsigned char),1,f);
            fread(&g[i][j], sizeof(unsigned char),1,f);
            fread(&r[i][j], sizeof(unsigned char),1,f);
            c[i][j] = ((r[i][j] & 0xf8) << 8) | ((g[i][j] & 0xfc) << 3) | (b[i][j] >> 3);
            VGA_PIXEL(j,i,c[i][j]);
        }
    }
 
    return 0;
    
}

////////////////////////////////////////////////////////////////
// ReadUShort
////////////////////////////////////////////////////////////////

int ReadUShort(FILE *fptr,short unsigned *n,int swap)
{
   unsigned char *cptr,tmp;

   if (fread(n,2,1,fptr) != 1)
      return(0);
   if (swap) {
      cptr = (unsigned char *)n;
      tmp = cptr[0];
      cptr[0] = cptr[1];
      cptr[1] =tmp;
   }
   return(1);
}

////////////////////////////////////////////////////////////////
// ReadUInt
////////////////////////////////////////////////////////////////

int ReadUInt(FILE *fptr,unsigned int *n,int swap)
{
   unsigned char *cptr,tmp;

   if (fread(n,4,1,fptr) != 1)
      return(0);
   if (swap) {
      cptr = (unsigned char *)n;
      tmp = cptr[0];
      cptr[0] = cptr[3];
      cptr[3] = tmp;
      tmp = cptr[1];
      cptr[1] = cptr[2];
      cptr[2] = tmp;
   }
   return(1);
}

////////////////////////////////////////////////////////////////
// min_path
////////////////////////////////////////////////////////////////

void min_path(int start, int dest)
{
  if(neighbor[dest]!=start)
    {
      VGA_line(x_coord[dest],y_coord[dest],x_coord[neighbor[dest]],y_coord[neighbor[dest]],red);
      dest = neighbor[dest];
      min_path(start, dest);
      number2name(dest);
      printf(" ->\n");
    }
  else
    {
      VGA_line(x_coord[dest],y_coord[dest],x_coord[neighbor[dest]],y_coord[neighbor[dest]],red);
      number2name(start);
      printf(" ->\n");
    }
}

////////////////////////////////////////////////////////////////
// keyboard
////////////////////////////////////////////////////////////////

int keyboard()
{
  while(1){

  char Location[15];
  scanf("%s", Location);
  
  char Quit[15];
  strcpy(Quit, "Quit");
  if(strcmp(Location,Quit)==0) exit(0);
  
  char Frommap[15];
  strcpy(Frommap, "Frommap");
  if(strcmp(Location,Frommap)==0) {
     stop_or_resume = 1;
     return -1;
  }
  
  char Gulian[15];
  strcpy(Gulian,"Gulian");
  if(strcmp(Location,Gulian)==0)  return 0;

  
  char Tahe[15];
  strcpy(Tahe,"Tahe");
  if(strcmp(Location,Tahe)==0)  return 1;

  char Jiagedaqi[15];
  strcpy(Jiagedaqi,"Jiagedaqi");
  if(strcmp(Location,Jiagedaqi)==0)  return 2;

  char Yitulihe[15];
  strcpy(Yitulihe,"Yitulihe");
  if(strcmp(Location,Yitulihe)==0)  return 3;

  char Nenjiang[15];
  strcpy(Nenjiang,"Nenjiang");
  if(strcmp(Location,Nenjiang)==0)  return 4;

  char Nehe[15];
  strcpy(Nehe,"Nehe");
  if(strcmp(Location,Nehe)==0)  return 5;

  char Mangui[15];
  strcpy(Mangui,"Mangui");
  if(strcmp(Location,Mangui)==0)  return 6;

  char Yakeshi[15];
  strcpy(Yakeshi,"Yakeshi");
  if(strcmp(Location,Yakeshi)==0)  return 7;

  char Hailaer[15];
  strcpy(Hailaer,"Hailaer");
  if(strcmp(Location,Hailaer)==0)  return 8;

  char Yimin[15];
  strcpy(Yimin,"Yimin");
  if(strcmp(Location,Yimin)==0)  return 9;

  char Manzhouli[15];
  strcpy(Manzhouli,"Manzhouli");
  if(strcmp(Location,Manzhouli)==0)  return 10;

  char Boketu[15];
  strcpy(Boketu,"Boketu");
  if(strcmp(Location,Boketu)==0)  return 11;

  char Taerqi[15];
  strcpy(Taerqi,"Taerqi");
  if(strcmp(Location,Taerqi)==0)  return 12;

  char Qiqihaer[15];
  strcpy(Qiqihaer,"Qiqihaer");
  if(strcmp(Location,Qiqihaer)==0)  return 13;

  char Fuyu[15];
  strcpy(Fuyu,"Fuyu");
  if(strcmp(Location,Fuyu)==0)  return 14;

  char Beian[15];
  strcpy(Beian,"Beian");
  if(strcmp(Location,Beian)==0)  return 15;

  char Heihe[15];
  strcpy(Heihe,"Heihe");
  if(strcmp(Location,Heihe)==0)  return 16;

  char Suihua[15];
  strcpy(Suihua,"Suihua");
  if(strcmp(Location,Suihua)==0)  return 17;

  char Nancha[15];
  strcpy(Nancha,"Nancha");
  if(strcmp(Location,Nancha)==0)  return 18;

  char Wuyiling[15];
  strcpy(Wuyiling,"Wuyiling");
  if(strcmp(Location,Wuyiling)==0)  return 19;

  char Jiamusi[15];
  strcpy(Jiamusi,"Jiamusi");
  if(strcmp(Location,Jiamusi)==0)  return 20;

  char Hebei[15];
  strcpy(Hebei,"Hebei");
  if(strcmp(Location,Hebei)==0)  return 21;

  char Qianjin[15];
  strcpy(Qianjin,"Qianjin");
  if(strcmp(Location,Qianjin)==0)  return 22;

  char Dongfanghong[15];
  strcpy(Dongfanghong,"Dongfanghong");
  if(strcmp(Location,Dongfanghong)==0)  return 23;

  char Jixi[15];
  strcpy(Jixi,"Jixi");
  if(strcmp(Location,Jixi)==0)  return 24;

  char Linkou[15];
  strcpy(Linkou,"Linkou");
  if(strcmp(Location,Linkou)==0)  return 25;

  char Mudanjiang[15];
  strcpy(Mudanjiang,"Mudanjiang");
  if(strcmp(Location,Mudanjiang)==0)  return 26;

  char Suifenhe[15];
  strcpy(Suifenhe,"Suifenhe");
  if(strcmp(Location,Suifenhe)==0)  return 27;

  char Haerbing[15];
  strcpy(Haerbing,"Haerbing");
  if(strcmp(Location,Haerbing)==0)  return 28;

  char Daqing[15];
  strcpy(Daqing,"Daqing");
  if(strcmp(Location,Daqing)==0)  return 29;

  char Ranghulu[15];
  strcpy(Ranghulu,"Ranghulu");
  if(strcmp(Location,Ranghulu)==0)  return 30;

  char 	Yiershi[15];
  strcpy(Yiershi,"Yiershi");
  if(strcmp(Location,Yiershi)==0)  return 31;

  char Wulanhaote[15];
  strcpy(Wulanhaote,"Wulanhaote");
  if(strcmp(Location,Wulanhaote)==0)  return 32;

  char Baicheng[15];
  strcpy(Baicheng,"Baicheng");
  if(strcmp(Location,Baicheng)==0)  return 33;

  char Daan[15];
  strcpy(Daan,"Daan");
  if(strcmp(Location,Daan)==0)  return 34;

  char Changchun[15];
  strcpy(Changchun,"Changchun");
  if(strcmp(Location,Changchun)==0)  return 35;

  char Yushu[15];
  strcpy(Yushu,"Yushu");
  if(strcmp(Location,Yushu)==0)  return 36;

  char Jilin[15];
  strcpy(Jilin,"Jilin");
  if(strcmp(Location,Jilin)==0)  return 37;

  char Jiaohe[15];
  strcpy(Jiaohe,"Jiaohe");
  if(strcmp(Location,Jiaohe)==0)  return 38;

  char Dunhua[15];
  strcpy(Dunhua,"Dunhua");
  if(strcmp(Location,Dunhua)==0)  return 39;

  char Yanji[15];
  strcpy(Yanji,"Yanji");
  if(strcmp(Location,Yanji)==0)  return 40;

  char Tumen[15];
  strcpy(Tumen,"Tumen");
  if(strcmp(Location,Tumen)==0)  return 41;

  char Helong[15];
  strcpy(Helong,"Helong");
  if(strcmp(Location,Helong)==0)  return 42;

  char Yantongshan[15];
  strcpy(Yantongshan,"Yantongshan");
  if(strcmp(Location,Yantongshan)==0)  return 43;

  char Baishanzhen[15];
  strcpy(Baishanzhen,"Baishanzhen");
  if(strcmp(Location,Baishanzhen)==0)  return 44;

  char Taipingchuan[15];
  strcpy(Taipingchuan,"Taipingchuan");
  if(strcmp(Location,Taipingchuan)==0)  return 45;

  char Huolinhe[15];
  strcpy(Huolinhe,"Huolinhe");
  if(strcmp(Location,Huolinhe)==0)  return 46;

  char Taligentu[15];
  strcpy(Taligentu,"Taligentu");
  if(strcmp(Location,Taligentu)==0)  return 47;

  char Tongliao[15];
  strcpy(Tongliao,"Tongliao");
  if(strcmp(Location,Tongliao)==0)  return 48;

  char Zhengjiatun[15];
  strcpy(Zhengjiatun,"Zhengjiatun");
  if(strcmp(Location,Zhengjiatun)==0)  return 49;

  char Siping[15];
  strcpy(Siping,"Siping");
  if(strcmp(Location,Siping)==0)  return 50;

  char Tonghua[15];
  strcpy(Tonghua,"Tonghua");
  if(strcmp(Location,Tonghua)==0)  return 51;

  char Baihe[15];
  strcpy(Baihe,"Baihe");
  if(strcmp(Location,Baihe)==0)  return 52;

  char Jian[15];
  strcpy(Jian,"Jian");
  if(strcmp(Location,Jian)==0)  return 53;

  char Tieling[15];
  strcpy(Tieling,"Tieling");
  if(strcmp(Location,Tieling)==0)  return 54;

  char Shenyang[15];
  strcpy(Shenyang,"Shenyang");
  if(strcmp(Location,Shenyang)==0)  return 55;

  char Xinlitun[15];
  strcpy(Xinlitun,"Xinlitun");
  if(strcmp(Location,Xinlitun)==0)  return 56;

  char Anshan[15];
  strcpy(Anshan,"Anshan");
  if(strcmp(Location,Anshan)==0)  return 57;

  char Benxi[15];
  strcpy(Benxi,"Benxi");
  if(strcmp(Location,Benxi)==0)  return 58;

  char Kuandian[15];
  strcpy(Kuandian,"Kuandian");
  if(strcmp(Location,Kuandian)==0)  return 59;

  char Dandong[15];
  strcpy(Dandong,"Dandong");
  if(strcmp(Location,Dandong)==0)  return 60;

  char Dashiqiao[15];
  strcpy(Dashiqiao,"Dashiqiao");
  if(strcmp(Location,Dashiqiao)==0)  return 61;

  char Yingkou[15];
  strcpy(Yingkou,"Yingkou");
  if(strcmp(Location,Yingkou)==0)  return 62;

  char Wafangdian[15];
  strcpy(Wafangdian,"Wafangdian");
  if(strcmp(Location,Wafangdian)==0)  return 63;

  char Pulandian[15];
  strcpy(Pulandian,"Pulandian");
  if(strcmp(Location,Pulandian)==0)  return 64;

  char Lvshun[15];
  strcpy(Lvshun,"Lvshun");
  if(strcmp(Location,Lvshun)==0)  return 65;

  char Dalian[15];
  strcpy(Dalian,"Dalian");
  if(strcmp(Location,Dalian)==0)  return 66;

  char Jinzhou[15];
  strcpy(Jinzhou,"Jinzhou");
  if(strcmp(Location,Jinzhou)==0)  return 67;

  char Huludao[15];
  strcpy(Huludao,"Huludao");
  if(strcmp(Location,Huludao)==0)  return 68;

  char Yebaishou[15];
  strcpy(Yebaishou,"Yebaishou");
  if(strcmp(Location,Yebaishou)==0)  return 69;

  char Chifeng[15];
  strcpy(Chifeng,"Chifeng");
  if(strcmp(Location,Chifeng)==0)  return 70;

  char Shangbancheng[15];
  strcpy(Shangbancheng,"Shangbancheng");
  if(strcmp(Location,Shangbancheng)==0)  return 71;

  char Chengde[15];
  strcpy(Chengde,"Chengde");
  if(strcmp(Location,Chengde)==0)  return 72;

  char Qinhuangdao[15];
  strcpy(Qinhuangdao,"Qinhuangdao");
  if(strcmp(Location,Qinhuangdao)==0)  return 73;

  char Huairou[15];
  strcpy(Huairou,"Huairou");
  if(strcmp(Location,Huairou)==0)  return 74;

  char Tianjin[15];
  strcpy(Tianjin,"Tianjin");
  if(strcmp(Location,Tianjin)==0)  return 75;

  char Tangshan[15];
  strcpy(Tangshan,"Tangshan");
  if(strcmp(Location,Tangshan)==0)  return 76;

  char Zhangjiakou[15];
  strcpy(Zhangjiakou,"Zhangjiakou");
  if(strcmp(Location,Zhangjiakou)==0)  return 77;

  char Beijing[15];
  strcpy(Beijing,"Beijing");
  if(strcmp(Location,Beijing)==0)  return 78;

  char Bazhou[15];
  strcpy(Bazhou,"Bazhou");
  if(strcmp(Location,Bazhou)==0)  return 79;

  char Daban[15];
  strcpy(Daban,"Daban");
  if(strcmp(Location,Daban)==0)  return 80;

  char Sanggendalai[15];
  strcpy(Sanggendalai,"Sanggendalai");
  if(strcmp(Location,Sanggendalai)==0)  return 81;

  char Xilinhaote[15];
  strcpy(Xilinhaote,"Xilinhaote");
  if(strcmp(Location,Xilinhaote)==0)  return 82;

  char Benhong[15];
  strcpy(Benhong,"Benhong");
  if(strcmp(Location,Benhong)==0)  return 83;

  char Jiningnan[15];
  strcpy(Jiningnan,"Jiningnan");
  if(strcmp(Location,Jiningnan)==0)  return 84;

  char Huhehaote[15];
  strcpy(Huhehaote,"Huhehaote");
  if(strcmp(Location,Huhehaote)==0)  return 85;

  char Baotou[15];
  strcpy(Baotou,"Baotou");
  if(strcmp(Location,Baotou)==0)  return 86;

  char Baiyunebo[15];
  strcpy(Baiyunebo,"Baiyunebo");
  if(strcmp(Location,Baiyunebo)==0)  return 87;

  char Dongsheng[15];
  strcpy(Dongsheng,"Dongsheng");
  if(strcmp(Location,Dongsheng)==0)  return 88;

  char Linhe[15];
  strcpy(Linhe,"Linhe");
  if(strcmp(Location,Linhe)==0)  return 89;

  char Wuhaixi[15];
  strcpy(Wuhaixi,"Wuhaixi");
  if(strcmp(Location,Wuhaixi)==0)  return 90;

  char Jilantai[15];
  strcpy(Jilantai,"Jilantai");
  if(strcmp(Location,Jilantai)==0)  return 91;

  char Shizuishan[15];
  strcpy(Shizuishan,"Shizuishan");
  if(strcmp(Location,Shizuishan)==0)  return 92;

  char Yinchuan[15];
  strcpy(Yinchuan,"Yinchuan");
  if(strcmp(Location,Yinchuan)==0)  return 93;

  char Datong[15];
  strcpy(Datong,"Datong");
  if(strcmp(Location,Datong)==0)  return 94;

  char Erlianhaote[15];
  strcpy(Erlianhaote,"Erlianhaote");
  if(strcmp(Location,Erlianhaote)==0)  return 95;

  char Shenmubei[15];
  strcpy(Shenmubei,"Shenmubei");
  if(strcmp(Location,Shenmubei)==0)  return 96;

  char Daxin[15];
  strcpy(Daxin,"Daxin");
  if(strcmp(Location,Daxin)==0)  return 97;

  char Shuozhou[15];
  strcpy(Shuozhou,"Shuozhou");
  if(strcmp(Location,Shuozhou)==0)  return 98;

  char Yuanping[15];
  strcpy(Yuanping,"Yuanping");
  if(strcmp(Location,Yuanping)==0)  return 99;

  char Kelan[15];
  strcpy(Kelan,"Kelan");
  if(strcmp(Location,Kelan)==0)  return 100;

  char Yulinzhen[15];
  strcpy(Yulinzhen,"Yulinzhen");
  if(strcmp(Location,Yulinzhen)==0)  return 101;

  char Yanan[15];
  strcpy(Yanan,"Yanan");
  if(strcmp(Location,Yanan)==0)  return 102;

  char Liulin[15];
  strcpy(Liulin,"Liulin");
  if(strcmp(Location,Liulin)==0)  return 103;

  char Taiyuan[15];
  strcpy(Taiyuan,"Taiyuan");
  if(strcmp(Location,Taiyuan)==0)  return 104;

  char Yuci[15];
  strcpy(Yuci,"Yuci");
  if(strcmp(Location,Yuci)==0)  return 105;

  char Jiexiu[15];
  strcpy(Jiexiu,"Jiexiu");
  if(strcmp(Location,Jiexiu)==0)  return 106;

  char Shijiazhuang[15];
  strcpy(Shijiazhuang,"Shijiazhuang");
  if(strcmp(Location,Shijiazhuang)==0)  return 107;

  char Suning[15];
  strcpy(Suning,"Suning");
  if(strcmp(Location,Suning)==0)  return 108;

  char Cangzhou[15];
  strcpy(Cangzhou,"Cangzhou");
  if(strcmp(Location,Cangzhou)==0)  return 109;

  char Hengshui[15];
  strcpy(Hengshui,"Hengshui");
  if(strcmp(Location,Hengshui)==0)  return 110;

  char Dezhou[15];
  strcpy(Dezhou,"Dezhou");
  if(strcmp(Location,Dezhou)==0)  return 111;

  char Dongying[15];
  strcpy(Dongying,"Dongying");
  if(strcmp(Location,Dongying)==0)  return 112;

  char Changzhi[15];
  strcpy(Changzhi,"Changzhi");
  if(strcmp(Location,Changzhi)==0)  return 113;

  char Handan[15];
  strcpy(Handan,"Handan");
  if(strcmp(Location,Handan)==0)  return 114;

  char Liaocheng[15];
  strcpy(Liaocheng,"Liaocheng");
  if(strcmp(Location,Liaocheng)==0)  return 115;

  char Jinan[15];
  strcpy(Jinan,"Jinan");
  if(strcmp(Location,Jinan)==0)  return 116;

  char Zibo[15];
  strcpy(Zibo,"Zibo");
  if(strcmp(Location,Zibo)==0)  return 117;

  char Qingzhoushi[15];
  strcpy(Qingzhoushi,"Qingzhoushi");
  if(strcmp(Location,Qingzhoushi)==0)  return 118;

  char Weifang[15];
  strcpy(Weifang,"Weifang");
  if(strcmp(Location,Weifang)==0)  return 119;

  char Qingdao[15];
  strcpy(Qingdao,"Qingdao");
  if(strcmp(Location,Qingdao)==0)  return 120;

  char Yantai[15];
  strcpy(Yantai,"Yantai");
  if(strcmp(Location,Yantai)==0)  return 121;

  char Weihai[15];
  strcpy(Weihai,"Weihai");
  if(strcmp(Location,Weihai)==0)  return 122;

  char Houma[15];
  strcpy(Houma,"Houma");
  if(strcmp(Location,Houma)==0)  return 123;

  char Yueshan[15];
  strcpy(Yueshan,"Yueshan");
  if(strcmp(Location,Yueshan)==0)  return 124;

  char Anyang[15];
  strcpy(Anyang,"Anyang");
  if(strcmp(Location,Anyang)==0)  return 125;

  char Heze[15];
  strcpy(Heze,"Heze");
  if(strcmp(Location,Heze)==0)  return 126;

  char Yanzhou[15];
  strcpy(Yanzhou,"Yanzhou");
  if(strcmp(Location,Yanzhou)==0)  return 127;

  char Taishan[15];
  strcpy(Taishan,"Taishan");
  if(strcmp(Location,Taishan)==0)  return 128;

  char Sanyuan[15];
  strcpy(Sanyuan,"Sanyuan");
  if(strcmp(Location,Sanyuan)==0)  return 129;

  char Zhongjiacun[15];
  strcpy(Zhongjiacun,"Zhongjiacun");
  if(strcmp(Location,Zhongjiacun)==0)  return 130;

  char Huashan[15];
  strcpy(Huashan,"Huashan");
  if(strcmp(Location,Huashan)==0)  return 131;

  char Luoyang[15];
  strcpy(Luoyang,"Luoyang");
  if(strcmp(Location,Luoyang)==0)  return 132;

  char Zhengzhou[15];
  strcpy(Zhengzhou,"Zhengzhou");
  if(strcmp(Location,Zhengzhou)==0)  return 133;

  char Xinxiang[15];
  strcpy(Xinxiang,"Xinxiang");
  if(strcmp(Location,Xinxiang)==0)  return 134;

  char Kaifeng[15];
  strcpy(Kaifeng,"Kaifeng");
  if(strcmp(Location,Kaifeng)==0)  return 135;

  char Shangqiu[15];
  strcpy(Shangqiu,"Shangqiu");
  if(strcmp(Location,Shangqiu)==0)  return 136;

  char Xvzhou[15];
  strcpy(Xvzhou,"Xvzhou");
  if(strcmp(Location,Xvzhou)==0)  return 137;

  char Linyi[15];
  strcpy(Linyi,"Linyi");
  if(strcmp(Location,Linyi)==0)  return 138;

  char Rizhao[15];
  strcpy(Rizhao,"Rizhao");
  if(strcmp(Location,Rizhao)==0)  return 139;

  char Xianyang[15];
  strcpy(Xianyang,"Xianyang");
  if(strcmp(Location,Xianyang)==0)  return 140;

  char Xian[15];
  strcpy(Xian,"Xian");
  if(strcmp(Location,Xian)==0)  return 141;

  char Ankang[15];
  strcpy(Ankang,"Ankang");
  if(strcmp(Location,Ankang)==0)  return 142;

  char Danjiang[15];
  strcpy(Danjiang,"Danjiang");
  if(strcmp(Location,Danjiang)==0)  return 143;

  char Baofeng[15];
  strcpy(Baofeng,"Baofeng");
  if(strcmp(Location,Baofeng)==0)  return 144;

  char Nanyang[15];
  strcpy(Nanyang,"Nanyang");
  if(strcmp(Location,Nanyang)==0)  return 145;

  char Luohe[15];
  strcpy(Luohe,"Luohe");
  if(strcmp(Location,Luohe)==0)  return 146;

  char Fuyang[15];
  strcpy(Fuyang,"Fuyang");
  if(strcmp(Location,Fuyang)==0)  return 147;

  char Fuliji[15];
  strcpy(Fuliji,"Fuliji");
  if(strcmp(Location,Fuliji)==0)  return 148;

  char Xinyi[15];
  strcpy(Xinyi,"Xinyi");
  if(strcmp(Location,Xinyi)==0)  return 149;

  char Yuntai[15];
  strcpy(Yuntai,"Yuntai");
  if(strcmp(Location,Yuntai)==0)  return 150;

  char Bengbu[15];
  strcpy(Bengbu,"Bengbu");
  if(strcmp(Location,Bengbu)==0)  return 151;

  char Nanjing[15];
  strcpy(Nanjing,"Nanjing");
  if(strcmp(Location,Nanjing)==0)  return 152;

  char Yangzhou[15];
  strcpy(Yangzhou,"Yangzhou");
  if(strcmp(Location,Yangzhou)==0)  return 153;

  char Zhenjiang[15];
  strcpy(Zhenjiang,"Zhenjiang");
  if(strcmp(Location,Zhenjiang)==0)  return 154;

  char Haian[15];
  strcpy(Haian,"Haian");
  if(strcmp(Location,Haian)==0)  return 155;

  char Nantong[15];
  strcpy(Nantong,"Nantong");
  if(strcmp(Location,Nantong)==0)  return 156;

  char Xiangfan[15];
  strcpy(Xiangfan,"Xiangfan");
  if(strcmp(Location,Xiangfan)==0)  return 157;

  char Xinyang[15];
  strcpy(Xinyang,"Xinyang");
  if(strcmp(Location,Xinyang)==0)  return 158;

  char Hanchuan[15];
  strcpy(Hanchuan,"Hanchuan");
  if(strcmp(Location,Hanchuan)==0)  return 159;

  char Shuijiahu[15];
  strcpy(Shuijiahu,"Shuijiahu");
  if(strcmp(Location,Shuijiahu)==0)  return 160;

  char Hefei[15];
  strcpy(Hefei,"Hefei");
  if(strcmp(Location,Hefei)==0)  return 161;

  char Danyang[15];
  strcpy(Danyang,"Danyang");
  if(strcmp(Location,Danyang)==0)  return 162;

  char Wuxi[15];
  strcpy(Wuxi,"Wuxi");
  if(strcmp(Location,Wuxi)==0)  return 163;

  char Changzhou[15];
  strcpy(Changzhou,"Changzhou");
  if(strcmp(Location,Changzhou)==0)  return 164;

  char Suzhou[15];
  strcpy(Suzhou,"Suzhou");
  if(strcmp(Location,Suzhou)==0)  return 165;

  char Shanghai[15];
  strcpy(Shanghai,"Shanghai");
  if(strcmp(Location,Shanghai)==0)  return 166;

  char Jingmen[15];
  strcpy(Jingmen,"Jingmen");
  if(strcmp(Location,Jingmen)==0)  return 167;

  char Wuhan[15];
  strcpy(Wuhan,"Wuhan");
  if(strcmp(Location,Wuhan)==0)  return 168;

  char Hankou[15];
  strcpy(Hankou,"Hankou");
  if(strcmp(Location,Hankou)==0)  return 169;

  char Macheng[15];
  strcpy(Macheng,"Macheng");
  if(strcmp(Location,Macheng)==0)  return 170;

  char Wuhu[15];
  strcpy(Wuhu,"Wuhu");
  if(strcmp(Location,Wuhu)==0)  return 172;

  char Wuhubei[15];
  strcpy(Wuhubei,"Wuhubei");
  if(strcmp(Location,Wuhubei)==0)  return 173;

  char Tonglingbei[15];
  strcpy(Tonglingbei,"Tonglingbei");
  if(strcmp(Location,Tonglingbei)==0)  return 174;

  char Xuancheng[15];
  strcpy(Xuancheng,"Xuancheng");
  if(strcmp(Location,Xuancheng)==0)  return 175;

  char Changxing[15];
  strcpy(Changxing,"Changxing");
  if(strcmp(Location,Changxing)==0)  return 176;

  char Hangzhou[15];
  strcpy(Hangzhou,"Hangzhou");
  if(strcmp(Location,Hangzhou)==0)  return 177;

  char Anqing[15];
  strcpy(Anqing,"Anqing");
  if(strcmp(Location,Anqing)==0)  return 178;

  char Yichang[15];
  strcpy(Yichang,"Yichang");
  if(strcmp(Location,Yichang)==0)  return 179;

  char Zhicheng[15];
  strcpy(Zhicheng,"Zhicheng");
  if(strcmp(Location,Zhicheng)==0)  return 180;

  char Shimen[15];
  strcpy(Shimen,"Shimen");
  if(strcmp(Location,Shimen)==0)  return 181;

  char Yiyang[15];
  strcpy(Yiyang,"Yiyang");
  if(strcmp(Location,Yiyang)==0)  return 182;

  char Changsha[15];
  strcpy(Changsha,"Changsha");
  if(strcmp(Location,Changsha)==0)  return 183;

  char Yueyang[15];
  strcpy(Yueyang,"Yueyang");
  if(strcmp(Location,Yueyang)==0)  return 184;

  char Huaihua[15];
  strcpy(Huaihua,"Huaihua");
  if(strcmp(Location,Huaihua)==0)  return 185;

  char Loudi[15];
  strcpy(Loudi,"Loudi");
  if(strcmp(Location,Loudi)==0)  return 186;

  char Zhuzhou[15];
  strcpy(Zhuzhou,"Zhuzhou");
  if(strcmp(Location,Zhuzhou)==0)  return 187;

  char Xinyu[15];
  strcpy(Xinyu,"Xinyu");
  if(strcmp(Location,Xinyu)==0)  return 188;

  char Wenzhu[15];
  strcpy(Wenzhu,"Wenzhu");
  if(strcmp(Location,Wenzhu)==0)  return 189;

  char Xiangtang[15];
  strcpy(Xiangtang,"Xiangtang");
  if(strcmp(Location,Xiangtang)==0)  return 190;

  char Nanchang[15];
  strcpy(Nanchang,"Nanchang");
  if(strcmp(Location,Nanchang)==0)  return 191;

  char Jiujiang[15];
  strcpy(Jiujiang,"Jiujiang");
  if(strcmp(Location,Jiujiang)==0)  return 192;

  char Chizhou[15];
  strcpy(Chizhou,"Chizhou");
  if(strcmp(Location,Chizhou)==0)  return 193;

  char Yingtan[15];
  strcpy(Yingtan,"Yingtan");
  if(strcmp(Location,Yingtan)==0)  return 194;

  char Huangshan[15];
  strcpy(Huangshan,"Huangshan");
  if(strcmp(Location,Huangshan)==0)  return 195;

  char Hengfeng[15];
  strcpy(Hengfeng,"Hengfeng");
  if(strcmp(Location,Hengfeng)==0)  return 196;

  char Jinhuaxi[15];
  strcpy(Jinhuaxi,"Jinhuaxi");
  if(strcmp(Location,Jinhuaxi)==0)  return 197;

  char Qiandaohu[15];
  strcpy(Qiandaohu,"Qiandaohu");
  if(strcmp(Location,Qiandaohu)==0)  return 198;

  char Xiaoshan[15];
  strcpy(Xiaoshan,"Xiaoshan");
  if(strcmp(Location,Xiaoshan)==0)  return 199;

  char Ningbo[15];
  strcpy(Ningbo,"Ningbo");
  if(strcmp(Location,Ningbo)==0)  return 200;

  char Wenzhou[15];
  strcpy(Wenzhou,"Wenzhou");
  if(strcmp(Location,Wenzhou)==0)  return 201;

  char Wuyishan[15];
  strcpy(Wuyishan,"Wuyishan");
  if(strcmp(Location,Wuyishan)==0)  return 202;

  char Shaoyang[15];
  strcpy(Shaoyang,"Shaoyang");
  if(strcmp(Location,Shaoyang)==0)  return 203;

  char Yongzhou[15];
  strcpy(Yongzhou,"Yongzhou");
  if(strcmp(Location,Yongzhou)==0)  return 204;

  char Guilin[15];
  strcpy(Guilin,"Guilin");
  if(strcmp(Location,Guilin)==0)  return 205;

  char Hezhou[15];
  strcpy(Hezhou,"Hezhou");
  if(strcmp(Location,Hezhou)==0)  return 206;

  char Hengyang[15];
  strcpy(Hengyang,"Hengyang");
  if(strcmp(Location,Hengyang)==0)  return 207;

  char Binzhou[15];
  strcpy(Binzhou,"Binzhou");
  if(strcmp(Location,Binzhou)==0)  return 208;

  char Jinggangshan[15];
  strcpy(Jinggangshan,"Jinggangshan");
  if(strcmp(Location,Jinggangshan)==0)  return 209;

  char Jianzhen[15];
  strcpy(Jianzhen,"Jianzhen");
  if(strcmp(Location,Jianzhen)==0)  return 210;

  char Ganzhou[15];
  strcpy(Ganzhou,"Ganzhou");
  if(strcmp(Location,Ganzhou)==0)  return 211;

  char Zhangping[15];
  strcpy(Zhangping,"Zhangping");
  if(strcmp(Location,Zhangping)==0)  return 212;

  char Laizhou[15];
  strcpy(Laizhou,"Laizhou");
  if(strcmp(Location,Laizhou)==0)  return 213;

  char Nanping[15];
  strcpy(Nanping,"Nanping");
  if(strcmp(Location,Nanping)==0)  return 214;

  char Fuzhou[15];
  strcpy(Fuzhou,"Fuzhou");
  if(strcmp(Location,Fuzhou)==0)  return 215;

  char Xiaocuo[15];
  strcpy(Xiaocuo,"Xiaocuo");
  if(strcmp(Location,Xiaocuo)==0)  return 216;

  char Liuzhou[15];
  strcpy(Liuzhou,"Liuzhou");
  if(strcmp(Location,Liuzhou)==0)  return 219;

  char Litang[15];
  strcpy(Litang,"Litang");
  if(strcmp(Location,Litang)==0)  return 220;

  char Nanning[15];
  strcpy(Nanning,"Nanning");
  if(strcmp(Location,Nanning)==0)  return 221;

  char Pingxiang[15];
  strcpy(Pingxiang,"Pingxiang");
  if(strcmp(Location,Pingxiang)==0)  return 222;

  char Fangchenggang[15];
  strcpy(Fangchenggang,"Fangchenggang");
  if(strcmp(Location,Fangchenggang)==0)  return 223;

  char Qinzhou[15];
  strcpy(Qinzhou,"Qinzhou");
  if(strcmp(Location,Qinzhou)==0)  return 224;

  char Beihai[15];
  strcpy(Beihai,"Beihai");
  if(strcmp(Location,Beihai)==0)  return 225;

  char Zhanjiang[15];
  strcpy(Zhanjiang,"Zhanjiang");
  if(strcmp(Location,Zhanjiang)==0)  return 226;

  char Haikou[15];
  strcpy(Haikou,"Haikou");
  if(strcmp(Location,Haikou)==0)  return 227;

  char Shilu[15];
  strcpy(Shilu,"Shilu");
  if(strcmp(Location,Shilu)==0)  return 228;

  char Sanya[15];
  strcpy(Sanya,"Sanya");
  if(strcmp(Location,Sanya)==0)  return 229;

  char Yulin[15];
  strcpy(Yulin,"Yulin");
  if(strcmp(Location,Yulin)==0)  return 230;

  char Wuzhou[15];
  strcpy(Wuzhou,"Wuzhou");
  if(strcmp(Location,Wuzhou)==0)  return 231;

  char Sanshui[15];
  strcpy(Sanshui,"Sanshui");
  if(strcmp(Location,Sanshui)==0)  return 232;

  char Guangzhou[15];
  strcpy(Guangzhou,"Guangzhou");
  if(strcmp(Location,Guangzhou)==0)  return 233;

  char Shaoguan[15];
  strcpy(Shaoguan,"Shaoguan");
  if(strcmp(Location,Shaoguan)==0)  return 234;

  char Dongguan[15];
  strcpy(Dongguan,"Dongguan");
  if(strcmp(Location,Dongguan)==0)  return 235;

  char Shenzhen[15];
  strcpy(Shenzhen,"Shenzhen");
  if(strcmp(Location,Shenzhen)==0)  return 236;

  char Hongkong[15];
  strcpy(Hongkong,"Hongkong");
  if(strcmp(Location,Hongkong)==0)  return 237;

  char Longchuan[15];
  strcpy(Longchuan,"Longchuan");
  if(strcmp(Location,Longchuan)==0)  return 238;

  char Meizhou[15];
  strcpy(Meizhou,"Meizhou");
  if(strcmp(Location,Meizhou)==0)  return 239;

  char Shantou[15];
  strcpy(Shantou,"Shantou");
  if(strcmp(Location,Shantou)==0)  return 240;

  char Longyan[15];
  strcpy(Longyan,"Longyan");
  if(strcmp(Location,Longyan)==0)  return 241;

  char Zhangzhou[15];
  strcpy(Zhangzhou,"Zhangzhou");
  if(strcmp(Location,Zhangzhou)==0)  return 242;

  char Xiamen[15];
  strcpy(Xiamen,"Xiamen");
  if(strcmp(Location,Xiamen)==0)  return 243;

  char Hechun[15];
  strcpy(Hechun,"Hechun");
  if(strcmp(Location,Hechun)==0)  return 244;

  char Maoming[15];
  strcpy(Maoming,"Maoming");
  if(strcmp(Location,Maoming)==0)  return 245;

  char Baise[15];
  strcpy(Baise,"Baise");
  if(strcmp(Location,Baise)==0)  return 246;

  char Jinchengjiang[15];
  strcpy(Jinchengjiang,"Jinchengjiang");
  if(strcmp(Location,Jinchengjiang)==0)  return 247;

  char Guiding[15];
  strcpy(Guiding,"Guiding");
  if(strcmp(Location,Guiding)==0)  return 248;

  char Guiyang[15];
  strcpy(Guiyang,"Guiyang");
  if(strcmp(Location,Guiyang)==0)  return 249;

  char Weishe[15];
  strcpy(Weishe,"Weishe");
  if(strcmp(Location,Weishe)==0)  return 250;

  char Kunming[15];
  strcpy(Kunming,"Kunming");
  if(strcmp(Location,Kunming)==0)  return 251;

  char Zhanyi[15];
  strcpy(Zhanyi,"Zhanyi");
  if(strcmp(Location,Zhanyi)==0)  return 252;

  char Hongguo[15];
  strcpy(Hongguo,"Hongguo");
  if(strcmp(Location,Hongguo)==0)  return 253;

  char Yuxi[15];
  strcpy(Yuxi,"Yuxi");
  if(strcmp(Location,Yuxi)==0)  return 254;

  char Lijiang[15];
  strcpy(Lijiang,"Lijiang");
  if(strcmp(Location,Lijiang)==0)  return 255;

  char Xichang[15];
  strcpy(Xichang,"Xichang");
  if(strcmp(Location,Xichang)==0)  return 256;

  char Zunyi[15];
  strcpy(Zunyi,"Zunyi");
  if(strcmp(Location,Zunyi)==0)  return 257;

  char Dujiangyan[15];
  strcpy(Dujiangyan,"Dujiangyan");
  if(strcmp(Location,Dujiangyan)==0)  return 258;

  char Mianyang[15];
  strcpy(Mianyang,"Mianyang");
  if(strcmp(Location,Mianyang)==0)  return 259;

  char Wanzhou[15];
  strcpy(Wanzhou,"Wanzhou");
  if(strcmp(Location,Wanzhou)==0)  return 260;

  char Yibin[15];
  strcpy(Yibin,"Yibin");
  if(strcmp(Location,Yibin)==0)  return 261;

  char Guangtong[15];
  strcpy(Guangtong,"Guangtong");
  if(strcmp(Location,Guangtong)==0)  return 262;

  char Dali[15];
  strcpy(Dali,"Dali");
  if(strcmp(Location,Dali)==0)  return 263;

  char Panzhihua[15];
  strcpy(Panzhihua,"Panzhihua");
  if(strcmp(Location,Panzhihua)==0)  return 264;

  char Liupanshui[15];
  strcpy(Liupanshui,"Liupanshui");
  if(strcmp(Location,Liupanshui)==0)  return 265;

  char Neijiang[15];
  strcpy(Neijiang,"Neijiang");
  if(strcmp(Location,Neijiang)==0)  return 266;

  char Chongqing[15];
  strcpy(Chongqing,"Chongqing");
  if(strcmp(Location,Chongqing)==0)  return 267;

  char 	Emei[15];
  strcpy(Emei,"Emei");
  if(strcmp(Location,Emei)==0)  return 268;

  char Chengdu[15];
  strcpy(Chengdu,"Chengdu");
  if(strcmp(Location,Chengdu)==0)  return 269;

  char Guangyuan[15];
  strcpy(Guangyuan,"Guangyuan");
  if(strcmp(Location,Guangyuan)==0)  return 270;

  char Yangpingguan[15];
  strcpy(Yangpingguan,"Yangpingguan");
  if(strcmp(Location,Yangpingguan)==0)  return 271;

  char Baoji[15];
  strcpy(Baoji,"Baoji");
  if(strcmp(Location,Baoji)==0)  return 272;

  char Tianshui[15];
  strcpy(Tianshui,"Tianshui");
  if(strcmp(Location,Tianshui)==0)  return 273;

  char Pingliang[15];
  strcpy(Pingliang,"Pingliang");
  if(strcmp(Location,Pingliang)==0)  return 274;

  char Lanzhou[15];
  strcpy(Lanzhou,"Lanzhou");
  if(strcmp(Location,Lanzhou)==0)  return 275;

  char Xining[15];
  strcpy(Xining,"Xining");
  if(strcmp(Location,Xining)==0)  return 276;

  char Haergai[15];
  strcpy(Haergai,"Haergai");
  if(strcmp(Location,Haergai)==0)  return 277;

  char Zhongwei[15];
  strcpy(Zhongwei,"Zhongwei");
  if(strcmp(Location,Zhongwei)==0)  return 278;

  char Gantang[15];
  strcpy(Gantang,"Gantang");
  if(strcmp(Location,Gantang)==0)  return 279;

  char Honghui[15];
  strcpy(Honghui,"Honghui");
  if(strcmp(Location,Honghui)==0)  return 280;

  char Wuweinan[15];
  strcpy(Wuweinan,"Wuweinan");
  if(strcmp(Location,Wuweinan)==0)  return 281;

  char Geermu[15];
  strcpy(Geermu,"Geermu");
  if(strcmp(Location,Geermu)==0)  return 282;

  char Lasa[15];
  strcpy(Lasa,"Lasa");
  if(strcmp(Location,Lasa)==0)  return 283;

  char Jiayuguan[15];
  strcpy(Jiayuguan,"Jiayuguan");
  if(strcmp(Location,Jiayuguan)==0)  return 284;

  char Jingtieshan[15];
  strcpy(Jingtieshan,"Jingtieshan");
  if(strcmp(Location,Jingtieshan)==0)  return 285;

  char Liuyuan[15];
  strcpy(Liuyuan,"Liuyuan");
  if(strcmp(Location,Liuyuan)==0)  return 286;

  char Dunhuang[15];
  strcpy(Dunhuang,"Dunhuang");
  if(strcmp(Location,Dunhuang)==0)  return 287;

  char Hami[15];
  strcpy(Hami,"Hami");
  if(strcmp(Location,Hami)==0)  return 288;

  char Liaodun[15];
  strcpy(Liaodun,"Liaodun");
  if(strcmp(Location,Liaodun)==0)  return 289;

  char Tulufan[15];
  strcpy(Tulufan,"Tulufan");
  if(strcmp(Location,Tulufan)==0)  return 290;

  char Wulumuqi[15];
  strcpy(Wulumuqi,"Wulumuqi");
  if(strcmp(Location,Wulumuqi)==0)  return 291;

  char Kuitun[15];
  strcpy(Kuitun,"Kuitun");
  if(strcmp(Location,Kuitun)==0)  return 292;

  char Beitun[15];
  strcpy(Beitun,"Beitun");
  if(strcmp(Location,Beitun)==0)  return 293;

  char Alashankou[15];
  strcpy(Alashankou,"Alashankou");
  if(strcmp(Location,Alashankou)==0)  return 294;

  char Yining[15];
  strcpy(Yining,"Yining");
  if(strcmp(Location,Yining)==0)  return 295;

  char Huoerguosi[15];
  strcpy(Huoerguosi,"Huoerguosi");
  if(strcmp(Location,Huoerguosi)==0)  return 296;

  char Baluntai[15];
  strcpy(Baluntai,"Baluntai");
  if(strcmp(Location,Baluntai)==0)  return 297;

  char Kuerle[15];
  strcpy(Kuerle,"Kuerle");
  if(strcmp(Location,Kuerle)==0)  return 298;

  char Akesu[15];
  strcpy(Akesu,"Akesu");
  if(strcmp(Location,Akesu)==0)  return 299;

  char Bachu[15];
  strcpy(Bachu,"Bachu");
  if(strcmp(Location,Bachu)==0)  return 300;

  char Kashi[15];
  strcpy(Kashi,"Kashi");
  if(strcmp(Location,Kashi)==0)  return 301;

  char Dazhou[15];
  strcpy(Dazhou,"Dazhou");
  if(strcmp(Location,Dazhou)==0)  return 302;

  char Suining[15];
  strcpy(Suining,"Suining");
  if(strcmp(Location,Suining)==0)  return 303;

 }
}

////////////////////////////////////////////////////////////////
// number2name
////////////////////////////////////////////////////////////////

void number2name( int number )
{

  if(number == 0) printf("Gulian");
  if(number == 1) printf("Tahe");
  if(number == 2) printf("Jiagedaqi");  
  if(number == 3) printf("Yitulihe");
  if(number == 4) printf("Nenjiang");
  if(number == 5) printf("Nehe");
  if(number == 6) printf("Mangui");
  if(number == 7) printf("Yakeshi");
  if(number == 8) printf("Halaer");
  if(number == 9) printf("Yimin");
  if(number == 10) printf("Manzhouli");
  if(number == 11) printf("Boketu");
  if(number == 12) printf("Taerqi");
  if(number == 13) printf("Qiqihaer");
  if(number == 14) printf("Fuyu");
  if(number == 15) printf("Beian");
  if(number == 16) printf("Heihe");
  if(number == 17) printf("Suihua");
  if(number == 18) printf("Nancha");
  if(number == 19) printf("Wuyiling");
  if(number == 20) printf("Jiamusi");
  if(number == 21) printf("Hebei");
  if(number == 22) printf("Qianjin");
  if(number == 23) printf("Dongfanghong");
  if(number == 24) printf("Jixi");
  if(number == 25) printf("Linkou");
  if(number == 26) printf("Mudanjiang");
  if(number == 27) printf("Suifenhe");
  if(number == 28) printf("Haerbing");
  if(number == 29) printf("Daqing");
  if(number == 30) printf("Ranghulu");
  if(number == 31) printf("Yiershi");
  if(number == 32) printf("Wulanhaote");
  if(number == 33) printf("Baicheng");
  if(number == 34) printf("Daan");
  if(number == 35) printf("Changchun");
  if(number == 36) printf("Yushu");
  if(number == 37) printf("Jilin");
  if(number == 38) printf("Jiaohe");
  if(number == 39) printf("Dunhua");
  if(number == 40) printf("Yanji");
  if(number == 41) printf("Tumen");
  if(number == 42) printf("Helong");
  if(number == 43) printf("Yantongshan");
  if(number == 44) printf("Baishanzhen");
  if(number == 45) printf("Taipingchuan");
  if(number == 46) printf("Huolinhe");
  if(number == 47) printf("Taligentu");
  if(number == 48) printf("Tongliao");
  if(number == 49) printf("Zhengjiatun");
  if(number == 50) printf("Siping");
  if(number == 51) printf("Tonghua");
  if(number == 52) printf("Baihe");
  if(number == 53) printf("Jian");
  if(number == 54) printf("Tieling");
  if(number == 55) printf("Shenyang");
  if(number == 56) printf("Xinlitun");
  if(number == 57) printf("Anshan");
  if(number == 58) printf("Benxi");
  if(number == 59) printf("Kuandian");
  if(number == 60) printf("Dandong");
  if(number == 61) printf("Dashiqiao");
  if(number == 62) printf("Yingkou");
  if(number == 63) printf("Wafangdian");
  if(number == 64) printf("Pulandian");
  if(number == 65) printf("Lvshun");
  if(number == 66) printf("Dalian");
  if(number == 67) printf("Jinzhou");
  if(number == 68) printf("Huludao");
  if(number == 69) printf("Yebaishou");
  if(number == 70) printf("Chifeng");
  if(number == 71) printf("Shangbancheng");
  if(number == 72) printf("Chengde");
  if(number == 73) printf("Qinhuangdao");
  if(number == 74) printf("Huairou");
  if(number == 75) printf("Tianjin");
  if(number == 76) printf("Tangshan");
  if(number == 77) printf("Zhangjiakou");
  if(number == 78) printf("Beijing");
  if(number == 79) printf("Bazhou");
  if(number == 80) printf("Daban");
  if(number == 81) printf("Sanggendalai");
  if(number == 82) printf("Xilinhaote");
  if(number == 83) printf("Benhong");
  if(number == 84) printf("Jiningnan");
  if(number == 85) printf("Huhehaote");
  if(number == 86) printf("Baotou");
  if(number == 87) printf("Baiyunebo");
  if(number == 88) printf("Dongsheng");
  if(number == 89) printf("Linhe");
  if(number == 90) printf("Wuhaixi");
  if(number == 91) printf("Jilantai");
  if(number == 92) printf("Shizuishan");
  if(number == 93) printf("Yinchen");
  if(number == 94) printf("Datong");
  if(number == 95) printf("Erlianhaote");
  if(number == 96) printf("Shenmubei");
  if(number == 97) printf("Daxing");
  if(number == 98) printf("Shuozhou");
  if(number == 99) printf("Yuanping");

  if(number == 100) printf("Kelan");
  if(number == 101) printf("Yulinzhen");
  if(number == 102) printf("Yanan");  
  if(number == 103) printf("Liulin");
  if(number == 104) printf("Taiyuan");
  if(number == 105) printf("Yuci");
  if(number == 106) printf("Jiexiu");
  if(number == 107) printf("Shijiazhuang");
  if(number == 108) printf("Suning");
  if(number == 109) printf("Cangzhou");
  if(number == 110) printf("Hengshui");
  if(number == 111) printf("Dezhou");
  if(number == 112) printf("Dongying");
  if(number == 113) printf("Changzhi");
  if(number == 114) printf("Handan");
  if(number == 115) printf("Liaocheng");
  if(number == 116) printf("Jinan");
  if(number == 117) printf("Zibo");
  if(number == 118) printf("Qingzhoushi");
  if(number == 119) printf("Weifang");
  if(number == 120) printf("Qingdao");
  if(number == 121) printf("Yantai");
  if(number == 122) printf("Weihai");
  if(number == 123) printf("Houma");
  if(number == 124) printf("Yueshan");
  if(number == 125) printf("Anyang");
  if(number == 126) printf("Heze");
  if(number == 127) printf("Yanzhou");
  if(number == 128) printf("Taishan");
  if(number == 129) printf("Sanyuan");
  if(number == 130) printf("Zhongjiacun");
  if(number == 131) printf("Huashan");
  if(number == 132) printf("Luoyang");
  if(number == 133) printf("Zhengzhou");
  if(number == 134) printf("Xinxiang");
  if(number == 135) printf("Kaifeng");
  if(number == 136) printf("Shangqiu");
  if(number == 137) printf("Xvzhou");
  if(number == 138) printf("Linyi");
  if(number == 139) printf("Rizhao");
  if(number == 140) printf("Xianyang");
  if(number == 141) printf("Xian"); 
  if(number == 142) printf("Ankang");
  if(number == 143) printf("Danjiang");
  if(number == 144) printf("Baofeng");
  if(number == 145) printf("Nanyang");
  if(number == 146) printf("Luohe");
  if(number == 147) printf("Fuyang");
  if(number == 148) printf("Fuliji");
  if(number == 149) printf("Xinyi");
  if(number == 150) printf("Yuntai");
  if(number == 151) printf("Bengbu");
  if(number == 152) printf("Nanjing");
  if(number == 153) printf("Yangzhou");
  if(number == 154) printf("Zhenjiang");
  if(number == 155) printf("Haian");
  if(number == 156) printf("Nantong");
  if(number == 157) printf("Xiangfan");
  if(number == 158) printf("Xinyang");
  if(number == 159) printf("Hanchuan");
  if(number == 160) printf("Shuijiahu");
  if(number == 161) printf("Hefei");
  if(number == 162) printf("Danyang");
  if(number == 163) printf("Wuxi");
  if(number == 164) printf("Changzhou");
  if(number == 165) printf("Suzhou");
  if(number == 166) printf("Shanghai");
  if(number == 167) printf("Jingmen");
  if(number == 168) printf("Wuhan");
  if(number == 169) printf("Hankou");
  if(number == 170) printf("Macheng");

  if(number == 172) printf("Wuhu");
  if(number == 173) printf("Wuhubei");
  if(number == 174) printf("Tonglinbei");
  if(number == 175) printf("Xuancheng");
  if(number == 176) printf("Changxing");
  if(number == 177) printf("Hangzhou");
  if(number == 178) printf("Anqing");
  if(number == 179) printf("Yichang");
  if(number == 180) printf("Zhicheng");
  if(number == 181) printf("Shimen");
  if(number == 182) printf("Yiyang");
  if(number == 183) printf("Changsha");
  if(number == 184) printf("Yueyang");
  if(number == 185) printf("Huaihua");
  if(number == 186) printf("Loudi");
  if(number == 187) printf("Zhuzhou");
  if(number == 188) printf("Xinyu");
  if(number == 189) printf("Wenzhu");
  if(number == 190) printf("Xiangtang");
  if(number == 191) printf("Nanchang");
  if(number == 192) printf("Jiujiang");
  if(number == 193) printf("Chizhou");
  if(number == 194) printf("Yingtan");
  if(number == 195) printf("Huangshan");
  if(number == 196) printf("Hengfeng");
  if(number == 197) printf("Jinhuaxi");
  if(number == 198) printf("Qiandaohu");
  if(number == 199) printf("Xiaoshan");

  if(number == 200) printf("Ningbo");
  if(number == 201) printf("Wenzhou");
  if(number == 202) printf("Wuyishan");  
  if(number == 203) printf("Shaoyang");
  if(number == 204) printf("Yongzhou");
  if(number == 205) printf("Guilin");
  if(number == 206) printf("Hezhou");
  if(number == 207) printf("Hengyang");
  if(number == 208) printf("Binzhou");
  if(number == 209) printf("Jinggangshan");
  if(number == 210) printf("Jianzhen");
  if(number == 211) printf("Ganzhou");
  if(number == 212) printf("Zhangping");
  if(number == 213) printf("Laizhou");
  if(number == 214) printf("Nanping");
  if(number == 215) printf("Fuzhou");
  if(number == 216) printf("Xiaocuo");

  if(number == 219) printf("Liuzhou");
  if(number == 220) printf("Litang");
  if(number == 221) printf("Nanning");
  if(number == 222) printf("Pingxiang");
  if(number == 223) printf("Fangchenggang");
  if(number == 224) printf("Qingzhou");
  if(number == 225) printf("Beihai");
  if(number == 226) printf("Zhanjiang");
  if(number == 227) printf("Haikou");
  if(number == 228) printf("Shilu");
  if(number == 229) printf("Sanya");
  if(number == 230) printf("Yulin");
  if(number == 231) printf("Wuzhou");
  if(number == 232) printf("Sanshui");
  if(number == 233) printf("Guangzhou");
  if(number == 234) printf("Shaoguan");
  if(number == 235) printf("Dongguan");
  if(number == 236) printf("Shenzhen");
  if(number == 237) printf("Hongkong");
  if(number == 238) printf("Longchuan");
  if(number == 239) printf("Meizhou");
  if(number == 240) printf("Shantou");
  if(number == 241) printf("Longyan");
  if(number == 242) printf("Zhangzhou");
  if(number == 243) printf("Xiamen");
  if(number == 244) printf("Hechun");
  if(number == 245) printf("Maoming");
  if(number == 246) printf("Baise");
  if(number == 247) printf("Jinchengjiang");
  if(number == 248) printf("Guiding");
  if(number == 249) printf("Guiyang");
  if(number == 250) printf("Weishe");
  if(number == 251) printf("Kunming");
  if(number == 252) printf("Zhanyi");
  if(number == 253) printf("Hongguo");
  if(number == 254) printf("Yuxi");
  if(number == 255) printf("Lijiang");
  if(number == 256) printf("Xichang");
  if(number == 257) printf("Zunyi");
  if(number == 258) printf("Dujiangyan");
  if(number == 259) printf("Mianyang");
  if(number == 260) printf("Wanzhou");
  if(number == 261) printf("Yibin");
  if(number == 262) printf("Guangtong");
  if(number == 263) printf("Dali");
  if(number == 264) printf("Panzhihua");
  if(number == 265) printf("Liupanshui");
  if(number == 266) printf("Neijiang");
  if(number == 267) printf("Chongqing");
  if(number == 268) printf("Emei");
  if(number == 269) printf("Chengdu");
  if(number == 270) printf("Guangyuan");
  if(number == 271) printf("Yangpingguan");
  if(number == 272) printf("Baoji");
  if(number == 273) printf("Tianshui");
  if(number == 274) printf("Pingliang");
  if(number == 275) printf("Lanzhou");
  if(number == 276) printf("Xining");
  if(number == 277) printf("Haergai");
  if(number == 278) printf("Zhongwei");
  if(number == 279) printf("Gantang");
  if(number == 280) printf("Honghui");
  if(number == 281) printf("Wuweinan");
  if(number == 282) printf("Geermu");
  if(number == 283) printf("Lasa");
  if(number == 284) printf("Jiayuguan");
  if(number == 285) printf("Jingtieshan");
  if(number == 286) printf("Liuyuan");
  if(number == 287) printf("Dunhua");
  if(number == 288) printf("Hami");
  if(number == 289) printf("Liaodun");
  if(number == 290) printf("Tulufan");
  if(number == 291) printf("Wulumuqi");
  if(number == 292) printf("Kuitun");
  if(number == 293) printf("Beitun");
  if(number == 294) printf("Alashankou");
  if(number == 295) printf("Yining");
  if(number == 296) printf("Huoerguosi");
  if(number == 297) printf("Baluntai");
  if(number == 298) printf("Kuerle");
  if(number == 299) printf("Akesu");
  if(number == 300) printf("Bachu");
  if(number == 301) printf("Kashi");
  if(number == 302) printf("Dazhou");
  if(number == 303) printf("Suining");

}
/****************************************************************************************
// Delay
****************************************************************************************/
void delay(){
   int c, d;
 
   for (c = 1; c <= 100; c++)
       for (d = 1; d <= 100; d++)
       {
       }  
       
}

/****************************************************************************************
 * Subroutine to send a string of text to the VGA monitor 
****************************************************************************************/

void VGA_text(int x, int y, char * text_ptr)
{
  	volatile char * character_buffer = (char *) vga_char_ptr ;	// VGA character buffer
	int offset;
	/* assume that the text string fits on one line */
	offset = (y << 7) + x;
	while ( *(text_ptr) )
	{
		// write to the character buffer
		*(character_buffer + offset) = *(text_ptr);	
		++text_ptr;
		++offset;
	}
}

/****************************************************************************************
 * Subroutine to clear text to the VGA monitor 
****************************************************************************************/
void VGA_text_clear()
{
  	volatile char * character_buffer = (char *) vga_char_ptr ;	// VGA character buffer
	int offset, x, y;
	for (x=0; x<70; x++){
		for (y=0; y<40; y++){
	/* assume that the text string fits on one line */
			offset = (y << 7) + x;
			// write to the character buffer
			*(character_buffer + offset) = ' ';		
		}
	}
}

/****************************************************************************************
 * Draw a filled rectangle on the VGA monitor 
****************************************************************************************/
#define SWAP(X,Y) do{int temp=X; X=Y; Y=temp;}while(0) 

void VGA_box(int x1, int y1, int x2, int y2, short pixel_color)
{
	char  *pixel_ptr ; 
	int row, col;

	/* check and fix box coordinates to be valid */
	if (x1>639) x1 = 639;
	if (y1>479) y1 = 479;
	if (x2>639) x2 = 639;
	if (y2>479) y2 = 479;
	if (x1<0) x1 = 0;
	if (y1<0) y1 = 0;
	if (x2<0) x2 = 0;
	if (y2<0) y2 = 0;
	if (x1>x2) SWAP(x1,x2);
	if (y1>y2) SWAP(y1,y2);
	for (row = y1; row <= y2; row++)
		for (col = x1; col <= x2; ++col)
		{
			//640x480
			//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
			// set pixel color
			//*(char *)pixel_ptr = pixel_color;	
			VGA_PIXEL(col,row,pixel_color);	
		}
}

/****************************************************************************************
 * Draw a outline rectangle on the VGA monitor 
****************************************************************************************/
#define SWAP(X,Y) do{int temp=X; X=Y; Y=temp;}while(0) 

void VGA_rect(int x1, int y1, int x2, int y2, short pixel_color)
{
	char  *pixel_ptr ; 
	int row, col;

	/* check and fix box coordinates to be valid */
	if (x1>639) x1 = 639;
	if (y1>479) y1 = 479;
	if (x2>639) x2 = 639;
	if (y2>479) y2 = 479;
	if (x1<0) x1 = 0;
	if (y1<0) y1 = 0;
	if (x2<0) x2 = 0;
	if (y2<0) y2 = 0;
	if (x1>x2) SWAP(x1,x2);
	if (y1>y2) SWAP(y1,y2);
	// left edge
	col = x1;
	for (row = y1; row <= y2; row++){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;	
		VGA_PIXEL(col,row,pixel_color);		
	}
		
	// right edge
	col = x2;
	for (row = y1; row <= y2; row++){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;	
		VGA_PIXEL(col,row,pixel_color);		
	}
	
	// top edge
	row = y1;
	for (col = x1; col <= x2; ++col){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;	
		VGA_PIXEL(col,row,pixel_color);
	}
	
	// bottom edge
	row = y2;
	for (col = x1; col <= x2; ++col){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;
		VGA_PIXEL(col,row,pixel_color);
	}
}

/****************************************************************************************
 * Draw a horixontal line on the VGA monitor 
****************************************************************************************/
#define SWAP(X,Y) do{int temp=X; X=Y; Y=temp;}while(0) 

void VGA_Hline(int x1, int y1, int x2, short pixel_color)
{
	char  *pixel_ptr ; 
	int row, col;

	/* check and fix box coordinates to be valid */
	if (x1>639) x1 = 639;
	if (y1>479) y1 = 479;
	if (x2>639) x2 = 639;
	if (x1<0) x1 = 0;
	if (y1<0) y1 = 0;
	if (x2<0) x2 = 0;
	if (x1>x2) SWAP(x1,x2);
	// line
	row = y1;
	for (col = x1; col <= x2; ++col){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;	
		VGA_PIXEL(col,row,pixel_color);		
	}
}

/****************************************************************************************
 * Draw a vertical line on the VGA monitor 
****************************************************************************************/
#define SWAP(X,Y) do{int temp=X; X=Y; Y=temp;}while(0) 

void VGA_Vline(int x1, int y1, int y2, short pixel_color)
{
	char  *pixel_ptr ; 
	int row, col;

	/* check and fix box coordinates to be valid */
	if (x1>639) x1 = 639;
	if (y1>479) y1 = 479;
	if (y2>479) y2 = 479;
	if (x1<0) x1 = 0;
	if (y1<0) y1 = 0;
	if (y2<0) y2 = 0;
	if (y1>y2) SWAP(y1,y2);
	// line
	col = x1;
	for (row = y1; row <= y2; row++){
		//640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (row<<10)    + col ;
		// set pixel color
		//*(char *)pixel_ptr = pixel_color;	
		VGA_PIXEL(col,row,pixel_color);			
	}
}


/****************************************************************************************
 * Draw a filled circle on the VGA monitor 
****************************************************************************************/

void VGA_disc(int x, int y, int r, short pixel_color)
{
	char  *pixel_ptr ; 
	int row, col, rsqr, xc, yc;
	
	rsqr = r*r;
	
	for (yc = -r; yc <= r; yc++)
		for (xc = -r; xc <= r; xc++)
		{
			col = xc;
			row = yc;
			// add the r to make the edge smoother
			if(col*col+row*row <= rsqr+r){
				col += x; // add the center point
				row += y; // add the center point
				//check for valid 640x480
				if (col>639) col = 639;
				if (row>479) row = 479;
				if (col<0) col = 0;
				if (row<0) row = 0;
				//pixel_ptr = (char *)vga_pixel_ptr + (row<<10) + col ;
				// set pixel color
				//*(char *)pixel_ptr = pixel_color;
				VGA_PIXEL(col,row,pixel_color);	
			}
					
		}
}

/****************************************************************************************
 * Draw a line on the VGA monitor 
****************************************************************************************/

void VGA_line(int x1, int y1, int x2, int y2, short c) {
	int e;
	signed int dx,dy,j, temp;
	signed int s1,s2, xchange;
     signed int x,y;
	char *pixel_ptr ;
	
	/* check and fix line coordinates to be valid */
	if (x1>639) x1 = 639;
	if (y1>479) y1 = 479;
	if (x2>639) x2 = 639;
	if (y2>479) y2 = 479;
	if (x1<0) x1 = 0;
	if (y1<0) y1 = 0;
	if (x2<0) x2 = 0;
	if (y2<0) y2 = 0;
        
	x = x1;
	y = y1;
	
	//take absolute value
	if (x2 < x1) {
		dx = x1 - x2;
		s1 = -1;
	}

	else if (x2 == x1) {
		dx = 0;
		s1 = 0;
	}

	else {
		dx = x2 - x1;
		s1 = 1;
	}

	if (y2 < y1) {
		dy = y1 - y2;
		s2 = -1;
	}

	else if (y2 == y1) {
		dy = 0;
		s2 = 0;
	}

	else {
		dy = y2 - y1;
		s2 = 1;
	}

	xchange = 0;   

	if (dy>dx) {
		temp = dx;
		dx = dy;
		dy = temp;
		xchange = 1;
	} 

	e = ((int)dy<<1) - dx;  
	 
	for (j=0; j<=dx; j++) {
		//video_pt(x,y,c); //640x480
		//pixel_ptr = (char *)vga_pixel_ptr + (y<<10)+ x; 
		// set pixel color
		//*(char *)pixel_ptr = c;
		VGA_PIXEL(x,y,c);			
		 
		if (e>=0) {
			if (xchange==1) x = x + s1;
			else y = y + s2;
			e = e - ((int)dx<<1);
		}

		if (xchange==1) y = y + s2;
		else x = x + s1;

		e = e + ((int)dy<<1);
	}
}





