public static char[][] build_block(String plain, int row,int period, int direction)
	{
		String plain_u=plain.toUpperCase();
		if(row==-1)
		{
		   row=plain_u.length()/period;
		}
		if(plain_u.length()%period!=0)
		{
			row++;
		}
		char[][] result=new char[row][period];
		if(direction==1)//1 for vertical, 0 for horizontal
		{
			int cur_row=0;
			int cur_col=0;
			for(int i=0;i<plain_u.length();i++)
			{
				result[cur_row][cur_col]=plain_u.charAt(i);
				if(cur_row == row-1)
				{
					cur_row=0;
					cur_col++;
				}
				else
				{
					cur_row++;
				}
			}
		}
		else
		{
			int cur_row=0;
			int cur_col=0;
			for(int i=0;i<plain_u.length();i++)
			{
				result[cur_row][cur_col]=plain_u.charAt(i);
				if(cur_col == period-1)
				{
					cur_row++;
					cur_col=0;
				}
				else
				{
					cur_col++;
				}
			}
		}
		return result;
	}