0100010011100001000100111011110001000111110101001001000000110000100100110001110001001110110110011011110000111010111111001100011100010010010111110010111100000100111000101011101000111101110110000001100000011000010010101101101001001011011111010100011101010010101110001110101011100110010010010000100000011110110111011101000110100001001010100011100100110110010110100000101110111001101001111101100011000101 1011111101001100010111011101101010110101000011110000011111010111001111111111101110011110101010100010100111000100110011000010110000010110010001100010100101011111100001000110001000110001101000100011101001101101101010010011000101011101010100111100100101000110110111101010100111111100101110011110110001110101110011101111011101000100011110110100100110110101010111000000101111101010100010011101110110010100 1001010010100111000100110100111001101101000010101111101010101111010111011101110000010010101000000011010010110000100010100100000110001000001110110100111101000000101011010001011111010110001100100001111001010110000010001001011011101001011100111000111100001001110000010011000111100011111111010011001100001100001110000101110011111011110101101111001011100101000001001001111001010011011110110111011001110001 0010111110010100111111001100100101001110010100010100010010100101000010101111011010100001101010011000010110101011010110110100111011010110100110110000111000000101111111101110111001010011011001000011000100111111010111101011100011100101101000100001011000111101111011101110101000011111001100010001111100100011101001000000001101101000010001011100000000101011111000111111000000000011110010101110101011101000 0110011010100111011011001010000110111001100010110010111100000000100001100011001100111101000100100110011010000010100000001010010000110100110110111010110010000000000111101001001011110010111010110110101000011111010010110000001000100011110111011011010000010101111100001001111011111100110111101101100010100101100100011011011100010101100100001110000000000011101111111010111011010001011011110100110011000000 1010101011101011111100100111010011100000101010100000001100001101100000110000110001001101010101011010000101111111110001111010101111101101000100011111100011111111111100010100001010101101001011010111101011110000100010101111101001000101001010101011100011001110010001010001101100101101101111001010000000110000101110001110110111101111011100101111001001001011101001111111101001101001100000101000000000000001 1111100110111011100100001000000001011101011011000110000100001001010011101001111010001110111111011100001100010000110010100101011101100100100111010010010000101011110001011011110010011010011011001000001100001010011111111111101010001101111110110000010111000000111100111110110010000111000110100110101101110101110001000100111011011000100010011011101110010110001010101001001100110101011100001011010100011000 1011101000100111111111111110110111111101001101110010110001010001101110000000011110010000110100010000110111011011001001001110110110111011100101110101101100000000011100011011011100000101011100101000000100111011111111111010010101101111111110110011001101010000001001101100110000101110110011101111001011000001111010000100100010110010110110101011010001101101110110010010000000011011110100001110101001000010 1100001011010011010101100011001100100100110110100001001100100001101000110101100100010000110101111111001101001001011001001000000111000000011010101100110000000111101010111101100001101111111100110000111100110011111101110010101100111000000110111011011011101111011011001011001001110111101001110011111110111101101110010111110011100111010011111101110000010100111100100010000110010001100010001100100110011010 1110110011111110110111000101010100010100101110001000011111010001101100011111011000100100010011001000010010010001011111100001001011101001000101110001100010011011100010010100111110010100011110110011110010101101111000001111100101000011111110110110001001011101001101100011000000001100001101100110101011111101101011101101111110001101100001000110011010000011000101000001101000010010101001100110000110001110 1011110010000001001011010000101011011001111011100011110000101110010001010000100100110111111100101010011100110101100100110100011111100100010110011101011100010001001001101011001101100011011111110111110111011001101100100100110111011110111100010000100111111100011000001101110111001111110001000000111111101001011010001001111011001011001001001100111000101110001001110000110011101001011100011100100111011011 1010011000010010000100100001100110111110100100010100110001101011001111100010101001111100111111010010110011010101101011001101000100000011100110010111011111111000000110101010010001001111110101110001011011001101001000110100101001110111000100000101111110001110000110001000101000010101010010001111100111111000101000011111110011000001001001000111000001000000100101000110101101010100000001001100100100101110 0110011010100001110101101010101100010101111110000011110001001011001110111010011011111111101001001100100101110010000001111010011010100001000110100111001011110010111101101100010100010001011111011001000001001001101001011110011100111000011001101000110101111100011100101100100000001101110101010010101010111011010111010100011010101010001101111101001101001011010010000000101001010110100010110000100000011110 1100100010011001001101111110110011011110000100001101111010001111111001101110101010010101000100010110110000010010000101001101100111100100110000100111000110101100011001100111100000010111011111110101101100001001001111010001011101110010111010001110000010000110011000000101011011101110100001000101111110111001000111000001010100100111111101100000000101010000111000111011010010010111010010110100100000101011 1001111011010010111101011110111001101110110101101101010010110011110010010110010111111110000010001010000101101001110110110111101001001100000100101011101111011011101010010101001110111100000000110100100110000011100110101000100011011001110111111101000000100110000000000111010101011000100100000001011111000100011101011101000100001111110111100010000000010100110101001001100001011110011111001100100000110111 1101011111000001101100111010000101101001111110110001100110000010100110111011101011011011100111011100000010001000010100011011110001011110111010001010001110000111001111001011101100111100011100100010001110100111001010111001110000000001010100101010110101110010011010000111111000100111011110110111000011010010110000001000110000101011100110010110001100100100110010000000100000010110000000100001111001011011 0010111111100101111000000011001110100000110011101000000111001011001110110100011010011011000011000101111010110100111001101011001111101001111011010111111010100110010110100000110101101000111011001001100101011001101101011111010010000101100110010011100000101001101010101000000000010101100101001111100110000001110101110011000011110100100111000000110100110001111010010010101110011011110001011100010101011001 0110000001010010011000100100101101011011100001110101010101100001001011010111011100011000011101110110001010000011110011111010000110011001000100100111101100000011100001110001010010100110101000101001110110110011101101000000111001010011100101001100011111010111100010111001100011111001111101101001000000001011111001011011101111000011110110010101000001101100010111000010000011100011001001011110000110101010 1111010000001000100101000000110110000100001001111101011110000011110000101111001110110110000111010110101001011000001101100100000000101010001001011000011101000100001101110100011000100010101011011100001011111011101000100011111000100111101110111011001010000100011111011011010011001001110100010110110111100110100101000001111101010101110010110111100100111111011010010001011100010111111110011001011100011001 1011101111111111001100111011011011010110000010110111100001111100100011011011101111010011011111000111110110000100001010100110100110000111111111111010111010000000101101000101110001111111111100100011101101010111010001010101001111111011010101110111100011101010111110100110011011100001011000101110111101101100011000010011110101111101111010011000110010010110010100110001011011011101110100111101000011100110 0000111000111010101011000010000111011101100000101000001100100000101001001100001111001101001101001101101000011111111100101110110010101111111011101010000011010101000100101101010111011101001110001111011011010111010101101111110000010100001010111011101001110000101000100011000110000011100010010011001011111110100001100110110010011010011111100010110001101101011111111111100110101100110111000100001001110100 1011000011000010010010010011110001110001100111000000000001000100101100001011010000000101000000100100100010111110100101111100100010010101101100101000010110110010101011001000000011000101110100001011111101011011101111001011101001110010010110110000011100100001010111000100100110110101011001110011011100100100000001100110010110111110011101110100010111100101001111111000100010110111001001010011000001010001 0001010011011111110101011010100010010001100011000010010101110111011100011011001100011011001010110111110010010101011100001011001001001001011110000011010000111010100110101101111010011110011110010110100100010011001000111000110100011010011001001110010110100001101111100011110110110111101100011111011000100110000001111100111101001100000010111000100101000110110111100001010010011111111011001101010101101001 1110001001100110010000011110011010011011000101011001001001010110110110100010111011100110100010010101010010111010110001101011010001100000111111110100000110101010110000011011011000110101011111100110001100101110001100010010010010011000111110111101100101011101010010010010000001000001111100011100011010111001110011111001111011111011110101101010011111111111100111101101100000001111101110001010110101011101 0110110001100111111001101011111000100111101010111011111100000100111110010000010110011110100001101011111010010101010001001011000001001110101011100100100110000111100000001101101100101110011101111011011101001001101110010111001010001000011011100011010111010101010100110000010001010001010101110101000000000110111000100101100111110001101110011000010111111101010001100111111110100111101001110011000111101001 0100001101100001111011001111010101100111001001100100000111111011101001101010110011011111010100011100101110111011100100010010001100100000011110110000010100100001000011001011000111000001011001110111000101110100001110101101100010000001100001011011100000000011100000011111111000101100110010110110111111001000010000111001110000010000000110100111010101100000110010110000010011110011110010011101000011010111 0111111110101111010000010101110100001110101010100000100000000110111000011111110110111000100010110010011000101111000011001111110010100010001101101010101101101010001101001101001001100110111010001000001110111100110011100101101100110100100000101000010111001110001010100101100010000100111010000111111001011000011010111000100101001100001111011001101000111100101100110100010000011011101101111010001100100010 1111010011010000010111100111101000100010011001100100100011110000110100110110000001001011110110001111011101101000110010000101110100101000010001000110111100101000111100000111110110101010000001011010000110101111000011011000110110111100000101000000101000001110011011101100101111010111100101010000100010001010111111000110010101111010101110000011100101001101110101010000101110100101110111011011011001111111 0000111011010000100111000000110000101101011001110010111111111100100010001011001000110101000101110111011101001001010110101001010110010010010011110011011101000100111011110001011100100001100110111101110111001000100010101101111100101110101101001101110000000001111110100000100010001011011011111100111100100110100101110110110111011101100100111001101101000100000011111100101000011111111001010110001001010100 0101100110010011011101101110111100101111011100011110110001111011010010000101111010001001110110111001000110100001000101111100010001011000110100001010111010000000000000010001000101101011010000100101101011100110000011101101110001011010010110111001100101011000001011001000100001101111001100101011100010111101111010010100110100111000010010110101111011111011001001111100011011100011101001111001010111010111 1100100101011010111101011010100111100001011010001001100100011111100000110100100110101011101100100011110101011001010101111111011000001100101100011111110100011101111111100101010000100011011111101001111100010001101011011101010100000110101101101010011110110010100101100011101011010001001010010000101010001001010000110000011000011111110101001111110000001101001001110101111000000110110010011000000001111101 1010010010101010001001101001101001000100101111011001100110011110000001000110010111000111010001101110110110000100111001101000101011101000101001111101010111010011001100111001000111001000000000010001000111101011101110100011101010011101010111001010001000101011000010101011101001100000110000000001000110111110101110100010101110101001011111110011110011010111101111001000101011100111000011111001001110110000 1001000100011000100011110010001111100000100001111000011110100011101110001111000001000010010011100000111000111001001111110011011111011100111111011001101110111101001111011001101000001101000011100110001010000000000110100111111101101010001011000000110111101100110010000111011100110111111110000011110110000111101100001001010010000111000010101010100110000000111100110110000100101110101101100101110011101011 1010010100000111010011101000101000010010011111111010010111110101000001011001010100000001110100110001000110101100110011100001100011110001000110000111111100001111110010001001111001001000101010111001101100000001101100011000001001110010110100100000011001101100110110101110001010111001110100111000100101101110001111110110001110100110010110111001000011010111011100010000110000101001000100011101001010011101 1000001000101000000111010000100101110001000100010110010000111001101111001110010101110100010100010010110010000001011101101101000000110011000001000111000111110010110111000100100011101000001111111101010110001100001001110110000110010111101110001111010000101001101000000111101001101101000000010001010111001110010101011110000010010100100101100011000101101010101010010011111110111100010000110011010001011100 1110101011000111101010101011000000110101110010001001111010000111001010011000110001011101011001111010111111101001010010010001101101100111010010000010011110111100101100001001001011100010100000100100101100110110111111010111101110001100001011001000110010011100110001100100000100111011100110110010111001001111101010110110010101000100111010101101111111111110011111000011000111001011011111111110101111010000 1110011001001111111010010111000110010010111100000100010110000111010001100101010011101111011000011011110010011011010011010011001011110000110011001110010101010000100000110010011111001100000101010011011001111011100101010110000010110101100110100001001001101100100010010000011111001010001111001001001011001101010110010001001110011010010001011000011001101101110000011010010000010110000110110110110000101001 0011000010101001011001000101100100101000111010001011011101010001000111011001011110111000111101010110000001111001000110000110101010110000000001101111010010110100111000011110011110011000001001100000010000011110110000100011101001010010111010100100100011101010111100001101110011100000011010100010111001110101001001100100001100000001010001111001110110101110011100000110001111101000011111101101011000111101 0010011010010011110100000001011000100110110101010101101011010001110111001101110011001101110010011001011011000110101010001010000111000100110100101101100001010001010101110101100100111101000001111000000011100111011011111110111111100111111000010000111000101011000100001011010111000100111110101100001110001000000110011001000101010000001100011100101000111001100000110011001101100011111011111110111100001100 1100000101110000100101010011101001100100110000001111011011100100000000111110000011100011110100111100111100001001111000100100010101001000010110010100011010110111111110111100111110100110010011110101000000110101001101101110011010110111001000111001011100100000000101001000100011111100111110101110010001000011111010001101001011001010100111001000101000010100110111000000011110001010100011110101100001100100 1111001010101011011000000100011110011110111011011000000110001000100001110011001100100101000110100001001100010101111101101101100001110010011001001010100111101101101100000001100110001001111011001110111110000111110011100010000010001000010000101010100011001111001100011010100100110011000100011000101010100001101001100111010000011011100110111110110111011101001110000101110011101010011001110001000110111100 1001011000010110010110001001010011001010110100001101100110011010111010110001101010000101001010100011101011001110100010110011000000011111111111101010111001001100110000010011001111011001001110100100100100001000101110000001011001000000010001001111100010000110001000101100101110000001100000101101100110100111101101110011100100110110001010010010101110010110011110010100110101101000001001110101011001001000 0010010101101101001110101011001001001111000010100010111111001010010011100101110111000010000010010000010111001101001011111011011110001101010001111111111010110100110110001011010100001000110000001000011011011100000111101011110110100011111011100100001001111111110110101010011111000111011001100000011010000100100101001011101010110001001101011101001111100110010001101100000001111100110010001100101110100100 1010110101100000101001000100100110110101010010011101101010001101111000001110000010111101101111001100010100000100111100100001000000110111011000100000100110111001010001001011101011011000111100001011011101100010000111001110010110111110110100001100100101001011101110011111011000011000111100100000111111111110100001011111110111011011111010111101101001110101001010000100000110001111100000011100111100000000 0001110110101001100100100101010010111110111011011000010111100101101010011001000110001110011100110110000110110111110101001110110000001000000011011101110110110001100001000001000100000011011100110001100101110100000001001111100100110101010011001110001000111001100111010101011011000001101001000011110110001111000000111011110100000100110001010111001000100010100101100000110011110110001000110100111010000110 1110001000111010111100110000011100000011100011010000100111011100001001011111011110000111100100110100111100101110111100011000110011010111010101011101101101000100100000011110001100100110000100100101100001000011010011011000110111111010100001001010001100110010000010110100010001001110100100101001001001111011101010001011101001010001110000111011110000101111101111011001111111010101011100111010110101001100 1100101100111111101111100001000001000110111100000000000011110100001010100110110110100000000011100101100001101111100010110101110000011100000001111010000001001101111010111110001101001001011100001010010011000000111000010000111011101100011101000010110011001101110111110000010111000001100001100000110111110100010101000001100100010001010111111001101001010110111011110000000101100010111000100000010001010001 1011011001101001001000100110000110001011111010111110010100101100101110101111101000010101001100011100100010010100110111100111101000100011101010111000111100000001101010001011011101110100010001111101001110110111011011010010001111000011011100101111100010001000111010111001111011001011010001111100001111001000000010001011110111100011100101010001000111010101010000000011000111101010111000101011010000110001 1110010100100010000001101110010111101110001010101110110000001011011001011001010011111011101101011100111101010010001000010001000100010110001110011011101011101010110111110101101010111101111010111011010010101100000111000010110101010001010111011001011011011011001110000100100001001000000011100001001000100110101001100111111010101100001011010010010111011001100101001010001000110101111110001000101000101010 0011111010101001101110110010111001100101111000101111111100101100011001110001000001001100111111001010010001100010101110010101011100100101011001001100111111011011111000110010010001010100100111010011110011100010101111001010100101111000010110001010010000010000100000011010011000110011000111011010100010011000000010111110111000111011100001110111010001100111000001101100110000111101010111000101000110010100 0000110010000001010101110010100110100111001010000001111011010100100100111110000100100001010011000001101101111001000101000001000000110010000011010110011000101000000100000011111100101011011100001001111011000001000001110000011000001100111011010001000001011001010101111011001110101100001011010000000000000111100000000010110111000111110000000000010000001111000011010000101001001111100000010100001001000000 1100001001010111010111111110111111101011001010010001011011011000010110101011101101000110101111011110001111001001010000011000001001111110011100111110010111101111011000110001100000001100001110001101111011010001000101001111101011011100011100111100011000000010011000000010110001100111100110101101101011100011101110101011011101000110011011010010111000101101011000101111110011010101111111111000001101111001 0101110010001001100100011100000101001100011001111101101001010100010010101100101000010111000100001111000001011000001011111100101100101001010001011001110110101011111100011000111010010111001011111101110111011101000101101000111100000100011011101100011111110110110000111110100100111101111011111111010111010100100111001100010110111011000101110101011011110000010100011001101111011111000001100010111000000100 0110010100101011001101110101001100110110111000111011101011011010011111001111001110010110000010111000111001110001100000101011011000011100000001101001000000110111001111010111011010110110000101001000111100111110011010101101011001100111111000010100000100000010100010011110010011011110011010010101111011000100001101011101101101101111110101001011001011011001111100001001001000101101011001011110110001101100 1100110101001111101001001000110011010110100110100110010010110011100100101100111101101011101111100111111100100011001010100011111010000011101111111101011010001001111010101110111001001010111110110010011111000111011011010001101010010110001011111011011010011100101111010110110100101100011110000110100101110001010100111001110111111011000011110100001111111100110101101101101100011101101001001110101100011110 1100110001110100110000110001101000101110001110100100110001010110100011001110110011010000101001000100111110101000001111111111001011111111000111101111000001111110101101010011000110000000110010111000100000100010001101011000111111100110111010010001010101011001110111111010111010110011111001000011101100000110000111001110100111000000110100011011011001100010110001001100110001101101101000010100100000110001 1100110000110010101110011101000100101001111100001001010001111110010100001010000011100110011011001001010010111111011100001110110011001000000100011010101110001101101010000000110110100100110101011100010001011010110010011010111000011101010110111100101111011011000100100010011010110110100010111101111101011101001110010011110110010111101010001111000110000010110011110110010011100100010101000100011010001111 1000010111000100001100000111100101010001011000010101101000101100111001101100110000101110101111001100110100001011001010001111010100101011100111101100001111011110111101010110101111101000111011111101101010111000010011001101101100111110111101011111000101010001110101010011100111110101100111001011100010111011001111110010101001000111111001110111001111011111111000101000010110111111000010010101001101100110 1100000101010100001011010010010000111000110011110100110100110110000001110101111111001001001001111100001101010111011011111000000110000001011110011001010000101001010000101100010000001011001110100101111001101101110110110001100010001111001110101111000011110101010011110001110111101101111011011010011101011011110101100100101100100000011111101011000001010000111000001100010011010100100010101111001111111100 0011100001010001100111001101011110000100101010111110011100011000110000000010011111010010110101111100011001010110001001010000100101111001000110000101000111000100001010101110111000000110110010111000000000000000011111100111111000110110010001001100101111001000000101010101001001000100001111101000101010111001110001111100000000101000101001011010001100011110001111110110001110101100110101110011010111000001 1100011000111101101110110110100110100011111101110110000111111011100011011111110100101010100111011011110011011010101001100110111001001100111010000111111111111011010011001101011111000100011111010111101111111111011100110100101011100010101111101000100101010100111100111011101001010011000011000100001100110110000011101101111001101000110101101101011111111001011010110001011111001111001001010010000110010100 0001001000010101101011011110000110111011010101001110101101000111110101001011001011001110010001010101010011110011010101100100010001101111100110100001110001011011100111110001000011000000000111111100111100000000001000001110111110011010100111110010000000101001000110011111000101100110001010011001110101011111010011001111011001001110000111110000000111101110001010000000100100011100110000010110110010000100 0011010100001100110011001000001010110110101111100110100011100010100010100010110101100101001101101111000011101001110100101100010101110111001100011101011000011110010010110101011000001111001111111010110010011010001001011001100111110101011010110100010010111100101100011100110101110101111110010011001100110100101101011101111010101110000100010111001000010110011011101000110001101101001001110001111011111000 0101001100100111010111001011111101000101000111111011000111000001010001100011111111001110111110100010110001100111101111001101000011010010001011101110111110101110100001011000010001010001001110011000101101010011100100000000011001010111100110011010111000000010000111001011110100000101101001110111000010001000010001100011111101000101011100111111001100001010001010111010001110000111100100111111110100011100 1010010000001010100000000010010011010000011101111111110101101110110000100001001101010111111001000101000010011111001001011101001101100010101111111110011001100110101001011011000111001111011111001010010111011000101001000110110001001111100111111101011011011011111001010100111100010001010001010000100011111110100110111101111100100011100100000001011000000000010110001110101011101000010111100000010100110011 1001001101110010100010001100000111110000101101010100110001000001111111110010010010110011001101010011001001101110111001000100010001011100000100111110100100110001101000100000110011001100101001011011111101110110011101011110110001101000011101101101010011011000010111100100110101110101000011111111010110100011101101110011110110100100010110001000111011111101101100000010001011101001111101110100011010000010 1001000011001001101001011101000100000011101100011000101011111010011001010101011010000110100000100010110100101110000110000000001001000100011000101101010111001010011011001110000001001000010111011111000010101111100111011101111001000100100100011001001011000010110001001011111011011110000111010110100101000100010100010000110111001111100011001101111101110101001010110110101101010011110100011000100111111110 0100011001100111000101100011011011110101100000100011000001000111000111011000011111100000011010010010001111010101011001001001101100111001110000000010010001111110000101001101010010010010100011011110100010010100010001101101100101101111111111111000110010010000000001111100100010101000001100010010001101101111110001101101110001000101111100011010111110111111101100001000101110110111010001001110001110101010 1010000001000000101000010101011111110111000001000011011001110101110000000000011111110000010011001110000101101001011011001110100000010001000010010111100000000000100010101001111110110100111101011010010110010100011010000011100011000101000001001111001111101110111100101001000101010011111010101001110000110100100111011101100011000001110001110101000001000001011100011001100001000010010010010010111110111100 0010000100011101010001110101000001100101011101101011101001010000110100100011101100011000111111001011110010010001110011110010100000110011011110010111001010101100111100011110000110100011011010101100110100110010101110011000101101111100000110110111001111010110100011000111100010001001100000000010011111000001111100101011100011111101101011101101011110100010010111100001111110100001000100000000010101010101 1000111110101011111001101100100010001010100111000001101101011100101111100001100111110001110110101110111111111111011110000000100011110010110110001101111010101000110000100011001111001011111000100110000011010001101001110110011111000001101001000111110011011010010111101111011110011100111000010001101101011100110001000001010010011010010011111111101100011111011111011001001100111011111001010000010001110110 0111110101110100110010010010110111100010101011101100110001110000010100110001011010100100100101011110000011110110101001010101010000000101100011010000010100010011100001011101001010001010001011100100111101001100001111011110100111001111001011010010010101010110010111101001011101100000001001110001000111111100011001100100000110110011111100001111001111000001100010001011010100011011100101100100010011111010 1000001000101011000010111011101111001001000100011111000010000011001101110101000100101101010100011111000100011110001101110000000100111100101111100000000111100001111011100100101001001000110100010000011010011011000111101101110010011100111000111101100110001101110101111100110100111100010010010010001000111110001000101001101111001010001111110101111101101011001100111111001110101100100101011111011010000110 0010110111011110111011000000010111111110101110010001000101101110110110110110101111111111111001001011110001100111110100111001010011011000001110010110111010001000000000000111111110010111000100101001001100111101110010110011001000001010010000111111000110001100000100001110111011001101101000111111111011011100110101110011000100111111110011101101110000111000111101110000010101000101001011110001000001101001 0100000011010100110111101001010101001100000010001010011001101000010110011101111001011001101001111000011001011110100101010011001010000110101111001011011111010011101011100011011100001101000111110010000110100011010111111101010000001101001100001000001110001001111010100010110100001101001100011000111001001101101110100000101101010100110111111000000001000111110100100111110001100110001101101011100101110110 1010100000010010110101000101000010000100000000100100011011101000101101000010011101011011101001010110111010011111101010101010110101110110001001000110111001000000100011011000101110011111101110110111011101110001101000101110001110001010000101100010011011011100010111000111111000110100100011101101000110010101100010010101110100001110001100011011110101111111000010110110111011010011000001100111110111000110 0111111101011011000000011000101110001110101101001010011100000100111110011010010111010001000110011000111101011001001010111110001010001100101110110110111111101110000010000010110101110110100101100101001001000011000100111000110101111000110000111011000001110100010101011011101011100110011001001100101111101101011010100010000001101110101011001100011110111000010111100011110101101110010110011110110010011101 1111011100100001010010110110100101110001110100001000000101000101111100001011000011000111001101000111101110000010001111011010000100001000011110000011011000101110110010101001000010110101101010100000011110111100101110110011001101001111011100000001100111000101111101010000100001110010100111110110000100101010001101000110110011001100000011001011101110010101001010110110010011110110111111110001101100110110 0010011111101010001011011001011100101100010111110010001101001011101100111011011110010110011111001011110011100000110000110001000101101000110101100000110000001010001100001011100110101110000101000100010001100100000011100010101100101110010100010000100101101110101111101000010011010000111010011110101100010000101100101100101101011110100011000011110011100100101011111011001011000010011101001001111011111000 0000100101001000000101111000001011110001110100101110110011001110100000011011100110111111011110101000010111101011111010100101111000000010111110001101111010100100110010001111111000111000100110001110111010000010101011110011001100101000000001011000010011001000110101111111000100010000010011001110010010110000101010110000101001100100101010100110101011010001000100000111111010111011001010010001100011010100 0100101001001101011101100100010111111110011101110101111010110101000101111010001010001000010101001100010000101010010110000110111001000010000000011011001010000010011001100101000100011101111110110101011011101011010001011100000101101110011001100110001010111010001010100000110100111100000110101000100101001100100101100001110011111100100000001001000111100010011011110100001001010011000011101011110001110110 1000100001001010111001101111011110101010100100001000110111110000001110100101101000001110111111101001111101011000010001110101000100001100111101110110010000101011110001101000001100010001100100001010111001111010001100001001100111010110000100010100010101000101000010111111000111001111011001011000010001110000000001101010011110110110000011111101110111000110010100000101100011011010000100001011110111101100 0101010100110001000000101101011000100110001110001110000010010000110000100000010000011110001111001000011011110111001011011010111010100101010111101011100101000111100010000100100010010110011110111001100001011001111010010010110101111011001111110010100110111011100101001101011101111100000110010111101011011011001101011101011110100111111110101101101100011000001111001101010010101011110011010010100110011100 0100110111101001001110000010011011000110011010100110110111001000001101111100000001110101011100010111101011111101100100110001100111000011101100100011110101001010010110001001110101101111011100001011000000011000110110010010101110110101000011100001000011001011001100001111001000101101110101001011000100110010001010101010000000001101001011000100000111010101111000000001101000111010000000111000000010110100 1111110010110101110001010110011100010000010111011000100100001001110011100000011011010010111100000100111101001100010010101010111001001101100110111001101111101010111001101010001110011011001011111000111011100011101000100100011111011001110000011111101010011101001010011101101001100001000000110011000100001110110111111101101011000100000111010000100011111010010110000101100111101110011010101011111111001111 1011010111110111011000011000001100110001000010100000011111110010110011010000000111110111010100100111100010100001000010001101010101010010011111100100011100001110011011001001000001111011101111101010101001101011010001010110000010100000000100110001110000100101000101111101100110110111110111001100011100111100111000010111001001100001111100001110001100100100001001110110000100000111001010100111101010110100 0100011111101010001000010001100100101111011001111101010001111101001001000010110110110000000100010010010011010110101110010010101111110011011101001100101001011000101011100101101000110100000111100000100110100011110011111110100010000010100001010010100001000010000001111111010110000100100010100000100100110111000100110101001110101100010111000101110001010100010110001111111010110010000010110000101101101000 0101001100001000111010100001110111010100111011010110111100011101101100100100000011011111010111011010101100111010111000000001101111111101110100101110101010100101100101000101010111010010111010000100011010001001111100111111101100010011000100010001110001000000111101011110011010001101101101010000000010000000001011001110111111001111011001011110010100010001111001111100100000011010011000000000110011100110 1011111110011111101110111110100110110000100011111100100000011100000110000110001110010000010010000011101011011100101000100011111000100101001000011000010101001111000001011010101001001010011000111111000111011001001101010000010110110000000111100110101011010111001010111011011000011011101000000000111000101110000000101101000100011010011101001110111100111101100110011111111000100101100011000101011111000100 0001110010111111101111010001101111010010111010000010111100101011110110101001010010101011010100001100101011001000100111010111101111100110000100000111001010111100111001101001111000100001001110110010111011011001101001101001000111111010111010011010001011110110000110001010011000011000110010000001001000010010000010000001001101011110001001110000010011110011000001101010010100100100100011001100001101010100 0101000101001010110000110010111011001100010011010101010010001000110100010011101000010010100101100100011101101100010001001110100100000110101110010010110110010010110001110110001111011010000111111100100011101001111100111111101110111010000111010000000101001001100101001110001011101100111010001110000000010001010111000010010100001010000011111000001001010001110001000000000100101101100011101101110001111100 1101010100001000010000110000111010110101111111001111001010111000100001001011010010110000000101000000001100001010100001000011110100101011100110101010011011111110001010110101010111011110010110101011011100101010011010100010111000110101101000111111010101010110110111011000110001000100000111001001000001111001101100001001011100101110010010100000100111101001111110100100101011000111000100011110011100001111 1111010010001100101000111001111110011101110101100110010101110100001101010011011111110011000110001110010011110000001001110001100001000001011000010111011111100110101101111010111011001110010110111011000011011111111101011010100010010111001101110011000001010000000110010111011110010110011010001101111111111100000110110110100110111000111111000110110001010001110101010010001110010111110101111001101101101101 0101001011101001110111010101110101110000101101101100101001110010011110011000100011011111110111011010001111001010100000110101011101101000111100011100100110001010001110111010001101010111001010001100101000100101001001111000001101101111100110111100100001110111100011101111000100111000010111000100001101110010110101101010111100011000000101011110011010111111010010110101111010101110100010101001011000000010 1100101111010110111101101100101110001100000000001100001110001111101100001011100011101100110110000001011110100100101111100011000010101001100010000010100000000100101001010100111110100010000100100101010110101110111000000110100011101111011011110111100101010110110100101111000000011111110100111001110011010010101110110010000101111110111000100101101101001010010110100001110010100111000110110011011100101110 1111010000100000100101100011010111101111001011001111011011100010101100001110111011011101000111010100111110010101000010001000110101010000101101110001010000011100100011110100111101000001110101100010110111100011101000010011011001101111000100000001010001100001110001101000110011110100011111010100101000001100100000010000001110110111101101110110011110011001010111011100001101011100111001000000001010010010 1011111011100100010100100000000001010011101111110000100100101011111000011000000100001000001111101111011100000000111010110110001011001011001011101010010101100101110001111010001000101100001101001110000001101001111010000010011010110001000011011011100100111010000101100010000110011101100101100100011100010000111110000111100100001110100100110111111101000011000010100011110100111100001101000101111000001101 0011000000110000101111011010010011011000001101001101001011011111010001001011010100010110000110110011100100100011011011011000010110000001001111100011010101010000000011011111100000111110110011011111001010000011000010101111110101000100010001010110011001010000001001100100000000101110010000011010100101110101001110111111011000111110011100000001111000010010100001010001100110000011000110011100111101110011 1110111011111100101101000001001101101110011111010111011001111010011110001101000000010101101000000000110010000101101010111100110001011100110011000000000111001100100100111110001111100011000001100110010011111001110110000100010010010010010011011111010010000100110010011101001010111101000000111011110010011011101000011110111111000111001111000010001001000111111001110111110011000101000001111111101000011001 0100100001101101011111011000110010110111101011100011011111011100011100011010000100110000000010000111101101110011101111110010010101010101010000101000001101000111001111100010100100001101001111000101110010010110110101001101011101011101100001101110100000111111010101000000000110111100011001110011100001111110010100011100001001100000000011101011111110111011101000111100110010010000100110000000000010111000
cTrader Algoシステムトレード

