1101000000011001010001000100111101111100101100011000110011111100010101100011000011001010111111111111000110111010000111101001110000000001110100101001010000100010001110100100000010101000101000101001111110011110111001011001010001001011001110110101101000001010010000000010100000101100111000110010111000110010000101000110011100110100110110010100001001000000111110101110000110100000001111111111000111011000 0011100001011000000000011000100110111011011010100000010111010010000011010110010001010001001001010011011000101111011111011110000111000001011000100011011110101101010110100010000001011100001001100010101101011111111100010101110111100011110011010111100011111111101000011001000111011001011100001100110001000101110101000110101110000101011010010001111111101101100001011010010001000110001101100001000110000010 1011100111000101100110110000000000100100110111110111101100010111111101110000011100100001100000000111101001111011001001010110001011000110101100011100101010111000101111111000110001000010100111011000010100100100100100011110011001111010011110000010000100100001000011110011111000110000001000101110110110100111101110010100110001010110001110101101110010010010010000110010111110101101100100111111011110110010 0010111011111001010100000111000010100111111110100011011000001011011011011010001100110101000101010100010111110101001111010001111010101001110100000001100111000100110010110110000110110011001001000000101011011101110000001100001001111010010101000111000100100110101010100100010101010101010010011110111001110001111011001101001011011011001001100100001101010001110111011011110100001000001101011110011110001110 0101000000000010010001101100101011100000000010011000001000101001001100000001110001111111101101100111111011111100101100011001110111000011111011001010101100100000101100110010110111110101101000110101001110110110110010110111000010010101001100101100000000101110001001101010111101011111001011011011101111010000001011010000011010110111100011010010001111001101000111011101110100111100110010100100010110111101 1000101101011011010010001001001110101100111100100110011010111011010001110011101010101111010101101110001010010001101011000000000011100101011111001101100111011101011000111000100010110111001101100101110001110001010110010000001010110011101111000100101001101000000101101101111100100011011111011110011111111111000000101111000011101111001000110110001111011101101010111110010011011101101101101010111001010011 0100000001001100001101101001001010100010001011011011101100001010001110101000011011110111110101011111101111110100000101001110000000000101011101000010100110101001000111101000011010011110111101100001100110110000011001001101011111110101111110010101011101000001010001010011101110001110110100110111110100101001010110110111010101110000101101010000011011001010010101101100010110110001111111111100100001010101 0010000100111011110100110101010100110111010111100010011001000001111101000110001011101000000010100000111010011001100101111110110000011000110001011011101000001111110011111010000111101111110100000011111000111110010100101100100011110111010110101100001011111110110000011011100001010010001101011110011101110111000010010000001010010110000111010110101100101010010111111011011010100111010001100000000001100010 1001000010110011100001110110111100001100100100100100111010110100101001100001101101100111000110001011000100110001110101001100100011010101110000111100111010001111100010001101110100110101101011001100101111011101100011010111001010011000101000010011010101101000001111011001101111001001101101111111101111111101000010001110011101011101100101100110011000000011000110101101001011101011111000000001100001001001 0110001000011101011100010000100110001010010000101011110001101111111100101100010011101011011110101111001001111110001011101101001111011111110110000001100111101000010000100011100100000000111000011100100100111001010100101010111111000011111110100001010110001000101010111110111010111101001100111000100001001111100111000110100111110100011110110000001111111001011010110100101101001000101011111010011011010101 0100101100001101110111100010011101101100001100100010100110100011100111000110101110110001010110111110010111010001101011010100101010001011010110110000100000001010001011100011101101101101001101011111101010110000010100011110111000110011010001010000111001011001000111111010100111111110101001001000001010001001000111011111010100101001101101010101110001110101101011011001100111101001100010010000000000001100 1110000111001100000011111101001001000111100010001110010001100001111100011010110101111100001001100101111101011011000010010011011001100010111011101000011001111000001010000110001111100100110111011011100100100100110110110010000011100101010011001101000011100001001101100001110110110100000000000010100100110011001010100111000001111101011101000110000010101101100010111011001011011010010111001110101000101010 0110000111010000100000100001011000100001001010110101011101010000001111011001001100000001111001100111111010100010110001001010110000100011010001010100000011011110001010000111001111101101011111101110110000010100000100100101010000100011100011100010000110010010111011101110100001010101111011100010010100001011000101000111001101110000001000101010111101010010010101110001110100101011101100110010010000111000 1100010010000101010000101011000001100001101100011100000101000101000001111001010111110111100001100110010010101011001100001100010101010001000000100011101010011001000001111001101101011111001011010101101100111000111110011111011101010010000110010001110111011001001000000001010000010000001100000110001100000111001100101001000010100001000001010010000001101111100101100100001001001010100101111011110011111000 0011110010001000010100100010011011101000101110111000000111010011010110110000011001100011000110100100110010011011001111100111101111001011001101000110010010101000101100010011100000111001000100011000010100100011100011110011010011001010001001010000010010101110110101100010011001010110110001011110101011100010001110111110011011100110010010000101011001000010100100011101110100110111010111110101110100000010 1010111100100011011000111101011110100111001101111011110011111110101001110111000010010001111001110110100101010001111101001101100111000101110111111101001100101001001011001110001101011011100001000100000011010000101100111000100001011010011001101001011110110101111111010001011011011010100000001100001110001111101010111001101000110111010000111111110101001100100111011011011000111001101000001010110011001110 1101001110110110100101110110100111111010110101001001111100101011001110100111001100010101110110010001000011110010000010010010001110000000000011011001001010111001011001110011110000011000011101101111010010100001101101010010001101000010110000101111101110100001000000100011001111110111010101101010001001000100100110001111011101100111110011011101001000100010101001111001101001011101001000011100001110011010 1110000111000101001011011100010010001101001011010001111110001010001010011000100000110010011110111000101001100110010110101010000001010010111100001000100110101011000111001001011100101101110010001010001101100001011001010100100000000010110000101110101101001101101001100111101110101110111000111010001100100011100101100001000000110001001001111111000101010010110001111001011101111010011001001110000011111111 1001001011011100111011111110010111011100111001101100000010100011011111000001010110010110100100110010111001010000111100010011111100011000100010111011000111011110111001101101001101011011110010110000100010110111000000010001110110011001101011101100100111010110011001011010110010001111110100000110100101010001010011110100001110100011101010010111101001111011011000010111000010110010000101000101011110001110 1101000111101011111001001011010001111000100110101000011100000010011100000100111010101011100100101010100010010100100001110111101111111100111101000010000011001000101010101010110111011111111000110100000001110001001000110000001110010010111100001110101110110101111110010110101101011011101011011001101110101000110000011011101111011111111000001101100100100000110101000011100110001001000011101100100000100111 1000111011100000111100000001000000110011010111101001010001100111010000111001000010010100000011100111111001011100000101100101011111010101011010101001000010011000011000111001110010100111010001001101101100111001010110001111011111101100001001111010100100100001110110101110111010000100011101110111000100110000001001101001001000011110010010001010001010010111011010110110111011110100000000100010111011011000 1010100100000101111001011100010001100111010110010101011010111101001100010111001010000010010011110111000000010101010011001000001111110000100010000101111010011001101111000011110000100011000011111111111010110010100101010010101001010010101010110001011001001101110001110000001110110111000100110101001000100011111100011010010100010001011010100111010010110011010000110010100010000001000101111101110000111000 1100101111101010011010010110110001111001011111100111101110111111011010100110111010010101010110110001010101101100101100010101011011000000011110001110010101000000001010001001110111010001001001100101011110001100001001100110011100101100101111101011100101011010101110001110111100001010101101101011000011110011000011011101001000011011001001110000111111101100010100111100101100110000000110010000101110000100 1110100100101001100101000001110110001000101000101010101101110101010100101011101101101000100000010011101010101101010010100101100101111101101111101010000010000101011101001011100101101001111100010010010100000111000111111100010101001110111111100110110010010111111101100111101011110011010011100100100110100111000111010101010011011001101101001000101100010110010001010111110100010000011100111011111000100111 0000000000110011010111010111100011001110100100110001001001100100111100110111101000110011100011101001010011111001110111010111111001111110110011011111100100000001111010110000100111111011111011100001010001001101011110110111000101110101100111010000100101010000010000000101111001010110000001000110010010001101011011001110000000111011101111010010110111001011100110111100110101101000110110101100111001111011 0111100000001011100011100011110111111000111101011101111001010010110010000010011011101100100001000101100010000110011011000010001011010111000111000111100100111111001001111111000100101110101101111000000000101101000000001000001011010011101011010111000000110100010110000011010110111010000011011110010100011101111111100011000101111001011101001001110010100110001001111101001010001010111000010000110111111010 1001111001011011110000001101011101010011011011101100111000110010011000110111110011000010101110010110111100011111100111100010000011011101101100100010011010000111000111010000110101000111100100101111010100001001110010000100100100000011110101101111110101110111010101011111001001010000010000000011001000001011001100000001101100010010100001010101010011001110101001001110001101100101011010000100001001010001 0000001001101010101010101000101000010100001010000001001100110101010011001110001010111111010000101110111001011011000010100010101111111101001010100111011001101110011100010100011101101010110001111011000101100101001001101000100010110010111000001000011110101010100100000110111000100001001010101000001111101011110001011110001001111001111000101010010101010101011000100010110010100001110110101111110110001100 1100111010000110110100110110110111111100000001100110000001100100010111100001110011001010011110111110111001000001101101000001010001010100011000101111011100100100011011001000101000010111001000101011000011011011110110001101011001100000001001111010110111001110101011010011000100110000101001001001011011001011100011010100001100110111011000111010111100010010011010110101100110001100001110010001110110000100 1001101010101010100111000111111110000010000010011001011110010001110111010100000001011111000111100011100011010111001010001000011010000101100011011011100000001000000101111000111111111101101001111000100100110100100100110011101101000111010101101001010110101111000101101111000111001011000110011111100100011010111111011111001110011000001101111111010011100010100010001100101101001011111110101111011101110111 1001110001100001111101010001100111011011010100001100011110110110101101101010110010001110010110101011110001111101011100111110000001010111010110101100011000001110101101000101010100010000000111101111001110110000001001101100001111011000011010111110111001011011111001101010001000010010001111101000110001000001011100101010010000000010011101100001111101111101110111011000101110101110010111100101000001001000 1101111011011001100011101011000011101011000101010010011110110101111111110011011010000010010000011100100101011110011100101110110010010010101011110110111111010001001011101110110110000111010101011111011001000111111100010110011001000000010111011010011100110101011100010001110001001111010101010000111010000111101001111101000111111000110110110101110001111001100001110001001010100001110100100000101110101111 1100100001111000011100011000110011000010110111110110000001110100010100001100000000110111010100000001111001111110111011101111100101111001101101100110111011011010011010111100011000110010001010111000001111111001101110110100010111000011111101011010111010111010111111100011110111001110001000001000111111101010011010101011100110110101000011110011001011010011100001011111010111001000000101000100001011110001 0000010011010010110101100010110000001100110010000110101010011111101001011110001110111000010011000001110001110110100101001000100111101010000100101111110011010110101010010101010011111001010010100100001101010000010111101000000100100111101001100111001011111011011000010001100011101100110111001100111011100111001010010101001100000010011110110110000100111101111100001111000101011000000000100111111100001111 1011100110110001010100010101001100001101100110010000001010011001001000101011100001010110100010111101001101101101110111000101010001010010110100100000010000110001011010000111101100101100100111111110111000011010111101010110010101000010010011001011111100101100001110011001001101111010010100010011010111011101110100001111101010010101000010111000110101101011101110001110111110110001110010110000001000111001 0000001101110010100010101101111110110100110100001001010011100100011011101011010111111000110001001110001111111101011000100001001011101001010010101000110000011011100111001000110110011100111101001110100011010111010110110101111110000100000000011010001110000100100011000101110000010101100101101111010100111001010000111011110111001010010010101111001000100110011001110010110110101001011111101011110000001011 0011000111100001010100000000010000001100110101100000110110110011001111010010111110100100011100111010011000011000001101011000101011010001101001010010000011000011010110110010110100111100100011111010010111101000011011101001010001101111000101011000011100100101011001111110100111111101010010110011000010101001110001001010110110001010111100000000101110000110000011000001000111101000000110000011011001011001 0111101110100010100011010101111110101111011110110010001101010100011001011010110010011000110001011101011001100100100000101110101010100001001100000111100001000101100101111100011001101010110001110011010101011101010000110000000101000011001101101101000001101001000100010000001100010100001100011001111000110100101011101011010110011010100111011110111101110111000110110100110000011001101111000110010001110011 0101000111101000011011111110100101000101000101111110001000010101101100000111100001110000011100000111100111101110010001001010010101110111010001110011111000001111101010000111001001001001101011111101111001011110101000001011000100001111101010110111100010010110000011110100101011111011110000100100101100110111000110111101011000110010001001100111100011010111000111000110101101001101100110001110111000011000 0110000010010111100011111010100010001110010011100100000010000011001010011011110010011011110011011001110001011000110001011111110101010100100010110111000111011110111000010101010001100011100111001000100100111110100011110000101000000011111001011111110100001100000000011001111010010000100100000000001001101011110111000110101111001001000000011000001101101001011011011100001001001111000101111111011110011101 0011100111010000101000010001111011000101010000100110000010000101000001001101000110111110000110101010101111001000101100011000111111100110110110100010010010010110001000101110011011010001101110100111100011101001000110100100101111101000010111000011110110000100111010101111101001111000100010011100010100100000110110010111010100101000100110001111101110100111101010010000110110100110001111110010011110101100 1110101100100101111000000011011001111000011010000010101011001101101011110000100001000110011000010011011100010101001101110110001001101111111011101000010011010011100101101011110001010010100011110000011010001001111010000110111110100010110111001111101110000101101111111001011000100000110001011101111011011000111100001111101110000010001010101111000011101010110000011101100101100001110111101100000110101000 1010000011001101010100010000110111000010011011011000100010000110001111010110011000101111110000101101101001110011111100100010011010111111110110001001100010000110101000110001001110100101000011010101001001010101100110010100101100001001111111110000010010110001001011100111010101100001110010101010000000010110000011011101001110001010101010110011110011011111011010001011110110111110000001010110100110101000 1101101000001101011101111001001110101110101000110000111000001101111010001101100010000111110111001010001111011011001011010001111100000011111000100010001001100001000101111011011101011010110000000011001001001001100110010011101010001101111001001010000111000010001011111010001001001011101010110101100101000100010001100011100110110000000110001110111001011001011011011010100010011001110011100100111111010100 0010101100110001001011110111001000111000111100011001001001001000101101001111000000101011100101101001010110110110100111001010010100001111101101111000011101011001000000000011011001111111010001100100010001011110001101100001101101010011000111011100001101111001100010001011100111011010101111001100000011100001110001101001001111001001101110100110011000010011000111001100101010011000001011010111110000010111 1100111000100110000100011001001001100110100101101000011110110000010011000111111100111101110001011010101011011001011010100110111100111000100100101010011010101011000100111110010011111001000000100011001001101101110110000111000010010010010100111011111100110100010100100110111100010000011111101111110000110011010100101010000101010001101110011011000111001100001111010011000100100001000000100111111001101111 0100011100110111101001001100010000100100110100111011000101000110010000011000110100110101001010011010101111000111000100010100011101010001100101011000100101011001001111111011100011110100011000110100000011100011001010110010010101111000011000101111001110011001010110011011011000101110101011101000100001111000000101010111111011001111011001111110010011001101011100000110100110110101011100010011010100101000 1010001011001101001101010101001010010110011011111010110101010111000001000011111000111011110101010111100101101100110011101111101111110001001101001110011011111001011000000111000011111000101101111101010111101001010101010110010110100110010110011011010011101101111100110011000110010100100100100000100001011100000011000110001010000000110001011000110100001011100110010000011010001110101111010000000100111011 0110001111101101011111010111101101000011010000000010011010011011001010001101000101101111101101011000001110110000100101101000010001001101010110001100101000010110010011001111011001001001010100110000110100001100111100011011101001000110111000010100101001110011100010011011110010110101101111000100101011010000110111110000011101111001111011110110110000101101011001010101100101010100011110000111100001000110 1000100110100110001010000110000100000101000100010101010100111011101001111111100110001100001111100000100000011011110001111011110000110011010001001000000001000010100001100000100001111010001101101111111110001000010110000000100111100110000010101100100001101001010011100001100010101010110101001100011010110111011111101011000101101110100101011010100110111010101000111001110001010001111110111101010001111011 1111100101111000110011000001010001010010111100111110100011010100110100111100100110100111010101001101101001100101001100101111011100111001011011001111100000101011001011011101110001110101010000001111111001101111110111111111101010001000100110100010101101001111111001001001111010010111001100101011010010011110101111100100001001101100000011101011100000110000011000101011001011100011111010000011111100010100 0010001000111101100011110011011000101101001101010101000110001110001100100000110011100100000110010001001110011111010011101100111001110000000000100110011010010000100100011010001010001110110110011101000000101100110101000101110110101010011100111100110110101000100011101001000011100111001100111111000011010111100001101001000111001101011111101110100101000011001001101100011011101011010111100001010000111100 0001110111010101100010010110000001110010011010010100010000010100111111111101110110011111000010110000111110010011101101010000100011111011110100100100010111011000101101010001111100000110100011101000100101101010011001111000001100100101010111110110001011011010111110111101100101101011100000001011111111100000110100110100001101111001111010001010001011110111001100101100111000111101011111101100101100001111 0111000010111011111011111000001100111001011001010000010011110001100010111101111111000100101111101101100101100000011101100101101101110001110110111100011000100111011110111110101110011110101000011111111100001001101100101101111010011110110101111101111010001001000110010101101010001011010011101110000010110010001110001110011101110101010001111101011011001011110110110111011111010001000011101001100100011110 1010101110100010000100000101101101100111000001100011000111011000101001011101010001110100100111001110101001111010101100001100010110000000101110100110111000001010000001001000110000000011110011111111000110110101001101001011001010111110010101001000100010100111000101001011010010001010010001110100001100001001111110010001100100000010111010110011011010001001011101000111101010011010000100111101010001101100 0110011111011001100111000011010010001100100100111100011010011010011101010001001000111000010101011010111111101011111001010000101001000101000001100111100101001000110111001111001011111000011110010101011011001001100101101010001010110001010001100010010110000101110101001110110100001111101110000101110011111100111100011110111010110100010110101100001110110000100011001011001010100110101000011100010100110111 0010111111001110011101111110011110010001001111111000101010010101100101111001111110100100001011100111001001110011100011101011101011111000101001111100000110101000110010000000110010000100101111110100001101000010010000111010101011110101100001011111001111001101100100000111011110000010000101100110111110110010111000100101001100101001111000111110000011110001111000100011100100001111000011011000101111011001 0010111000001101001111111101001101101111110011000001111001100100111010010000010010010010010000001010001001101101111010011111101010001010101010001001010101001101001011001011001000001111011001011010011000101000101001000010100101101111010100000001110001001010101111110111100001000010001100001101101001011001011001011110000000101101011001111111100010101111011011000100110011100100011111010100111110111000 1010111001011110001011001001011111101101010000111111111100100011011001110111101011111000011001111101000100011011110110101111011101101000110010001101101010001110001011101100010011000000111000100011010100100011101101100100010010010011111101110110110101111011000111001111000001011100000010111110001001100110010010001000111001111011100000010110111111101011101100001000010011110100111110111001010111001000 1010111001100001110110011101110110111011010111010111101000000101011001000011111101001101110101111000110100100111101110010110101101100101110010100111111110111001111001000011011110101111001100011000000011100100101101001111011101110111010000001010001001011010001000000111010101010000100100100101101100110010101000110110111100001101100011101101001110010110100011101010101101101110101111100000010001000110 1100000101011010001011001000001000101010101111111011100010101100111100010101101111101010101000101010001011011100010011101011010101001001101001001101011100011001011010000101111011011111110011001101010100010011011010011001101100101110101111001000101001001111101110111000000110010010010001111111101011111100010010011011001011001000110001000000000000011101000011011110101101101100000101110101011000101010 1001010101001011010001110001110101110001010000111000110110000101001010000101101110100111010000010111110100011110111000111011111010011110111000011101100101000101111110110000110011111110101010001000101111100101111000000101111000000111010011010010001011010010101011110010100100101011000101010100111110101111110010010110011111011010000000000100100111101000101011101000011010000111010011000010001010110010 0100001011000000010101010010010110101010010001010100100110100010100000101001001100100000110001010011001111100100001100011101110110000101110000110110000001111101100010110101010000110000111001000110001110001100100000001100110111011010110111010001100001100011001101111010101011110010011010110100111001100111100011111110011011110001010010111111011011101001011110010010011010011101101011000111110001111000 1011011110011101001100101010111100110111111100110000111110111110010001011101011000001010101101101101110110111010110101110111110001011101001111101000010100111010110001100101111000111111110001010001011101010000011110111101110100001110011111001001010100101001011011001001001001100001000111111010011011011000011100100011100001000110100100100100101011110110111011101100010000111001111000011100011110010010 1100010110111110100111001110111100110010110000010001110010011100000011110110001111100011000100111000110101110101110100001011101111001110100011101010100001010110111100101000111110101000100010100100011110111111111110011110010001110100100110010100000000101011101100011101001100001000000001011110011011001011001101010101011111110011111000000101000010111010010110001111000001000110101001110011010100111111 1010101001110010001000001010100000011110100011100000001000001000011001110101110100111001100111010110000111001001111000000010101110000010110111110001111010011111101010111101010101101001001011111111100110101100000111001111100010010100101111111101000101101010000110101111000101111111011010000110011010101100011010111101011011111010000001111111000111011110011100011111110000100101001001011111010110001010 0111111111111000100110011000000101011111000101010001011000100111000101111111111111010011000001110111001101011000001100000011001101001111100100001011110100001001100001000000000100101111110111111010011101010010100110011011011100001111000001111110111000000111101011011010000110001000110111110011011110010110101001110001011011100011010110101011111011000100011110110101111011011110111010011010111100001010 0001111001011010101101001111000001010101100011101011100000000100101011101010110100001101011111010001010100101101001100100011100100000111001111111011001111101101100010100011010111101110111100111101010101111111101011110010000110101110111100100000011001011110011001001111111001101011010100001000010101111100101011111100001100111110001000001010000001111101101100111111001100010101100101100100101010011011 0110011110000010100101000110011010011011111110010100110011011001100110000001010000100110011101101001010011000101111000100111101111000100001010011110100111011011100000111110100100110000111111010000111000101001011110110001110010101100110001000101111011010000000100001010110001111100111100111111011011110101111000101010011110001011000011111001101001011010101001100101100001011000010101100010111000100111 1110001100100100100111010000101000101011101100001100110000000011110000010011010011100110110010001101111010111000110101110011011010010011001100101010011000100101000100100101001100000010111101010100010111000111101100101011000101110001011001100110011001100100111100000101011011111110110001010110100110111011100011111110101010110111001111010100011010110101111000101000011111000000001111000010111011010001 0010111100101111011101000101001101001110100100000101000110100111110011111110010011000010110100010001110001110010011110000010001011000010001100111101010111000000010110001001001011101101101011010100100110101101000110101010100001101101001000010010010000011100111001111100011111000011101001001001000001001110100110100001010000011011001110111001101001111110110110111110111001110110101010000111101001001011 1011101000001111001110011100001100111010000000010101010000000100010100100001011101111101001000111101010101000101100101111010111100001000111101011100110110100001101011100110111001001101101001010000011111110001000110001010000000000110110101110111111111111000110111010110000110011100011101001111101111111000011010010111110111000100000001101110011101100100001010110100010100111111000100010110100010101010 1010010110101100000000111000010100010010001100110001000110101011011000001101001111000100111111110010011111111100111000111100100011010101100100010101000001111000000110010011100101100001011101101101110110000110111111010001101001101100010001101000001110000001011001010100000111100010011110100100111110110000100111000010111001100111110011010000100110011010000011101001100011001001000000100010111101101101 1011000001100000111100011111011011010111011100110111010100001001110100110100111100111001010111100010111111000011011010001111010001011100010111110100010100101010101111011110101011000000010101110010101100001101110110001010101011110110000000110000101110000000100100100011101111110011010101101101100100001000001111101011010001111010101101011001101101010011001100111010111110111111011110001000111101110010 1001100110010011110101000000110110001001011110011011011110100100001001101110100001011101011011101011111110000000110011001101010101101011110101001100111110110010001010011111110000111100100110111011111011101100001000110011100000111000100010101011000111001111101011010000110100001010101011110100000000100101001000100111010011101010101110000100101000001101101011010111101000100011010100001110001100001101 0010011101101000010001111011000111111010111101111000100111101111001001011110111100001000100100100101010011001101000010100111010100000111000010001101001000101101100100111011010100100110001111000100101101000000000010110001011100100001000000101111110111000101110010101001101010101101010001011010011100011101010011100000110100100001011000010000010001101101010011100111000101111010101000101001111011001101 0101000110011100111110111001001111010010000001100100100010000011000010111011010010111100100111000110101100110101001101110101111001011011011000100110011011101100001100110001000110110100100110111111011010101001011001001001000001111011010101010010011011100000101010011101100010110111111111111111011111001001010001011000100111100100000111011001000010100010110111001100011000000010110100100101100010000001 1011010110011101010011100011011000101011000111100000110110111100100100010000001001101110011101000000100011000100101000011001110001001111000011110001001111111110101110000100001110111001000100101000001011111100011111000101010001110001011001001000001001000011111010001100111001110110010011000100101100001001101101011111010010101110111001000000000100011001101001100000111010011011110110100101010000000000 0001001100001101101101101111100100111100000111101101111101100110001111010001100111010000011101111100000111001110011001000010010000100001100101110110000010010111111100101100100100101011010001100011001000110111010010100010001111001011000110000100011010000101001101101110100000000011010111011001101110000101100100010011111000000110100000011100110001000010010101011110101111010001000101010000111001100001 0110010001001100101000010111011110011001001100010000001111011011111111110110010011101010110100010100111011000101001110010000001101100110011001010000111100001100110000000110111101101100010011001100001110110000110011111010111101000101010001010011001110000100101001110011100111000110101000011111011000000001010101011100110011100111001000001010011000111101001100100101101101100010000010100111110001000101 0100110001011110000110011010011011010000000011010000110010100111001001100110100100000011110011001010011100010101000011010010100100111111111000101010001111011000111111111001111001100010001001010001000111011000111110100100000110101110100010111011001000011010100000010110110010100000111111110000110011000110110011011110010101001100101101011101001010011011111110100101011000010000000011110001101111000110 0000110110000111111100011101010010000111111010111111010100110101011110110001011111000100011110001101000110100001001010010011110111001010110011100100101111111100011101010001000010110000000101010000111000100010111010101111101011011001101111101001011000100001000000011111010001001010110000101010101100000001001111100011011001001010111011111001100111010101111111000101100101111011110110110010010001011001 1101110011001101101100100000111000100001011110101111011000000111100110100101010100000010100100000110001010001000000000101111001011011111001011000011100001100110010110000010000010000000110101100101000100001001110010111000010101101111111010111000101110100101111010011000111010000000011111101101100010110101111111011001110001001000100011000100010001100010011110111010000100011011001100101101010011100111 0101110010111010100000010001011010010011010001101001110110101010110100011010100000010111111111001010001011100101010000001001110011011110110000101101011010100110101110100010110011010001000110100100110011100001000001110110001011001110010101011010111001011111100011011011001010100100110111010111110110111000111011100011001101110100111001101011100101001001011011101001110110101101111101000011100011111110 1000111111100000111000011100001000011011111101000111101011001111110100010001111011110011000111010000110110010000001111000111001101011011100110101010101000101111101110100101000000111000011110100110011101111101011000010001111111011010100000001111010011001001000010000011011010100010111110010011100111100101100010001000100010000111011100110110000100100111010110011110001010110111101101101110000100111010 0001101100011110111011000111110011000011001110010010011001111011100110000101110101110010101010101111011100000000101110111000000111000010011101001010011110000111110010100101010101010011001001110110111111100001110111010101001100100111011010000100001101001100000011111011010101001010110101101010110001011000001001001011000001010000101001011011100010111111110110011000111011110101111101100011000100011000 1100001111110100001110101110010000001001111000110001011000000110110001111100111000110000001011000000110011100110110110010010010100010100100101101001010110111101001100011000000000011010000001101001000000010101111111110001100011000100111011111010101011110011000000111010011110011110011110010111101111100110010101010010111111011000010001111011011100101010001100110110100001010100001101010101000100111100 1111001001101000110111101101000001100111001010100011101001011010000011000000011100100111000110101001110001000111111100000000000100111110100110011010111110011100000111110011011111001111011010110100110000110101000001000011100101110000011100110000011100010011101010000000000110101111011100110001111111110111001100001001111101001101011100010011101111110101011110111100001101010010101100111100000000010000 1100111111100111110111110000111100010101000010011110000111100101010001001001001110111111011111111000011100111110100100101101001010101101110101000111101000101010001011011010110011011110010000100110101111011100110001111001011001011010011101000111100110111111110011100100011100010110110001100110010011000111101100111100000111001000101001000000011111100000100111010000101111110011100000011111011111100000 0100100001111000010110110100101010001000010101010100110100000110010111010100110000100011000101101001111101010011001110010010101100001000010101010101000100101100010010101001001110000000000001111001101101011000100111011110010101000000011100010110111110101110011100001111001011110100100110001011011101011001010101100111010011011000101000000011001011101001000100001010101111011000010110100000000111111000 0100101011101010001010111011010000010110001100000110011010010101110111000101100001001011001011110110010001010010110100011100000000001000000101110001101101110010110010000110001101110100001010110010101000011101100011101101101101011100010000011011001111111110101001001110011011011000110100101000111000001011010011110111110001001101010110011010110010101101111101001111010011111111001010111011111001010110 1101110011110001011001110101100010000110011010000010010001001000001110001101101110010011110101011000110000011000100000100110100101010000000111011111100110110111100101111101010111000010000011000010010101010100101101011101010111000011010101101011011010111111111100110100100001001100001001011101110001010001100011000111001010010100110010110010110111101110101011001001100100111000101111100100011011000010 0101111110111010000010000101010011011000011011111101011110110000011110101011000101010011111001101111100010111000000111011101011000111000011000011001011101011101101011000011011101111100011100100011011000100101000100000001110111111101010000011101011111101111100000000110000011010110111110011110001001101101001111000110001101011010101011101111100011011110110000001110000101100111010111110010100110100110 0100100101000111100101010010011001000010100101000100010111001011001111111011001011110000010010010101111011100111100111000100010111011111001011111100110011111000000010011101011011111000100101110010010010011000000000100010111101010001001101111000000101100101001111001111011101010110110011000110101001111101111011000011000011111110001110001110111010111100001101111100000111010110010110110000010000100011 1001101110110110101010011101000111101001001100001011111000001010001010101101110011011101000001111111011011010101001101011110000101101100011000111010001011001001110111110100111110011000100101000101010110001110110101010000100110110101000000010100100000001010100010001111111111010000111111110110110010000000110010101000110001010101001010110101011000010111000100010011100111001110101110111000010100000001 0010111111100010001110010110100000111100111010100010111100111111110111100111000010110110000110001110011101110000101110110010101111001101010111001011100110000101111000001001100100011000101010100010011011001011111110011001011000010010101101110010010100101001001101100110001010111010111000110000100001101110011010001111010011010101101011011100100010101111100000111111110111111010001000011011100100100011 1000010111100100110101100010100000100000010111001111001000111110011101011100011100101011100001000011101111100100010101000001001111111010010001001100101101111001001011001001111101100100001011000000011000010000111111100100100010100111011110001101011000111011110111010110110100100011011000110100111001010110101011100111101100101011001110010100100101111110001110010110111100000001100101000000011101001111 0101100101101111100110100000101111011111011010001100000101110011001110011110110110000001101111101110110110110000111010001110010010001011110101111100111101100111110010111101001111010010011010011001110110100111101001111101011000100011100110001001110101001011011101011010101100010000011101010110011011001001001111001100100111000100010101100110110000001101000111001110111110100001000010110011101101000010 1111111011010000001000101001111100001010101011010101111010000100100110110101100101000011011110011101110011011001110100110011100101111111101111001100010100010011010001111011010100110111010001111100111010111000000101010011100111010010100001111111111000001000110100110110000000011111101100001111100100111111010001011101100111010100110001110000100110111000011110100010110110110110101001010011100101110001 1001100100000110000011001111011001010100110101001101101111110101000000100110000101111100101011110010001111010101110101100100111100110111000100010011001011011100101011011111011101100001001111001110001101011000101110010110011000010100111001101010001010110110011110001000000101011010011101111110101010110001011011000000001111100111011000101111010111100011101110101111110110110001110010101001010101001111
cTrader

