if (NON_EMPTY_SELECTION)
{
	data_rows  	 = Columns 	(SELECTED_CHART_ROWS);

	if (data_rows % 2 == 0)
	{
		temp = -1;
		data_columns = -1;
		
		for (count = 0; count<data_rows; count = count+1)
		{
			temp2 = SELECTED_CHART_COLS[count];
			if (temp<0)
			{
				temp = temp2;
			}
			else
			{
				if (temp!=temp2)
				{
					if (data_columns<0)
					{
						data_columns = temp2;
					}
					else
					{
						if (temp2!=data_columns)
						{
							break;
						}
					}
				}
			}
		}
		
		if ((count == data_rows)&&(data_columns>=0)&&(temp>=0))
		{
			for (count = 0; count < data_rows; count = count+2)
			{
				if (SELECTED_CHART_ROWS[count]!=SELECTED_CHART_ROWS[count+1])
				{
					break;
				}
			}
		
			if (count==data_rows)
			{
			
				SELECTED_CHART_ROWS = {2,data_rows/2};
				for (count = 0; count < data_rows; count = count+2)
				{
					SELECTED_CHART_ROWS[0][count/2]=SELECTED_CHART_DATA[count];
					SELECTED_CHART_ROWS[1][count/2]=SELECTED_CHART_DATA[count+1];
				}
				SELECTED_CHART_DATA = SELECTED_CHART_ROWS;
				data_rows = data_rows/2;
				
				HASH_TABLE_1 = {};
				HASH_TABLE_2 = {};
				
				for (count = 0; count < data_rows; count = count+1)
				{
					value = SELECTED_CHART_ROWS[0][count];
					if (HASH_TABLE_1[value]==0)
					{
						HASH_TABLE_1[value] = Abs(HASH_TABLE_1)+1;
					}
					value = SELECTED_CHART_ROWS[1][count];
					if (HASH_TABLE_2[value]==0)
					{
						HASH_TABLE_2[value] = Abs(HASH_TABLE_2)+1;
					}
				}
				
				
				
				C_TABLE = {Abs(HASH_TABLE_1),Abs(HASH_TABLE_2)};
				
				for (count = 0; count < data_rows; count = count+1)
				{
					value = SELECTED_CHART_ROWS[0][count];
					value = HASH_TABLE_1[value]-1;
					value2 = SELECTED_CHART_ROWS[1][count];
					value2 = HASH_TABLE_2[value2]-1;
					C_TABLE[value][value2] = C_TABLE[value][value2] + 1;
				}
				
			    data_rows = Abs(HASH_TABLE_1);
				data_cols = Abs(HASH_TABLE_2);

				labels = {1,data_cols+1};
				
				keys = Rows (HASH_TABLE_2);
				
				for (count = 0; count < data_cols; count = count+1)
				{
					labels[count] = "" + keys[count];
				}


				keys = Rows (HASH_TABLE_1);
				firstString = "Categories";
				
				for (count = 0; count < data_rows; count = count+1)
				{
					firstString = firstString + ";"+ keys[count];
				}
				
				labels [data_cols] = firstString;
				
				fprintf (stdout, "\nFisher's exact p:", CChi2(C_TABLE,0), "\n");

				OpenWindow (CHARTWINDOW,{{"Contigency Table"}
								   {"labels"},
								   {"C_TABLE"},
								   {"None"},
								   {""},
								   {""},
								   {"Index"},
								   {""},
								   {"Value"},
								   {"0"}
								   {""}
								   {"-1;-1"}
								   {"10;1.309;0.785398"}
								   {"Times:12:0;Times:10:0;Times:12:2"}
								   {"0;0;16777215;1644825;0;0;6579300;11842740;13158600;14474460;0;3947580;4294967295;15670812;6845928;16771158;2984993;9199669;7018159;1460610;16748822;11184810;14173291"}
								   {"16"}
								   },
								   "SCREEN_WIDTH-60;SCREEN_HEIGHT-50;30;50");
								   
				return 0;
			}
		}
	}

	fprintf (stdout, "Please select two columns with the observations for two variables.\n");
}
else
{
	NON_EMPTY_SELECTION = -1;
}