【cAlgo】ナンピンマーチンcBot【Sample】

4/10/2021 12/18/2023

4年以上前の記事です。内容が古くなっている可能性があります。

悪名高いナンピンマーチン

世の中にはいろいろなロジックのEAやcBotがありますが、ナンピンマーチンほどシステムトレード初心者を魅了し、そして地獄の底に蹴落としてきたロジックはないのではないでしょうか。

(EAやcBot・・・cTrader信者のajinoriとしては全部cBotと呼びたいところですが、一般的な呼び名で総称してEAと呼んでおきます。)

 

ナンピンマーチンとは

説明は不要でしょうが一応簡単に。

ポジションが損失を抱えたら、同じ方向で追加エントリーすることで、平均エントリー価格を下げる「ナンピン」と、負けたら倍掛けして負けを取り返すギャンブル手法「マーチンゲール法」を組み合わせたロジックです。

一般的にはポジションに一定以上の損失が出たらより大きなロットでナンピンして損失の相殺を図るロジック全般を総じてナンピンマーチンと呼ぶことが多いでしょう。

 

なんでダメなのか

一番大きな理由は破産リスクの大きさです。「マーチンゲール法」自体、無限に倍掛けできることを前提とした必勝法のため、ロットが資金的ににエントリーできないくらい膨れ上がった時点で口座破綻を起こします。