cTrader5.4の新機能

8/30/2025

cTraderがアップデートされました

お久しぶりです、ajinoriです。しばらくcTraderから離れてたのですが、久しぶりに見てみたらcTrader5.4で面白いアップデートがあったようじゃないですか。

アルゴリズム開発にpythonが利用可能になりました!

今回はもうこれだけです。

他にAPIのアップデートはあったようですが、そこまで大きなものなさそうなのでリンクだけ貼っておきます。

これまではアルゴリズム(cBot,インジケーター,プラグイン)の開発にはこれまでC#しか使えなかったのですが、これが pythonで開発できるようになりました。

今回はこの件について語りたいと思います。

使い方

新規作成画面からすすめていくとプログラミング言語選択の画面が出るのでpythonを選択します。

最初だけ必要なものをinstallするか聞かれるのでインストールを選んで進めてください。

設定が終わると

pythonコードが出てきました。最初の数行は動作させるためのおまじないだと思っておいてください。class ~ がcBotクラス本体です。

on_start, on_tickなどpython風の名前に変わってますが、そのままC#で書いたときのOnStart, OnTickに該当します。その他、on_stop,on_barなどなどそのままC#で書いてたときの名称をスネークケース(小文字+アンダスコア区切り)に変換した名前で定義可能です。

