/**
 * 注意事项:
 *         1、本程序为java程序,同时感谢您花费宝贵的时间来阅读本文档;
 *         2、请注意包名为:practice,文件名为:ImageCombining,注意检查,以防一些不必要的麻烦;
 *         3、在完成确认2中的内容后,本程序可以直接运行,因为本软件说明都在注释中;
 *         4、本人已经尽可能对代码进行全面的注释,但由于个人能力、阅历等原因,有些细节可能并没有
 *                 详细阐述,或者有疏漏,请谅解。
 *         5、您可以在/home/soft1/CharMapsImage.jpg下找到小窗口中的图,是一张合成图,是《终结TTS无图
 *                 时代——Java原创巨作》的原图。
 */
package practice;
import java.awt.Graphics;
import java.awt.p_w_picpath.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.p_w_picpathio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
 * RGB图像合成<br><ol>
 *         <li>本软件是采用CharMaps逆向思路,图像合成。另外写了一个RGBOfCharMaps对图片进行R、B、G色彩提取的小软件,是
 *                 CharMaps的修改版。
 *         <li>本程序中的R、G、B三个数组均为使用RGBOfCharMaps自动生成的;
 *         <li>如果您对CharMaps不了解,请查阅《终结TTS无图时代——Java原创》,里面有详细的注释;
 *         <li>本软件合成的图就是《终结TTS无图时代——Java原创》的原图,经合成,图片上有了不少噪声,这里就不进行去噪工作,更
 *                 确切的说是:不懂!。
 * @author soft1
 *
 */