破産リスクを小さくするためには最初のエントリーをできるだけ小さくする必要がありますが、その結果リターンが少なくなり、その割にはそこそこの口座破綻可能性を秘めるという、どう頑張ってもハイリスクローリターンの設計になってしまうのです。

 

本当の問題

ハイリスクローリターンであると最初からわかっていれば誰も使うことはなく、ただすたれていくだけの手法のはずです。しかしナンピンマーチンロジックはいまだに人気・・・かどうかはわかりませんが、少なくとも有名です。

ナンピンマーチンの怖さは口座破綻のリスクが感覚的にはわかりにくい、という部分にあるのでしょう。人は小さすぎる確率を0として扱ってしまうんですよね。特にマイナスの事象に関しては。

「さすがに〇回も連続で負けるわけないっしょ!」って。この思考が破滅への道を着々と進んでいくのです。

また、EA開発の視点から言うなら、このロジックを使えば比較的簡単にきれいな右肩上がりのバックテスト結果が出せてしまうんで、EA販売をする人からしたら都合がよかったというのもあるかもしれません。

 

作ってみた

どうしてもナンピンマーチン=ヤベーやつというイメージが強かったため、手を出したことがなかったのですが、今回ブログのネタとして、至極単純なナンピンマーチンcBotを作ってみました。