pythonで書けることのメリット

いまいち何が嬉しいのかピンとこない人も多いと思うのでajinoriが思うpythonでアルゴリズムを作れることのメリットを上げておきます。

習得しやすいメジャー言語

pythonは比較的わかりやすく習得しやすい言語と言われており、あらゆるところで使われるようになってきています。最近だとpythonからプログラミングに入る人も多いようです。

cTraderのcBot開発を他人にオススメするときも「C#の勉強にもなるよ!」というより「pythonの勉強にもなるよ!」といえたほうが魅力的です。

データ解析や機械学習のデファクトスタンダード

さらに、 データ解析や機械学習,AI関連開発などは主にpythonが使われています。

cBotがpythonで書けることでこのような手法を取り入れたcBotが作られやすくなります。

pythonで書くことのデメリット

じゃあもう全部pythonでいいかというと残念ながらそういうわけには行きません。pythonにも・・・というか cTrader開発でpythonを使うことにはデメリットもあります。 うん、試してみたらメリット全部ぶっ潰すくらいたくさんありました。

遅い

pythonは遅い です。普通に使う分にはあまり気になることはないのですが、マイクロ秒単位で少しでも早く発注入れたい!というときに使うべきではないです。そいういうシビアなプログラムはC#で作っておいたほうがいいでしょう。