public class ImageCombining extends JPanel {
    /**
     * 设置图片缓冲区的宽
     */
    private static int width = 86;
    /**
     * 设置图片缓冲区的高
     */
    private static int height = 33;
    /**
     * 声明一个BufferedImage
     */
    private static BufferedImage bufferedImage;
    @Override
    public void paint(Graphics g) {
        //绘制图像
        g.drawImage(bufferedImage, 5, 5, null);
    }
    public static void main(String[] args) {
        try {
        //图像保存路径
        File file = new File("/home/soft1/CharMapsImage.jpg");
        //设置图像缓冲区
        bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        //图形合成函数
        p_w_picpathCombining(file,bufferedImage);
        //将图像写入文件
        ImageIO.write(bufferedImage, "jpg", file);
        //将图像通过JFrame显示出来
        showJFrame();
        } catch (IOException e) {
            System.out.println(e);
        }
    }
    /**
     * JFrame显示函数,完成任务如下:<br><ol>
     *         <li>创建一个ImageCombining,这个类继承自JPanel;
     *         <li>创建JFrame,并对JFrame进行设置;
     *         <li>显示JFrame;   
     */
    private static void showJFrame() {
        JPanel jPanel = new ImageCombining();
        JFrame jFrame = new JFrame();
        jFrame.setTitle("ImageCombining");
        jFrame.setSize(width+20, height+33);
        jFrame.add(jPanel);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setLocationRelativeTo(null);
        jFrame.setVisible(true);   
    }
    /**
     * 图像合成函数,完成任务如下:<br><ol>
     *         <li>从R、G、B三个数组中提取三基色;
     *         <li>对三基色进行合成;
     *         <li>将对应位置三基色保存进入图片缓冲区对应位置
     *        
     * @param file
     * @param bufferedImage2
     */
    private static void p_w_picpathCombining(File file, BufferedImage bufferedImage2) {
        for (int row = 0; row < height; row++) {
            for (int col = 0; col < width; col++) {
                int rgb = 0;
                //提取RGB三色值
                int r = R[row][col];
                int b = B[row][col];
                int g = G[row][col];
                //合成RGB三色值
                rgb = ((r<<16)|(g<<8)|b)&0xffffff;
                //将RGB三色值保存于对应的bufferedImage坐标中
                bufferedImage.setRGB(col, row, rgb);
            }
        }   
    }
    private static int[][] R = {{255,255,255,255,255,255,255,255,255,255,254,254,248,255,255,255,250,255,251,253,255,253,255,254,255,255,255,255,255,255,255,255,255,254,254,255,248,255,253,255,255,255,255,255,255,255,255,255,251,255,253,255,254,255,255,255,254,255,248,252,255,252,255,255,253,255,249,255,255,255,254,253,255,253,255,243,255,255,255,251,252,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,252,250,251,255,255,254,253,248,255,247,255,255,251,255,246,251,255,255,255,255,255,255,255,255,252,250,255,248,255,255,255,243,255,255,255,255,255,255,255,255,255,251,252,248,255,247,254,253,255,251,255,255,255,249,255,250,255,255,243,255,244,249,255,255,250,255,254,255,255,252,255,255,255,255,255,253,252,253,},
        {255,255,255,255,255,255,255,255,250,255,255,254,250,255,253,255,255,157,38,0,47,149,251,255,255,255,255,255,255,255,255,255,253,255,255,255,255,243,255,255,255,255,255,255,255,255,255,255,252,255,250,255,246,255,252,255,252,255,244,243,255,252,255,255,254,255,255,250,255,255,245,255,255,248,255,253,255,248,255,255,255,255,255,255,255,253,},
        {255,255,255,255,255,255,255,255,252,0,0,0,10,252,255,248,151,8,8,0,5,0,155,253,255,255,255,255,255,255,255,255,255,252,243,251,252,253,255,255,255,255,255,255,255,255,255,255,248,249,255,252,251,255,255,254,249,255,255,255,246,255,255,242,247,255,248,206,125,64,30,12,66,138,207,236,251,255,250,255,254,253,254,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,0,6,0,255,249,255,38,5,239,0,255,7,40,255,255,255,255,255,255,255,255,255,255,253,255,255,255,255,255,244,255,255,255,255,255,255,255,255,255,251,255,255,255,255,249,251,255,248,254,251,255,255,250,255,252,166,0,10,0,0,0,0,1,0,0,12,165,245,255,250,255,253,252,254,255,255,},
        {255,255,255,255,255,255,255,255,254,255,0,255,0,250,255,244,9,0,6,1,3,0,9,255,255,255,255,255,255,255,255,255,247,13,0,85,255,253,255,255,255,255,255,255,255,255,255,255,241,255,253,0,4,78,255,255,245,255,255,251,255,243,255,208,16,4,0,24,111,209,247,245,201,107,27,4,0,24,212,255,255,255,255,252,252,255,},
        {255,255,255,255,255,255,255,255,255,0,5,250,255,255,253,255,40,0,254,255,251,0,46,245,255,255,255,255,255,255,255,255,255,1,3,88,255,253,255,249,255,255,255,255,255,255,255,255,255,255,249,0,1,83,255,255,255,255,252,255,252,255,199,2,0,34,198,255,255,247,253,254,254,255,255,191,47,0,0,199,247,255,255,254,252,255,},
        {255,255,255,255,255,255,255,255,253,0,255,255,253,255,249,255,154,2,0,0,0,8,150,255,255,255,255,255,255,255,255,255,255,0,0,90,250,255,252,255,255,255,255,255,255,255,255,255,250,255,250,0,4,90,255,248,255,253,252,255,252,213,1,2,84,255,255,236,169,80,8,17,74,167,239,255,253,81,12,0,224,245,255,255,252,255,},
        {255,252,255,249,255,255,250,255,0,0,245,255,248,255,251,255,252,153,1,0,9,148,249,255,255,252,252,255,252,246,255,248,254,0,2,86,252,255,253,255,255,252,251,255,255,246,255,253,255,255,255,255,252,251,253,255,253,255,252,255,248,20,1,83,255,255,166,0,6,0,0,0,1,0,9,167,251,255,85,0,16,255,254,255,255,251,},
        {247,255,255,242,255,253,255,243,0,6,3,251,251,255,255,255,0,10,0,0,0,4,13,250,248,255,255,248,255,255,246,255,255,7,0,92,255,250,255,253,255,255,255,251,255,255,246,255,249,250,255,255,255,255,254,253,255,255,250,253,158,4,32,252,250,135,0,2,0,3,10,3,5,6,0,1,124,255,247,40,6,140,252,255,255,254,},
        {250,255,246,255,255,244,255,255,0,254,0,1,255,255,249,3,0,253,5,3,0,252,0,255,255,255,249,0,252,251,253,246,254,0,0,90,243,255,250,254,253,255,251,255,250,249,255,255,255,255,254,254,253,255,253,248,251,247,255,251,0,4,201,255,165,0,9,6,33,137,220,235,141,34,0,0,7,158,246,198,0,23,243,253,255,255,},
        {255,255,255,245,253,255,249,251,4,253,255,7,0,248,3,0,255,255,3,0,1,255,0,5,249,255,255,0,255,244,255,254,254,0,7,81,255,209,94,34,6,18,77,191,255,251,254,252,234,255,253,0,0,83,255,255,255,255,243,213,5,26,249,240,4,0,0,70,255,255,255,250,248,255,91,0,0,10,236,255,32,0,212,244,255,255,},
        {252,246,255,255,255,249,252,2,0,249,255,255,0,11,0,255,251,255,0,7,0,255,251,0,5,244,0,14,249,255,253,250,255,4,0,80,174,16,0,3,0,0,1,1,141,255,255,252,255,255,248,1,5,86,253,255,255,250,255,128,0,119,255,164,6,0,40,255,246,168,34,36,182,255,246,35,0,0,168,255,114,3,141,249,255,255,},
        {255,255,252,255,235,254,255,0,255,255,244,245,255,240,255,251,7,0,7,4,0,252,255,252,0,7,0,254,247,248,255,255,255,0,0,52,12,31,143,207,198,128,17,11,0,218,254,255,255,252,255,0,11,76,255,250,255,243,255,57,0,197,246,79,0,7,142,249,184,0,0,8,0,174,250,150,4,0,82,247,199,1,58,255,255,255,},
        {255,255,255,251,255,255,0,0,247,255,253,255,252,255,255,255,3,5,0,4,0,246,255,254,255,250,255,251,255,255,251,254,255,3,0,7,44,231,255,239,251,255,156,0,13,106,253,255,248,255,255,5,0,93,255,255,255,255,252,28,3,241,255,17,1,11,224,255,44,0,216,203,5,37,255,223,2,3,6,255,241,0,16,255,255,251,},
        {255,253,255,249,255,251,3,254,255,253,252,252,255,255,246,255,0,255,0,2,1,255,247,255,255,252,255,255,252,254,254,255,254,3,0,1,210,253,247,255,255,255,250,20,3,45,255,252,255,253,254,0,3,85,254,252,250,255,255,10,2,243,252,15,0,0,242,246,38,2,213,202,2,31,255,234,0,0,16,255,246,5,18,249,255,251,},
        {255,252,255,252,255,249,6,255,255,255,252,255,246,255,255,254,0,255,0,0,1,255,253,255,255,255,255,255,255,255,255,255,253,2,0,41,255,246,255,255,254,255,250,75,0,11,255,251,255,254,255,0,0,88,255,255,255,248,255,63,4,191,255,74,0,3,143,255,171,0,8,0,0,168,252,152,0,1,77,255,191,7,67,252,250,255,},
        {255,255,255,255,246,255,0,255,255,255,255,252,255,255,249,251,253,243,3,0,0,248,255,253,255,255,255,255,255,255,255,255,249,4,0,66,255,254,254,255,254,255,253,80,0,5,255,253,255,254,255,0,0,88,255,255,245,255,247,131,1,111,255,166,3,6,28,249,253,174,39,34,180,246,253,25,7,0,165,246,118,0,129,255,255,252,},
        {248,255,247,254,255,0,0,255,248,255,251,255,253,251,249,255,255,255,6,0,0,255,255,255,255,255,255,255,255,255,255,255,249,5,0,88,255,255,252,255,254,255,255,85,0,0,254,255,255,254,255,0,0,88,255,255,255,255,252,212,4,31,250,247,4,0,0,91,255,247,253,254,249,255,73,3,6,0,246,255,26,8,209,249,255,246,},
        {255,250,255,255,248,0,255,244,255,248,247,255,249,255,255,250,1,0,0,250,6,3,255,248,255,255,255,255,255,255,255,255,255,2,0,93,250,255,252,255,254,255,255,88,1,0,252,255,255,254,255,0,0,88,255,255,245,255,253,241,5,6,187,255,164,7,7,0,29,148,232,243,142,31,9,0,0,167,253,185,6,0,246,255,247,255,},
        {248,255,254,255,255,0,248,253,0,255,255,255,255,250,255,255,2,251,255,254,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,89,252,252,255,255,255,254,253,88,3,0,252,255,255,254,255,0,0,88,255,255,255,255,255,253,160,0,49,253,255,113,3,7,0,0,0,0,0,5,0,0,128,248,255,42,7,153,255,254,251,252,},
        {250,255,255,247,254,255,247,255,0,0,247,252,252,255,252,4,0,255,255,244,255,255,2,250,255,255,255,255,255,255,255,255,255,0,1,87,255,253,255,251,255,254,252,86,3,1,254,254,255,254,255,0,0,88,255,255,251,250,248,255,242,28,3,74,255,255,160,7,0,0,15,0,0,0,0,163,255,251,91,0,3,255,251,249,255,246,},
        {255,254,254,255,255,255,252,248,255,4,0,255,255,252,0,0,255,246,255,255,239,255,0,255,255,255,255,255,255,255,255,255,254,0,1,87,255,255,255,253,254,255,254,85,1,1,255,254,255,254,255,0,0,88,255,255,255,255,255,252,255,207,0,13,84,254,255,236,160,78,8,16,76,174,248,245,255,90,0,12,228,253,255,255,247,255,},
        {251,255,252,255,254,253,255,255,250,250,8,0,255,255,0,255,254,255,251,255,255,251,0,0,255,255,255,255,255,255,255,255,252,6,0,86,252,255,254,255,254,255,255,84,0,0,255,254,255,254,255,0,0,88,255,255,255,255,255,255,251,255,200,0,0,45,192,255,254,254,253,254,255,246,255,195,36,1,0,198,252,254,255,254,255,255,},
        {255,255,255,255,255,255,255,255,255,246,255,0,1,0,3,255,253,255,254,255,245,248,255,0,255,243,255,254,255,254,255,250,255,0,0,90,250,255,252,255,253,255,247,91,2,0,253,254,250,255,250,0,4,90,255,248,250,255,255,252,255,255,245,224,14,4,1,34,113,199,243,246,199,115,30,7,1,14,228,247,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,251,255,0,9,246,253,254,255,252,246,255,255,241,8,252,255,255,255,253,249,253,255,255,1,3,88,255,253,255,249,254,251,255,83,0,0,255,255,255,255,249,0,1,83,255,255,254,255,255,252,254,255,255,247,255,141,23,0,0,5,0,0,0,8,0,0,151,248,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,249,255,255,254,255,250,254,255,255,248,255,255,252,255,249,1,255,249,255,253,255,255,253,250,247,13,0,85,255,253,255,255,255,255,253,83,2,9,232,255,241,255,253,0,4,78,255,255,253,255,255,252,252,255,255,255,255,252,242,208,137,61,23,23,74,128,208,247,255,255,243,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,245,251,252,254,255,255,249,249,255,253,255,255,250,255,3,255,255,255,255,244,255,251,255,255,253,255,255,255,255,255,244,245,255,255,249,255,253,255,250,255,251,255,255,255,255,249,251,253,253,255,255,254,252,253,255,255,255,255,251,249,255,255,252,246,255,246,255,254,245,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,254,255,255,255,251,255,247,255,253,254,254,255,250,255,255,0,6,0,255,255,250,254,255,251,255,252,243,251,252,253,255,255,254,255,244,255,255,254,241,255,248,249,255,252,251,255,255,254,255,255,255,255,255,254,253,254,254,253,254,255,255,255,254,248,255,255,255,245,255,255,252,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,253,249,252,252,248,255,255,255,254,250,255,255,239,255,255,255,242,255,254,253,255,254,252,253,255,255,255,255,243,255,255,255,252,255,255,253,254,255,255,252,255,250,255,246,255,252,255,255,255,253,255,255,255,255,255,255,255,255,254,251,249,253,255,255,237,255,255,255,250,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,239,255,251,255,255,248,246,255,255,252,251,255,244,255,255,254,251,254,252,250,255,248,255,255,255,243,255,248,255,254,255,247,255,247,255,251,252,248,255,247,254,253,255,255,253,252,253,255,255,255,254,255,255,254,253,255,255,255,248,255,255,249,255,249,255,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,247,255,255,249,255,255,253,250,255,248,255,253,255,252,255,250,253,255,253,255,251,255,255,255,254,254,255,248,255,253,255,253,255,255,251,255,245,255,255,251,255,253,255,254,255,255,255,251,255,255,255,255,255,255,252,254,252,254,255,255,252,253,255,255,251,253,255,251,255,255,250,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,}};
      