ソースコードも公開してますので、よかったらなんかの参考にしてください。なるかわからないですけど。

 

何も考えないナンピンマーチンcBot

ロジック

最初に適当にエントリーします。プログラムに「適当に」とか言えないので、とりあえず起動時の最後のローソク足が陽線なら買い、陰線なら売りにしておきます。特に意味はないので別に逆でもいいです。以降、ずっと同じ方向でエントリーを繰り返します。

あとは設定値(Pipsパラメータ)以上損失が出たら倍掛けエントリーします。損失が相殺された時点でナンピンポジションは全決済します。

利確も同じ幅にして利確したら再エントリー、にしようかと思ったのですが、決済直後に再エントリーはさすがにあり得ないので、「最初のポジションは一番いいところで決済して再エントリーした」と仮定して、最初のポジションが一番いいところから設定Pips以上落ちたらナンピンさせるという設定にしました。

・・・説明がわかりにくくてすみません。ロジック気になる方はソースコード読み解いてください。

 

ソースコード

using System.Linq;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Robots {
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NanMar : Robot {
        [Parameter(DefaultValue = 100.0)]
        public double Pips { get; set; }

        const string LABEL = "NanMar";
        const string COMMENT = "namping";
        TradeType _tradeType;
        Position _basePosition;
        Position _lastPosition = null;
        double _maxPips = 0;

        protected override void OnStart() {
            if (Account.IsLive && RunningMode == RunningMode.RealTime) {
                /* 当cBotはブログ記事用に作成されたサンプルcBotです。
                 * 何の工夫もないナンピンマーチンロジックにより売買を繰り返すため、高確率で口座破綻を引き起こします。
                 * 間違い防止のため、初期状態ではリアル口座で稼働ができないようになっています。
                 * リスクを承知の上、動かしたい場合はこのifブロックを削除の上ビルドしてください。 */
                Print("初期状態ではリアル運用できません。ソースコードを確認してください。");
                Stop();
            }
            // --- 適当に売買方向を決めて発注
            _tradeType = (Bars.LastBar.Close > Bars.LastBar.Open ? TradeType.Buy : TradeType.Sell);
            var res = ExecuteMarketOrder(_tradeType, SymbolName, Symbol.VolumeInUnitsMin, LABEL);
            if (res.IsSuccessful) {
                _basePosition = res.Position;
            } else {
                // --- 発注失敗したら一度止める
                Print(res.Error);
                Stop();
            }
        }

        protected override void OnTick() {
            // --- 初期ポジションの最大獲得Pipsを覚えておく。
            if (_basePosition.Pips > _maxPips) {
                _maxPips = _basePosition.Pips;
            }

            // --- ナンピンしてなくて、初期ポジションが最大Pipsより設定値以上落ちてるか、ナンピンポジションの損失が設定値を超えてたとき
            if ((_lastPosition == null && _maxPips - _basePosition.Pips > Pips) || (_lastPosition != null && _lastPosition.Pips < -1 * Pips)) {
                // --- 前のポジションの2倍ロットでナンピン
                var volume = (_lastPosition != null ? _lastPosition.VolumeInUnits : Symbol.VolumeInUnitsMin) * 2;
                var res = ExecuteMarketOrder(_tradeType, SymbolName, volume, LABEL, null, null, COMMENT);
                if (res.IsSuccessful) {
                    _lastPosition = res.Position;
                } else {
                    Print(res.Error);
                }
            }

            // --- ナンピンポジションが前の損失を相殺できてれば初期ポジションだけ残して全決済
            if (_lastPosition != null && _lastPosition.Pips > Pips) {
                var myPositions = Positions.Where(pos => pos.Label == LABEL && pos.SymbolName == SymbolName && pos.Comment == COMMENT);
                foreach (var pos in myPositions) ClosePositionAsync(pos);//本当はクローズされたか成否確認しないと危険。今回は面倒なので省略。
                _lastPosition = null;
                _maxPips = 0;
            }
        }
    }
}