とはいっても大抵のプログラムでは気にするほどではないと思います。

ビルド時のチェックが効かない

pythonにはそもそもビルドという概念がありません。

pythonで書いたcTraderアルゴの場合、本体はC#なのでビルドは必要なのですが、pythonコードは単に中に埋め込まれてるだけのため、中身がどんなにおかしくてもビルド成功 してしまうのです。

当然そんなもの動くわけもなく実行時にエラーをはいて止まります。

pythonコード部分を別にテストする仕組みを作らないとめちゃくちゃデバッグがきつくなりそうです。

開発環境は整ってない

これはpython自体のデメリットではないのですが、 cTrader周りの開発においてはまだまだC#のほうが開発しやすい 状況になっています。

というのも、これってpythonnetというライブラリを使用してpythonコードをC#プログラム内で実行させることで実現してるので、いわゆる普通のpythonプログラムではないんですよね。

私は普段VSCodeで開発していますが、この辺の事情によりpythonでcBot作ろうとするとインテリセンスがうまく効きませんし、エラー表示だらけになります。もしかしたら頑張って色々設定すれば解決できる部分はあるかもしれませんが、そこに頑張るくらいならC#で書くかな・・・と。

今のところ「一応pythonでも書けるようになったよ!」という程度で決して開発環境が整ってるとは言い難い感じがします。