    private static int[][] G ={{255,255,255,255,255,255,255,255,255,255,254,254,248,255,255,255,250,255,251,253,255,253,255,254,255,255,255,255,255,255,255,255,255,254,254,255,248,255,253,255,255,255,255,255,255,255,255,255,251,255,253,255,254,255,255,255,254,255,248,252,255,252,255,255,253,255,249,255,255,255,254,253,255,253,255,243,255,255,255,251,252,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,252,250,251,255,255,254,253,248,255,247,255,255,251,255,246,251,255,255,255,255,255,255,255,255,252,250,255,248,255,255,255,243,255,255,255,255,255,255,255,255,255,251,252,248,255,247,254,253,255,251,255,255,255,249,255,250,255,255,243,255,244,249,255,255,250,255,254,255,255,252,255,255,255,255,255,253,252,253,},
        {255,255,255,255,255,255,255,255,250,255,255,254,250,255,253,255,255,157,38,0,47,149,251,255,255,255,255,255,255,255,255,255,253,255,255,255,255,243,255,255,255,255,255,255,255,255,255,255,252,255,250,255,246,255,252,255,252,255,244,243,255,252,255,255,254,255,255,250,255,255,245,255,255,248,255,253,255,248,255,255,255,255,255,255,255,253,},
        {255,255,255,255,255,255,255,255,252,0,0,0,10,252,255,248,151,8,8,0,5,0,155,253,255,255,255,255,255,255,255,255,255,252,243,251,252,253,255,255,255,255,255,255,255,255,255,255,248,249,255,252,251,255,255,254,249,255,255,255,246,255,255,242,247,255,248,206,125,64,30,12,66,138,207,236,251,255,250,255,254,253,254,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,0,6,0,255,249,255,38,5,239,0,255,7,40,255,255,255,255,255,255,255,255,255,255,253,255,255,255,255,255,244,255,255,255,255,255,255,255,255,255,251,255,255,255,255,249,251,255,248,254,251,255,255,250,255,252,166,0,10,0,0,0,0,1,0,0,12,165,245,255,250,255,253,252,254,255,255,},
        {255,255,255,255,255,255,255,255,254,255,0,255,0,250,255,244,9,0,6,1,3,0,9,255,255,255,255,255,255,255,255,255,247,13,0,85,255,253,255,255,255,255,255,255,255,255,255,255,241,255,253,0,4,78,255,255,245,255,255,251,255,243,255,208,16,4,0,24,111,209,247,245,201,107,27,4,0,24,212,255,255,255,255,252,252,255,},
        {255,255,255,255,255,255,255,255,255,0,5,250,255,255,253,255,40,0,254,255,251,0,46,245,255,255,255,255,255,255,255,255,255,1,3,88,255,253,255,249,255,255,255,255,255,255,255,255,255,255,249,0,1,83,255,255,255,255,252,255,252,255,199,2,0,34,198,255,255,247,253,254,254,255,255,191,47,0,0,199,247,255,255,254,252,255,},
        {255,255,255,255,255,255,255,255,253,0,255,255,253,255,249,255,154,2,0,0,0,8,150,255,255,255,255,255,255,255,255,255,255,0,0,90,250,255,252,255,255,255,255,255,255,255,255,255,250,255,250,0,4,90,255,248,255,253,252,255,252,213,1,2,84,255,255,236,169,80,8,17,74,167,239,255,253,81,12,0,224,245,255,255,252,255,},
        {255,252,255,249,255,255,250,255,0,0,245,255,248,255,251,255,252,153,1,0,9,148,249,255,255,252,252,255,252,246,255,248,254,0,2,86,252,255,253,255,255,252,251,255,255,246,255,253,255,255,255,255,252,251,253,255,253,255,252,255,248,20,1,83,255,255,166,0,6,0,0,0,1,0,9,167,251,255,85,0,16,255,254,255,255,251,},
        {247,255,255,242,255,253,255,243,0,6,3,251,251,255,255,255,0,10,0,0,0,4,13,250,248,255,255,248,255,255,246,255,255,7,0,92,255,250,255,253,255,255,255,251,255,255,246,255,249,250,255,255,255,255,254,253,255,255,250,253,158,4,32,252,250,135,0,2,0,3,10,3,5,6,0,1,124,255,247,40,6,140,252,255,255,254,},
        {250,255,246,255,255,244,255,255,0,254,0,1,255,255,249,3,0,253,5,3,0,252,0,255,255,255,249,0,252,251,253,246,254,0,0,90,243,255,250,254,253,255,251,255,250,249,255,255,255,255,254,254,253,255,253,248,251,247,255,251,0,4,201,255,165,0,9,6,33,137,220,235,141,34,0,0,7,158,246,198,0,23,243,253,255,255,},
        {255,255,255,245,253,255,249,251,4,253,255,7,0,248,3,0,255,255,3,0,1,255,0,5,249,255,255,0,255,244,255,254,254,0,7,81,255,209,94,34,6,18,77,191,255,251,254,252,234,255,253,0,0,83,255,255,255,255,243,213,5,26,249,240,4,0,0,70,255,255,255,250,248,255,91,0,0,10,236,255,32,0,212,244,255,255,},
        {252,246,255,255,255,249,252,2,0,249,255,255,0,11,0,255,251,255,0,7,0,255,251,0,5,244,0,14,249,255,253,250,255,4,0,80,174,16,0,3,0,0,1,1,141,255,255,252,255,255,248,1,5,86,253,255,255,250,255,128,0,119,255,164,6,0,40,255,246,168,34,36,182,255,246,35,0,0,168,255,114,3,141,249,255,255,},
        {255,255,252,255,235,254,255,0,255,255,244,245,255,240,255,251,7,0,7,4,0,252,255,252,0,7,0,254,247,248,255,255,255,0,0,52,12,31,143,207,198,128,17,11,0,218,254,255,255,252,255,0,11,76,255,250,255,243,255,57,0,197,246,79,0,7,142,249,184,0,0,8,0,174,250,150,4,0,82,247,199,1,58,255,255,255,},
        {255,255,255,251,255,255,0,0,247,255,253,255,252,255,255,255,3,5,0,4,0,246,255,254,255,250,255,251,255,255,251,254,255,3,0,7,44,231,255,239,251,255,156,0,13,106,253,255,248,255,255,5,0,93,255,255,255,255,252,28,3,241,255,17,1,11,224,255,44,0,216,203,5,37,255,223,2,3,6,255,241,0,16,255,255,251,},
        {255,253,255,249,255,251,3,254,255,253,252,252,255,255,246,255,0,255,0,2,1,255,247,255,255,252,255,255,252,254,254,255,254,3,0,1,210,253,247,255,255,255,250,20,3,45,255,252,255,253,254,0,3,85,254,252,250,255,255,10,2,243,252,15,0,0,242,246,38,2,213,202,2,31,255,234,0,0,16,255,246,5,18,249,255,251,},
        {255,252,255,252,255,249,6,255,255,255,252,255,246,255,255,254,0,255,0,0,1,255,253,255,255,255,255,255,255,255,255,255,253,2,0,41,255,246,255,255,254,255,250,75,0,11,255,251,255,254,255,0,0,88,255,255,255,248,255,63,4,191,255,74,0,3,143,255,171,0,8,0,0,168,252,152,0,1,77,255,191,7,67,252,250,255,},
        {255,255,255,255,246,255,0,255,255,255,255,252,255,255,249,251,253,243,3,0,0,248,255,253,255,255,255,255,255,255,255,255,249,4,0,66,255,254,254,255,254,255,253,80,0,5,255,253,255,254,255,0,0,88,255,255,245,255,247,131,1,111,255,166,3,6,28,249,253,174,39,34,180,246,253,25,7,0,165,246,118,0,129,255,255,252,},
        {248,255,247,254,255,0,0,255,248,255,251,255,253,251,249,255,255,255,6,0,0,255,255,255,255,255,255,255,255,255,255,255,249,5,0,88,255,255,252,255,254,255,255,85,0,0,254,255,255,254,255,0,0,88,255,255,255,255,252,212,4,31,250,247,4,0,0,91,255,247,253,254,249,255,73,3,6,0,246,255,26,8,209,249,255,246,},
        {255,250,255,255,248,0,255,244,255,248,247,255,249,255,255,250,1,0,0,250,6,3,255,248,255,255,255,255,255,255,255,255,255,2,0,93,250,255,252,255,254,255,255,88,1,0,252,255,255,254,255,0,0,88,255,255,245,255,253,241,5,6,187,255,164,7,7,0,29,148,232,243,142,31,9,0,0,167,253,185,6,0,246,255,247,255,},
        {248,255,254,255,255,0,248,253,0,255,255,255,255,250,255,255,2,251,255,254,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,89,252,252,255,255,255,254,253,88,3,0,252,255,255,254,255,0,0,88,255,255,255,255,255,253,160,0,49,253,255,113,3,7,0,0,0,0,0,5,0,0,128,248,255,42,7,153,255,254,251,252,},
        {250,255,255,247,254,255,247,255,0,0,247,252,252,255,252,4,0,255,255,244,255,255,2,250,255,255,255,255,255,255,255,255,255,0,1,87,255,253,255,251,255,254,252,86,3,1,254,254,255,254,255,0,0,88,255,255,251,250,248,255,242,28,3,74,255,255,160,7,0,0,15,0,0,0,0,163,255,251,91,0,3,255,251,249,255,246,},
        {255,254,254,255,255,255,252,248,255,4,0,255,255,252,0,0,255,246,255,255,239,255,0,255,255,255,255,255,255,255,255,255,254,0,1,87,255,255,255,253,254,255,254,85,1,1,255,254,255,254,255,0,0,88,255,255,255,255,255,252,255,207,0,13,84,254,255,236,160,78,8,16,76,174,248,245,255,90,0,12,228,253,255,255,247,255,},
        {251,255,252,255,254,253,255,255,250,250,8,0,255,255,0,255,254,255,251,255,255,251,0,0,255,255,255,255,255,255,255,255,252,6,0,86,252,255,254,255,254,255,255,84,0,0,255,254,255,254,255,0,0,88,255,255,255,255,255,255,251,255,200,0,0,45,192,255,254,254,253,254,255,246,255,195,36,1,0,198,252,254,255,254,255,255,},
        {255,255,255,255,255,255,255,255,255,246,255,0,1,0,3,255,253,255,254,255,245,248,255,0,255,243,255,254,255,254,255,250,255,0,0,90,250,255,252,255,253,255,247,91,2,0,253,254,250,255,250,0,4,90,255,248,250,255,255,252,255,255,245,224,14,4,1,34,113,199,243,246,199,115,30,7,1,14,228,247,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,251,255,0,9,246,253,254,255,252,246,255,255,241,8,252,255,255,255,253,249,253,255,255,1,3,88,255,253,255,249,254,251,255,83,0,0,255,255,255,255,249,0,1,83,255,255,254,255,255,252,254,255,255,247,255,141,23,0,0,5,0,0,0,8,0,0,151,248,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,249,255,255,254,255,250,254,255,255,248,255,255,252,255,249,1,255,249,255,253,255,255,253,250,247,13,0,85,255,253,255,255,255,255,253,83,2,9,232,255,241,255,253,0,4,78,255,255,253,255,255,252,252,255,255,255,255,252,242,208,137,61,23,23,74,128,208,247,255,255,243,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,245,251,252,254,255,255,249,249,255,253,255,255,250,255,3,255,255,255,255,244,255,251,255,255,253,255,255,255,255,255,244,245,255,255,249,255,253,255,250,255,251,255,255,255,255,249,251,253,253,255,255,254,252,253,255,255,255,255,251,249,255,255,252,246,255,246,255,254,245,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,254,255,255,255,251,255,247,255,253,254,254,255,250,255,255,0,6,0,255,255,250,254,255,251,255,252,243,251,252,253,255,255,254,255,244,255,255,254,241,255,248,249,255,252,251,255,255,254,255,255,255,255,255,254,253,254,254,253,254,255,255,255,254,248,255,255,255,245,255,255,252,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,253,249,252,252,248,255,255,255,254,250,255,255,239,255,255,255,242,255,254,253,255,254,252,253,255,255,255,255,243,255,255,255,252,255,255,253,254,255,255,252,255,250,255,246,255,252,255,255,255,253,255,255,255,255,255,255,255,255,254,251,249,253,255,255,237,255,255,255,250,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,239,255,251,255,255,248,246,255,255,252,251,255,244,255,255,254,251,254,252,250,255,248,255,255,255,243,255,248,255,254,255,247,255,247,255,251,252,248,255,247,254,253,255,255,253,252,253,255,255,255,254,255,255,254,253,255,255,255,248,255,255,249,255,249,255,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,247,255,255,249,255,255,253,250,255,248,255,253,255,252,255,250,253,255,253,255,251,255,255,255,254,254,255,248,255,253,255,253,255,255,251,255,245,255,255,251,255,253,255,254,255,255,255,251,255,255,255,255,255,255,252,254,252,254,255,255,252,253,255,255,251,253,255,251,255,255,250,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,}};
      