たったこれだけのコードです。ろくに確認してないので説明と違う動きになってたらごめんなさい(笑)

あ、少しくらいはcBot開発の参考になりそうなこと書いておきます。

ポジションのラベルとコメント

cBotからの注文ではポジションにラベルとコメントがつけられます

あくまで私の使い方ですが、基本的にラベルはMT4のマジックナンバーと同じ感覚で使います。どのcBotから注文されたかわかるようにするため、基本的に一つのcBot内では同じものを使います。

コメントは注文に追加情報をつけておきたいときに使います。cAlgoのメソッドPositions.Findではコメントを指定しての検索はできないのですが、LINQを使えば特定のコメントのポジションだけ抜き出すことは可能です。

このサンプルではナンピンポジションであることをコメントに残し、一括決済時にコメントがついたものだけを取り出してすべて決済しています。

 

ダウンロード

いろいろ改造して試してみたいという方はこちらからどうぞ。

(2023/12/18 更新 古いものはバックテストレポートが出ないようなので、.NET6.0版に差し替えました)

 

バックテスト結果

10年バックテストの結果がこんな感じ。さすがにいい結果とは言えませんが、一応右肩上がりです。

ちなみに最適化一切なしの一発バックテストです。これはEURUSDの結果ですが、どの通貨でやってもだいたい同じような結果が出ます。