いくらpythonが使いやすいとはいえこれは初学者には厳しいです。

pythonだけでは完結しない

もとがC#なこともあり、現状pythonだけで作り上げることはできません。

パラメータの定義は結局C#の.csファイルで行う 必要があります。

別にC#を知らなくても決まった書き方さえ覚えればできるので、そこまで大変ではないのですが.pyファイルと.csファイルを両方編集しなければいけないのはちょっと手間です。ついでにcTrader組込エディタだとそもそもどこから編集すればいいのかすらわからないです。

サンプルコード

ぶっちゃけデメリットのが目立つのでサンプル作るかも迷ったのですが一応・・・

MAクロスで売買するcBotをpythonで書くとこうなります。

import clr

clr.AddReference("cAlgo.API")

# Import cAlgo API types
from cAlgo.API import *

# Import trading wrapper functions
from robot_wrapper import *

class py_ma_cross:
    def on_start(self):
        self.label = "py_ma_cross"
        # 期間は UI から設定(FastPeriod / SlowPeriod)
        self.fast = api.Indicators.SimpleMovingAverage(
            api.Bars.ClosePrices, api.FastPeriod
        )
        self.slow = api.Indicators.SimpleMovingAverage(
            api.Bars.ClosePrices, api.SlowPeriod
        )

    def on_bar_closed(self):
        # ゴールデンクロス: fast が slow を上抜け → 売りを閉じて買い
        if self.fast.Result.Last(0) > self.slow.Result.Last(0)             and self.fast.Result.Last(1) <= self.slow.Result.Last(1):
            self._close_positions(TradeType.Sell)
            api.ExecuteMarketOrder(TradeType.Buy, api.SymbolName, 1000, self.label)

        # デッドクロス: fast が slow を下抜け → 買いを閉じて売り
        elif self.fast.Result.Last(0) < self.slow.Result.Last(0)             and self.fast.Result.Last(1) >= self.slow.Result.Last(1):
            self._close_positions(TradeType.Buy)
            api.ExecuteMarketOrder(TradeType.Sell, api.SymbolName, 1000, self.label)

    def _close_positions(self, side):
        for p in api.Positions.FindAll(self.label):
            if p.TradeType == side:
                api.ClosePosition(p)

