input: Write a python function to convert a list of commands to the binary format used by the game.
  ```python
  assert to_bin([(WRD_HEADER, {}), (WRD_SHOW_LINE, {})]) == b'\x00\x00\x00\x00\x00\x02'
  assert to_bin([(0x01, {"val": 0x03}), (0x02, {"val": 0x04})]) == b'\x00\x01\x03\x00\x02\x04'
  assert to_bin([(0xFF, {"val": 0xFF})]) == b'\x00\xff\xff'
output: def to_bin(commands):
      result = bytearray()
      for cmd, params in commands:
          result.append(cmd)
          for key, value in params.items():
              result.append(value)
      return bytes(result)