よく見ると資金が極大なのがわかるとは思いますが、つまりはそういうことです。100万円程度だとたとえ1000通貨から始めても破綻します。

こんな簡単なコードで、価格も一切見ないでトレードさせるだけなのに、資金さえあれば最適化もなしで右肩上がりのグラフが出るわけです。よく見ればおかしいのはわかるんですけどね。このリターンの少なさとか。

 

最適化してみた

最適化というかPips設定一つ変えただけなんですが、こんな荒いカーブフィッティングでもよさげなグラフができるから面白いですね。

トレード回数も増えて、目立ったドローダウンもうまい具合に隠れて、あとは縦軸の金額さえ目に入らなきゃいい感じです。(笑)

 

ちなみにこんな感じの時々下にスパイクが出てる直線右肩上がりグラフこそ、まさに典型的な損切りなしナンピンマーチンEAの特徴ですので見れば一目でわかります。

(確かMT4だと決済順序に気をつければ下方向スパイクは見えなくできた気がします。見えないとナンピンマーチンか損切りなしグリッド系EAか見分けつかないですが、cTraderなら見えてしまうため明白にわかります。)

間違ってもこんなグラフのEAにひっかからないようにお気を付けください。最近はまともな販売サイトであればナンピンマーチン使ってるかくらいは書いてあるので大丈夫だとは思いますが。

 