    private static int[][] B = {{255,255,255,255,255,255,255,255,255,255,254,254,248,255,255,255,250,255,251,253,255,253,255,254,255,255,255,255,255,255,255,255,255,254,254,255,248,255,253,255,255,255,255,255,255,255,255,255,251,255,253,255,254,255,255,255,254,255,248,252,255,252,255,255,253,255,249,255,255,255,254,253,255,253,255,243,255,255,255,251,252,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,252,250,251,255,255,254,253,248,255,247,255,255,251,255,246,251,255,255,255,255,255,255,255,255,252,250,255,248,255,255,255,243,255,255,255,255,255,255,255,255,255,251,252,248,255,247,254,253,255,251,255,255,255,249,255,250,255,255,243,255,244,249,255,255,250,255,254,255,255,252,255,255,255,255,255,253,252,253,},
        {255,255,255,255,255,255,255,255,250,255,255,254,250,255,253,255,255,157,38,0,47,149,251,255,255,255,255,255,255,255,255,255,253,255,255,255,255,243,255,255,255,255,255,255,255,255,255,255,252,255,250,255,246,255,252,255,252,255,244,243,255,252,255,255,254,255,255,250,255,255,245,255,255,248,255,253,255,248,255,255,255,255,255,255,255,253,},
        {255,255,255,255,255,255,255,255,252,0,0,0,10,252,255,248,151,8,8,0,5,0,155,253,255,255,255,255,255,255,255,255,255,252,243,251,252,253,255,255,255,255,255,255,255,255,255,255,248,249,255,252,251,255,255,254,249,255,255,255,246,255,255,242,247,255,248,206,125,64,30,12,66,138,207,236,251,255,250,255,254,253,254,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,0,6,0,255,249,255,38,5,239,0,255,7,40,255,255,255,255,255,255,255,255,255,255,253,255,255,255,255,255,244,255,255,255,255,255,255,255,255,255,251,255,255,255,255,249,251,255,248,254,251,255,255,250,255,252,166,0,10,0,0,0,0,1,0,0,12,165,245,255,250,255,253,252,254,255,255,},
        {255,255,255,255,255,255,255,255,254,255,0,255,0,250,255,244,9,0,6,1,3,0,9,255,255,255,255,255,255,255,255,255,247,13,0,85,255,253,255,255,255,255,255,255,255,255,255,255,241,255,253,0,4,78,255,255,245,255,255,251,255,243,255,208,16,4,0,24,111,209,247,245,201,107,27,4,0,24,212,255,255,255,255,252,252,255,},
        {255,255,255,255,255,255,255,255,255,0,5,250,255,255,253,255,40,0,254,255,251,0,46,245,255,255,255,255,255,255,255,255,255,1,3,88,255,253,255,249,255,255,255,255,255,255,255,255,255,255,249,0,1,83,255,255,255,255,252,255,252,255,199,2,0,34,198,255,255,247,253,254,254,255,255,191,47,0,0,199,247,255,255,254,252,255,},
        {255,255,255,255,255,255,255,255,253,0,255,255,253,255,249,255,154,2,0,0,0,8,150,255,255,255,255,255,255,255,255,255,255,0,0,90,250,255,252,255,255,255,255,255,255,255,255,255,250,255,250,0,4,90,255,248,255,253,252,255,252,213,1,2,84,255,255,236,169,80,8,17,74,167,239,255,253,81,12,0,224,245,255,255,252,255,},
        {255,252,255,249,255,255,250,255,0,0,245,255,248,255,251,255,252,153,1,0,9,148,249,255,255,252,252,255,252,246,255,248,254,0,2,86,252,255,253,255,255,252,251,255,255,246,255,253,255,255,255,255,252,251,253,255,253,255,252,255,248,20,1,83,255,255,166,0,6,0,0,0,1,0,9,167,251,255,85,0,16,255,254,255,255,251,},
        {247,255,255,242,255,253,255,243,0,6,3,251,251,255,255,255,0,10,0,0,0,4,13,250,248,255,255,248,255,255,246,255,255,7,0,92,255,250,255,253,255,255,255,251,255,255,246,255,249,250,255,255,255,255,254,253,255,255,250,253,158,4,32,252,250,135,0,2,0,3,10,3,5,6,0,1,124,255,247,40,6,140,252,255,255,254,},
        {250,255,246,255,255,244,255,255,0,254,0,1,255,255,249,3,0,253,5,3,0,252,0,255,255,255,249,0,252,251,253,246,254,0,0,90,243,255,250,254,253,255,251,255,250,249,255,255,255,255,254,254,253,255,253,248,251,247,255,251,0,4,201,255,165,0,9,6,33,137,220,235,141,34,0,0,7,158,246,198,0,23,243,253,255,255,},
        {255,255,255,245,253,255,249,251,4,253,255,7,0,248,3,0,255,255,3,0,1,255,0,5,249,255,255,0,255,244,255,254,254,0,7,81,255,209,94,34,6,18,77,191,255,251,254,252,234,255,253,0,0,83,255,255,255,255,243,213,5,26,249,240,4,0,0,70,255,255,255,250,248,255,91,0,0,10,236,255,32,0,212,244,255,255,},
        {252,246,255,255,255,249,252,2,0,249,255,255,0,11,0,255,251,255,0,7,0,255,251,0,5,244,0,14,249,255,253,250,255,4,0,80,174,16,0,3,0,0,1,1,141,255,255,252,255,255,248,1,5,86,253,255,255,250,255,128,0,119,255,164,6,0,40,255,246,168,34,36,182,255,246,35,0,0,168,255,114,3,141,249,255,255,},
        {255,255,252,255,235,254,255,0,255,255,244,245,255,240,255,251,7,0,7,4,0,252,255,252,0,7,0,254,247,248,255,255,255,0,0,52,12,31,143,207,198,128,17,11,0,218,254,255,255,252,255,0,11,76,255,250,255,243,255,57,0,197,246,79,0,7,142,249,184,0,0,8,0,174,250,150,4,0,82,247,199,1,58,255,255,255,},
        {255,255,255,251,255,255,0,0,247,255,253,255,252,255,255,255,3,5,0,4,0,246,255,254,255,250,255,251,255,255,251,254,255,3,0,7,44,231,255,239,251,255,156,0,13,106,253,255,248,255,255,5,0,93,255,255,255,255,252,28,3,241,255,17,1,11,224,255,44,0,216,203,5,37,255,223,2,3,6,255,241,0,16,255,255,251,},
        {255,253,255,249,255,251,3,254,255,253,252,252,255,255,246,255,0,255,0,2,1,255,247,255,255,252,255,255,252,254,254,255,254,3,0,1,210,253,247,255,255,255,250,20,3,45,255,252,255,253,254,0,3,85,254,252,250,255,255,10,2,243,252,15,0,0,242,246,38,2,213,202,2,31,255,234,0,0,16,255,246,5,18,249,255,251,},
        {255,252,255,252,255,249,6,255,255,255,252,255,246,255,255,254,0,255,0,0,1,255,253,255,255,255,255,255,255,255,255,255,253,2,0,41,255,246,255,255,254,255,250,75,0,11,255,251,255,254,255,0,0,88,255,255,255,248,255,63,4,191,255,74,0,3,143,255,171,0,8,0,0,168,252,152,0,1,77,255,191,7,67,252,250,255,},
        {255,255,255,255,246,255,0,255,255,255,255,252,255,255,249,251,253,243,3,0,0,248,255,253,255,255,255,255,255,255,255,255,249,4,0,66,255,254,254,255,254,255,253,80,0,5,255,253,255,254,255,0,0,88,255,255,245,255,247,131,1,111,255,166,3,6,28,249,253,174,39,34,180,246,253,25,7,0,165,246,118,0,129,255,255,252,},
        {248,255,247,254,255,0,0,255,248,255,251,255,253,251,249,255,255,255,6,0,0,255,255,255,255,255,255,255,255,255,255,255,249,5,0,88,255,255,252,255,254,255,255,85,0,0,254,255,255,254,255,0,0,88,255,255,255,255,252,212,4,31,250,247,4,0,0,91,255,247,253,254,249,255,73,3,6,0,246,255,26,8,209,249,255,246,},
        {255,250,255,255,248,0,255,244,255,248,247,255,249,255,255,250,1,0,0,250,6,3,255,248,255,255,255,255,255,255,255,255,255,2,0,93,250,255,252,255,254,255,255,88,1,0,252,255,255,254,255,0,0,88,255,255,245,255,253,241,5,6,187,255,164,7,7,0,29,148,232,243,142,31,9,0,0,167,253,185,6,0,246,255,247,255,},
        {248,255,254,255,255,0,248,253,0,255,255,255,255,250,255,255,2,251,255,254,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,89,252,252,255,255,255,254,253,88,3,0,252,255,255,254,255,0,0,88,255,255,255,255,255,253,160,0,49,253,255,113,3,7,0,0,0,0,0,5,0,0,128,248,255,42,7,153,255,254,251,252,},
        {250,255,255,247,254,255,247,255,0,0,247,252,252,255,252,4,0,255,255,244,255,255,2,250,255,255,255,255,255,255,255,255,255,0,1,87,255,253,255,251,255,254,252,86,3,1,254,254,255,254,255,0,0,88,255,255,251,250,248,255,242,28,3,74,255,255,160,7,0,0,15,0,0,0,0,163,255,251,91,0,3,255,251,249,255,246,},
        {255,254,254,255,255,255,252,248,255,4,0,255,255,252,0,0,255,246,255,255,239,255,0,255,255,255,255,255,255,255,255,255,254,0,1,87,255,255,255,253,254,255,254,85,1,1,255,254,255,254,255,0,0,88,255,255,255,255,255,252,255,207,0,13,84,254,255,236,160,78,8,16,76,174,248,245,255,90,0,12,228,253,255,255,247,255,},
        {251,255,252,255,254,253,255,255,250,250,8,0,255,255,0,255,254,255,251,255,255,251,0,0,255,255,255,255,255,255,255,255,252,6,0,86,252,255,254,255,254,255,255,84,0,0,255,254,255,254,255,0,0,88,255,255,255,255,255,255,251,255,200,0,0,45,192,255,254,254,253,254,255,246,255,195,36,1,0,198,252,254,255,254,255,255,},
        {255,255,255,255,255,255,255,255,255,246,255,0,1,0,3,255,253,255,254,255,245,248,255,0,255,243,255,254,255,254,255,250,255,0,0,90,250,255,252,255,253,255,247,91,2,0,253,254,250,255,250,0,4,90,255,248,250,255,255,252,255,255,245,224,14,4,1,34,113,199,243,246,199,115,30,7,1,14,228,247,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,251,255,0,9,246,253,254,255,252,246,255,255,241,8,252,255,255,255,253,249,253,255,255,1,3,88,255,253,255,249,254,251,255,83,0,0,255,255,255,255,249,0,1,83,255,255,254,255,255,252,254,255,255,247,255,141,23,0,0,5,0,0,0,8,0,0,151,248,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,249,255,255,254,255,250,254,255,255,248,255,255,252,255,249,1,255,249,255,253,255,255,253,250,247,13,0,85,255,253,255,255,255,255,253,83,2,9,232,255,241,255,253,0,4,78,255,255,253,255,255,252,252,255,255,255,255,252,242,208,137,61,23,23,74,128,208,247,255,255,243,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,245,251,252,254,255,255,249,249,255,253,255,255,250,255,3,255,255,255,255,244,255,251,255,255,253,255,255,255,255,255,244,245,255,255,249,255,253,255,250,255,251,255,255,255,255,249,251,253,253,255,255,254,252,253,255,255,255,255,251,249,255,255,252,246,255,246,255,254,245,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,254,255,255,255,251,255,247,255,253,254,254,255,250,255,255,0,6,0,255,255,250,254,255,251,255,252,243,251,252,253,255,255,254,255,244,255,255,254,241,255,248,249,255,252,251,255,255,254,255,255,255,255,255,254,253,254,254,253,254,255,255,255,254,248,255,255,255,245,255,255,252,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,253,249,252,252,248,255,255,255,254,250,255,255,239,255,255,255,242,255,254,253,255,254,252,253,255,255,255,255,243,255,255,255,252,255,255,253,254,255,255,252,255,250,255,246,255,252,255,255,255,253,255,255,255,255,255,255,255,255,254,251,249,253,255,255,237,255,255,255,250,255,255,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,239,255,251,255,255,248,246,255,255,252,251,255,244,255,255,254,251,254,252,250,255,248,255,255,255,243,255,248,255,254,255,247,255,247,255,251,252,248,255,247,254,253,255,255,253,252,253,255,255,255,254,255,255,254,253,255,255,255,248,255,255,249,255,249,255,251,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,247,255,255,249,255,255,253,250,255,248,255,253,255,252,255,250,253,255,253,255,251,255,255,255,254,254,255,248,255,253,255,253,255,255,251,255,245,255,255,251,255,253,255,254,255,255,255,251,255,255,255,255,255,255,252,254,252,254,255,255,252,253,255,255,251,253,255,251,255,255,250,255,255,255,255,255,255,},
        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,}};
}