パラメータの設定の仕方

移動平均線の期間など、外部から渡すパラメータですが、これはC#のファイルで用意する必要があります。組み込み開発環境からの編集のやり方が見当たらないのですが、直接ファイル開いて別のエディタで編集してもいけます。

.pyファイルがあるフォルダを見てみてください。

windowsなら"ドキュメント/cAlgo/Sources/Robots/{cBot名}/" にあると思います。

ここに{cBot名}.csというファイルが作られてますので、その中に定義します。ここは普通にC#で書くときと同じで、上記サンプルだとこう。

using System;
using cAlgo.API;
using Python.Runtime;

namespace cAlgo.Robots;

[Robot(AccessRights = AccessRights.None, AddIndicators = true)]
public partial class py_ma_cross : Robot {

    [Parameter("Fast MA Period", DefaultValue = 10, MinValue = 1)]
    public int FastPeriod { get; set; }

    [Parameter("Slow MA Period", DefaultValue = 30, MinValue = 2)]
    public int SlowPeriod { get; set; }

}

3rd partyライブラリの使い方

サンプルでは使用してませんが、pandasやnumpyなどの外部パッケージも使用可能みたいです。公式

これも同じフォルダ内にrequirements.txtが用意されています。

この中に使いたいライブラリ名とバージョンを書くことでビルド時にpip installしてくれる・・・はずなのですが、私のとこではなんかうまく動きませんでした。

誰か試してみてください。

(書き方はpythonで使う普通のrequirements.txtと同じ)

pandas==2.2.2

まとめ

pythonで書けるようになったぜ!という喜びのポストだったはずが、なんか愚痴みたいなのが多くなってしまいました。

まぁC#ですでにアルゴリズム作ってる人があえてpythonに切り替えるメリットは少なそうですね。慣れてる人は「どうしてもpython使いたい部分だけpythonで書く」みたいな使い方がちょうどいいのかもしれません。

それでも 「公式公認でpythonで書けるようになった」 というのはcBot開発の裾野を広げるという点では大きな意味を持つと思います。

cTrader使いの非プログラマーだけどpythonだけならちょっとわかるぞ、という方はもしよかったらチャレンジしてみてください。

すみません、触ってて気が変わりました。使いにくすぎるし思うように動かない。これはまだ人に勧めてよいものではありませんね。もう少し成熟するまで待つことをオススメします・・・


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

新しいコメント

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

cTrader's Life

© 2025 ajinori