まとめ

実際に簡単なナンピンマーチンEA(cBot)を試してみることでその破産リスクの大きさとリターンの少なさを実感することができました。

皆さんもぜひ上記のコードをいじったり、プログラムがわからなければバックテストだけでもいろいろやってみてください。

もちろんこのロジック自体がナンピンマーチンの中でも特に酷いせいはあるのですが、こんなものですらなんとなくよさげなグラフに見えてしまうことを忘れてはなりません。

ロジックを改良して、ちょっとよさげなモノが出来上がったときに、正しくリスクとリターンを評価できるのでしょうか。ナンピンマーチンで一番怖いのはここだと思います。

もちろんナンピンマーチンのすべてを否定するつもりはありません。1回1回の勝率が独立事象のギャンブルでマーチンゲール法使うのに比べたら、FXでナンピンマーチン使う方がよっぽど理にかなっているのも確かです。

人によってはこれに、まともなエントリーロジック、ナンピンの仕掛け方、損切りの仕方など工夫に工夫を重ねて実用的なEAを作ることも可能なのだと思います。

でもそれって、第三者から見た時に中身もわからない状態でまともかどうか判断できるんですかね。少なくともグラフだけでは難しそうですよね。

基本的には「危うきには近寄らず」で敬遠しておく方が無難な気がします。


まだコメントはありません

新しいコメント

コメントは承認後に公開されます。承認まで次のコメントは投稿できません。

cTrader's Life

© 2025 ajinori