import sndmixer, _thread, time

channels = 8

sndmixer.begin(channels)

for i in range(channels):
	sndmixer.synth()
	sndmixer.waveform(i+1, 1)
	sndmixer.volume(i+1, 100)
	sndmixer.play(i+1)

#[freq, volume, fTime, vTime, dVolume, dActive]

_currentNotes = []
notes         = []

for i in range(channels):
	_currentNotes.append([0,0,0,0,0,0,False])
	notes.append([0,0,0,0,0,0,False])

def synthThread():
	global channels, _currentNotes, notes
	lastTick = 0
	while True:
		currTick = time.ticks_ms()
		if (currTick-lastTick < 10):
			time.sleep_ms(10-(currTick-lastTick))
		lastTick = time.ticks_ms()
		for i in range(channels):
			if _currentNotes[i][0] != notes[i][0]:
				if notes[i][2] == 0 or notes[i][0]-_currentNotes[i][0] < 0.0001:
					_currentNotes[i][0] = notes[i][0]
				else:
					c = notes[i][0]-_currentNotes[i][0]
					c = c / notes[i][2]
					_currentNotes[i][0] += c
				sndmixer.freq(i+1, int(_currentNotes[i][0]))
			if _currentNotes[i][1] != notes[i][1]:
				if notes[i][3] == 0: #or notes[i][1]-_currentNotes[i][1] < 0.0001:
					_currentNotes[i][1] = notes[i][1]
				else:
					d = notes[i][1]-_currentNotes[i][1]
					c = d / notes[i][3]
					_currentNotes[i][1] += c
				sndmixer.volume(i+1, int(_currentNotes[i][1]))
			elif notes[i][6]:
				notes[i][6] = False
				notes[i][1] = notes[i][4]
				notes[i][3] = notes[i][5]



def on(note, freq, aVolume, aTime, dVolume, dTime):
	notes[note][0] = freq
	notes[note][1] = aVolume
	notes[note][3] = aTime
	notes[note][4] = dVolume
	notes[note][5] = dTime
	notes[note][6] = True

def off(note, sTime):
	notes[note][1] = 0
	notes[note][3] = sTime
	notes[note][6] = False

song = [
[0,739,0,0,0,0,0,0,0],
[163,0,0,0,0,0,0,0,0],
[12,369,0,0,0,0,0,0,0],
[133,0,0,0,0,0,0,0,0],
[28,554,0,0,0,0,0,0,0],
[134,0,0,0,0,0,0,0,0],
[29,739,0,0,0,0,0,0,0],
[152,0,0,0,0,0,0,0,0],
[12,830,0,0,0,0,0,0,0],
[149,0,0,0,0,0,0,0,0],
[12,554,0,0,0,0,0,0,0],
[141,0,0,0,0,0,0,0,0],
[22,739,0,0,0,0,0,0,0],
[139,0,0,0,0,0,0,0,0],
[13,830,0,0,0,0,0,0,0],
[150,0,0,0,0,0,0,0,0],
[12,987,0,0,0,0,0,0,0],
[150,0,0,0,0,0,0,0,0],
[30,554,0,0,0,0,0,0,0],
[133,0,0,0,0,0,0,0,0],
[13,987,0,0,0,0,0,0,0],
[139,0,0,0,0,0,0,0,0],
[22,932,0,0,0,0,0,0,0],
[152,0,0,0,0,0,0,0,0],
[17,554,0,0,0,0,0,0,0],
[144,0,0,0,0,0,0,0,0],
[19,932,0,0,0,0,0,0,0],
[132,0,0,0,0,0,0,0,0],
[30,830,0,0,0,0,0,0,0],
[133,0,0,0,0,0,0,0,0],
[11,739,0,0,0,0,0,0,0],
[152,0,0,0,0,0,0,0,0],
[29,184,554,0,0,0,0,0,0],
[500,277,554,0,0,0,0,0,0],
[475,0,554,0,0,0,0,0,0],
[16,369,554,0,0,0,0,0,0],
[623,369,0,0,0,0,0,0,0],
[17,369,739,0,0,0,0,0,0],
[295,369,0,0,0,0,0,0,0],
[30,369,830,0,0,0,0,0,0],
[296,369,0,0,0,0,0,0,0],
[28,369,987,0,0,0,0,0,0],
[301,369,0,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[12,164,987,0,0,0,0,0,0],
[506,246,987,0,0,0,0,0,0],
[162,246,932,0,0,0,0,0,0],
[149,246,0,0,0,0,0,0,0],
[13,246,932,0,0,0,0,0,0],
[150,0,932,0,0,0,0,0,0],
[11,329,932,0,0,0,0,0,0],
[963,329,830,0,0,0,0,0,0],
[303,329,0,0,0,0,0,0,0],
[23,329,739,0,0,0,0,0,0],
[302,329,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[19,155,1108,0,0,0,0,0,0],
[499,233,1108,0,0,0,0,0,0],
[475,0,0,0,0,0,0,0,0],
[18,311,739,0,0,0,0,0,0],
[962,311,1479,0,0,0,0,0,0],
[640,0,1479,0,0,0,0,0,0],
[11,146,1479,0,0,0,0,0,0],
[505,0,1479,220,0,0,0,0,0],
[478,0,1479,0,0,0,0,0,0],
[9,293,1479,0,0,0,0,0,0],
[953,293,0,0,0,0,0,0,0],
[13,293,1661,0,0,0,0,0,0],
[301,293,0,0,0,0,0,0,0],
[22,293,1479,0,0,0,0,0,0],
[139,293,0,0,0,0,0,0,0],
[13,293,2217,0,0,0,0,0,0],
[161,0,2217,0,0,0,0,0,0],
[12,184,2217,0,0,0,0,0,0],
[152,0,2217,0,0,0,0,0,0],
[30,184,2217,0,0,0,0,0,0],
[121,0,2217,0,0,0,0,0,0],
[41,184,2217,0,0,0,0,0,0],
[123,0,2217,0,0,0,0,0,0],
[40,184,2217,0,0,0,0,0,0],
[122,0,2217,0,0,0,0,0,0],
[41,184,2217,0,0,0,0,0,0],
[122,0,2217,0,0,0,0,0,0],
[38,184,2217,0,0,0,0,0,0],
[124,0,2217,0,0,0,0,0,0],
[39,184,2217,0,0,0,0,0,0],
[122,0,2217,0,0,0,0,0,0],
[30,184,2217,0,0,0,0,0,0],
[133,0,2217,0,0,0,0,0,0],
[31,184,2217,0,0,0,0,0,0],
[139,0,2217,0,0,0,0,0,0],
[39,184,2217,0,0,0,0,0,0],
[124,0,2217,0,0,0,0,0,0],
[22,184,2217,0,0,0,0,0,0],
[121,0,2217,0,0,0,0,0,0],
[42,184,2217,0,0,0,0,0,0],
[121,0,2217,0,0,0,0,0,0],
[42,184,2217,0,0,0,0,0,0],
[127,0,2217,0,0,0,0,0,0],
[41,184,2217,0,0,0,0,0,0],
[122,0,2217,0,0,0,0,0,0],
[39,184,2217,0,0,0,0,0,0],
[124,0,2217,0,0,0,0,0,0],
[22,184,2217,0,0,0,0,0,0],
[122,0,2217,0,0,0,0,0,0],
[42,0,0,0,0,0,0,0,0],
[16,184,0,0,0,0,0,0,0],
[152,0,0,0,0,0,0,0,0],
[24,184,0,0,0,0,0,0,0],
[120,0,0,0,0,0,0,0,0],
[42,184,0,0,0,0,0,0,0],
[120,0,0,0,0,0,0,0,0],
[43,184,0,0,0,0,0,0,0],
[120,0,0,0,0,0,0,0,0],
[46,184,466,0,0,0,0,0,0],
[122,0,466,0,0,0,0,0,0],
[23,0,0,0,0,0,0,0,0],
[19,184,493,0,0,0,0,0,0],
[121,0,493,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[29,554,184,0,0,0,0,0,0],
[121,554,0,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[12,184,554,0,0,0,0,0,0],
[168,174,554,0,0,0,0,0,0],
[133,0,554,0,0,0,0,0,0],
[41,174,554,0,0,0,0,0,0],
[123,0,0,0,0,0,0,0,0],
[28,174,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,174,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[29,174,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[41,174,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,174,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[28,174,739,0,0,0,0,0,0],
[150,174,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[11,155,830,0,0,0,0,0,0],
[150,0,830,0,0,0,0,0,0],
[29,155,830,0,0,0,0,0,0],
[124,0,830,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[27,155,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,155,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[42,155,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[41,155,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[41,155,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[29,155,739,0,0,0,0,0,0],
[161,138,739,0,0,0,0,0,0],
[136,0,739,0,0,0,0,0,0],
[38,138,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[29,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[41,138,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[41,138,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[13,698,138,0,0,0,0,0,0],
[127,698,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[13,138,739,0,0,0,0,0,0],
[149,138,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[17,123,0,0,0,0,0,0,0],
[1,123,1108,0,0,0,0,0,0],
[146,0,1108,0,0,0,0,0,0],
[27,123,1108,0,0,0,0,0,0],
[123,0,1108,0,0,0,0,0,0],
[40,123,1108,0,0,0,0,0,0],
[122,0,1108,0,0,0,0,0,0],
[41,123,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[13,123,739,0,0,0,0,0,0],
[120,0,739,0,0,0,0,0,0],
[41,123,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,123,739,0,0,0,0,0,0],
[127,0,739,0,0,0,0,0,0],
[25,123,739,0,0,0,0,0,0],
[161,130,739,0,0,0,0,0,0],
[139,0,739,0,0,0,0,0,0],
[42,130,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[23,130,739,0,0,0,0,0,0],
[128,0,739,0,0,0,0,0,0],
[38,130,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,130,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[40,130,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[22,0,0,0,0,0,0,0,0],
[19,130,739,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[30,130,0,0,0,0,0,0,0],
[1,130,739,0,0,0,0,0,0],
[121,130,0,0,0,0,0,0,0],
[40,0,0,0,0,0,0,0,0],
[11,739,138,0,0,0,0,0,0],
[151,739,0,0,0,0,0,0,0],
[24,739,138,0,0,0,0,0,0],
[123,739,0,0,0,0,0,0,0],
[45,739,138,0,0,0,0,0,0],
[122,739,0,0,0,0,0,0,0],
[40,739,138,0,0,0,0,0,0],
[123,739,0,0,0,0,0,0,0],
[40,739,138,0,0,0,0,0,0],
[122,739,0,0,0,0,0,0,0],
[25,0,0,0,0,0,0,0,0],
[15,138,830,0,0,0,0,0,0],
[122,0,830,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[29,138,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[17,138,698,0,0,0,0,0,0],
[135,0,698,0,0,0,0,0,0],
[27,138,698,0,0,0,0,0,0],
[134,0,698,0,0,0,0,0,0],
[42,138,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[27,138,698,0,0,0,0,0,0],
[123,0,698,0,0,0,0,0,0],
[42,138,698,0,0,0,0,0,0],
[128,0,698,0,0,0,0,0,0],
[40,138,698,0,0,0,0,0,0],
[121,0,698,0,0,0,0,0,0],
[42,138,698,0,0,0,0,0,0],
[128,0,698,0,0,0,0,0,0],
[40,138,698,0,0,0,0,0,0],
[128,0,698,0,0,0,0,0,0],
[28,138,698,0,0,0,0,0,0],
[168,0,0,0,0,0,0,0,0],
[18,184,466,0,0,0,0,0,0],
[157,0,466,0,0,0,0,0,0],
[28,184,466,0,0,0,0,0,0],
[129,0,466,0,0,0,0,0,0],
[40,184,466,0,0,0,0,0,0],
[121,0,466,0,0,0,0,0,0],
[42,184,466,0,0,0,0,0,0],
[122,0,466,0,0,0,0,0,0],
[40,184,466,0,0,0,0,0,0],
[121,0,466,0,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[11,184,415,0,0,0,0,0,0],
[123,0,415,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[24,184,369,0,0,0,0,0,0],
[122,0,369,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[12,184,554,0,0,0,0,0,0],
[163,164,554,0,0,0,0,0,0],
[132,0,554,0,0,0,0,0,0],
[41,164,554,0,0,0,0,0,0],
[128,0,554,0,0,0,0,0,0],
[25,164,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[40,164,554,0,0,0,0,0,0],
[123,0,554,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[10,164,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,164,739,0,0,0,0,0,0],
[127,0,739,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[29,164,830,0,0,0,0,0,0],
[121,0,830,0,0,0,0,0,0],
[25,164,830,0,0,0,0,0,0],
[150,164,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[18,155,987,0,0,0,0,0,0],
[145,0,987,0,0,0,0,0,0],
[29,155,987,0,0,0,0,0,0],
[121,0,987,0,0,0,0,0,0],
[40,155,987,0,0,0,0,0,0],
[122,0,987,0,0,0,0,0,0],
[41,0,0,0,0,0,0,0,0],
[1,932,155,0,0,0,0,0,0],
[123,932,0,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[12,155,932,0,0,0,0,0,0],
[127,0,932,0,0,0,0,0,0],
[40,155,932,0,0,0,0,0,0],
[124,0,932,0,0,0,0,0,0],
[39,155,932,0,0,0,0,0,0],
[123,0,932,0,0,0,0,0,0],
[24,155,932,0,0,0,0,0,0],
[161,146,932,0,0,0,0,0,0],
[140,0,932,0,0,0,0,0,0],
[40,146,932,0,0,0,0,0,0],
[123,0,932,0,0,0,0,0,0],
[28,146,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[42,146,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[40,1108,146,0,0,0,0,0,0],
[120,1108,0,0,0,0,0,0,0],
[40,1108,146,0,0,0,0,0,0],
[124,1108,0,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,146,987,0,0,0,0,0,0],
[121,0,987,0,0,0,0,0,0],
[30,146,987,0,0,0,0,0,0],
[146,146,0,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[13,138,932,0,0,0,0,0,0],
[150,0,932,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[19,138,987,0,0,0,0,0,0],
[121,0,987,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,138,0,0,0,0,0,0,0],
[1,138,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,138,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[42,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[13,138,554,0,0,0,0,0,0],
[123,0,554,0,0,0,0,0,0],
[42,138,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[30,138,554,0,0,0,0,0,0],
[163,130,554,0,0,0,0,0,0],
[131,0,554,0,0,0,0,0,0],
[31,0,0,0,0,0,0,0,0],
[10,130,830,0,0,0,0,0,0],
[123,0,830,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[14,130,0,0,0,0,0,0,0],
[1,130,739,0,0,0,0,0,0],
[120,0,739,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[29,130,698,0,0,0,0,0,0],
[150,130,0,0,0,0,0,0,0],
[12,622,0,0,0,0,0,0,0],
[1,622,138,0,0,0,0,0,0],
[121,622,0,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[13,138,698,0,0,0,0,0,0],
[120,0,698,0,0,0,0,0,0],
[43,138,698,0,0,0,0,0,0],
[121,0,698,0,0,0,0,0,0],
[29,138,698,0,0,0,0,0,0],
[163,0,0,0,0,0,0,0,0],
[17,146,739,0,0,0,0,0,0],
[202,0,0,0,0,0,0,0,0],
[297,164,739,0,0,0,0,0,0],
[477,0,0,0,0,0,0,0,0],
[10,184,739,0,0,0,0,0,0],
[304,0,0,0,0,0,0,0,0],
[10,92,0,0,0,0,0,0,0],
[140,0,0,0,0,0,0,0,0],
[40,92,0,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[24,92,0,0,0,0,0,0,0],
[123,0,0,0,0,0,0,0,0],
[40,92,0,0,0,0,0,0,0],
[128,0,0,0,0,0,0,0,0],
[40,92,0,0,0,0,0,0,0],
[123,0,0,0,0,0,0,0,0],
[39,92,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[41,92,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[24,92,0,0,0,0,0,0,0],
[168,0,0,0,0,0,0,0,0],
[12,123,440,0,0,0,0,0,0],
[1,123,440,739,0,0,0,0,0],
[149,0,0,0,0,0,0,0,0],
[24,123,440,739,0,0,0,0,0],
[121,123,440,0,0,0,0,0,0],
[42,0,0,0,0,0,0,0,0],
[329,164,830,493,0,0,0,0,0],
[123,0,830,493,0,0,0,0,0],
[25,0,830,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[15,164,493,830,0,0,0,0,0],
[132,164,0,0,0,0,0,0,0],
[31,0,0,0,0,0,0,0,0],
[151,110,440,659,0,0,0,0,0],
[294,0,440,659,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[29,110,659,0,0,0,0,0,0],
[122,0,659,0,0,0,0,0,0],
[27,110,659,0,0,0,0,0,0],
[122,0,659,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[13,110,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[40,110,554,0,0,0,0,0,0],
[123,0,554,0,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[11,110,659,0,0,0,0,0,0],
[122,0,659,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,110,493,0,0,0,0,0,0],
[121,0,493,0,0,0,0,0,0],
[18,0,0,0,0,0,0,0,0],
[11,110,554,0,0,0,0,0,0],
[41,110,0,0,0,0,0,0,0],
[10,110,493,0,0,0,0,0,0],
[40,110,0,0,0,0,0,0,0],
[19,110,440,0,0,0,0,0,0],
[39,110,0,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[11,123,293,493,0,0,0,0,0],
[150,0,293,493,0,0,0,0,0],
[30,123,293,493,0,0,0,0,0],
[122,0,293,493,0,0,0,0,0],
[10,0,0,0,0,0,0,0,0],
[29,293,123,0,0,0,0,0,0],
[1,293,123,440,0,0,0,0,0],
[121,293,0,440,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[30,123,493,293,0,0,0,0,0],
[122,0,493,293,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[13,123,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[39,123,0,0,0,0,0,0,0],
[2,123,293,440,0,0,0,0,0],
[121,0,293,440,0,0,0,0,0],
[11,0,0,440,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[29,123,0,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[29,349,123,554,0,0,0,0,0],
[162,349,138,554,0,0,0,0,0],
[136,349,0,554,0,0,0,0,0],
[40,349,138,554,0,0,0,0,0],
[122,349,0,554,0,0,0,0,0],
[27,349,138,554,0,0,0,0,0],
[122,349,0,554,0,0,0,0,0],
[40,349,138,554,0,0,0,0,0],
[123,349,0,554,0,0,0,0,0],
[41,349,138,554,0,0,0,0,0],
[122,349,0,554,0,0,0,0,0],
[42,349,138,554,0,0,0,0,0],
[119,349,0,554,0,0,0,0,0],
[47,349,138,554,0,0,0,0,0],
[124,349,0,554,0,0,0,0,0],
[21,349,138,554,0,0,0,0,0],
[163,0,138,554,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[18,587,739,123,0,0,0,0,0],
[143,0,739,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[28,123,587,739,0,0,0,0,0],
[123,123,587,0,0,0,0,0,0],
[40,123,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[326,164,659,830,0,0,0,0,0],
[121,0,659,830,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[9,164,659,830,0,0,0,0,0],
[142,164,0,0,0,0,0,0,0],
[26,0,0,0,0,0,0,0,0],
[147,110,880,554,0,0,0,0,0],
[302,0,880,554,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,659,554,110,0,0,0,0,0],
[123,659,554,0,0,0,0,0,0],
[27,659,554,110,0,0,0,0,0],
[121,659,554,0,0,0,0,0,0],
[14,0,0,0,0,0,0,0,0],
[29,110,659,554,0,0,0,0,0],
[121,0,659,554,0,0,0,0,0],
[41,110,659,554,0,0,0,0,0],
[121,0,659,554,0,0,0,0,0],
[22,0,0,0,0,0,0,0,0],
[19,110,554,659,0,0,0,0,0],
[120,0,554,659,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[29,110,659,880,0,0,0,0,0],
[121,0,659,880,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[16,110,987,739,0,0,0,0,0],
[164,0,987,739,0,0,0,0,0],
[11,123,987,739,0,0,0,0,0],
[151,0,987,739,0,0,0,0,0],
[30,123,987,739,0,0,0,0,0],
[121,0,987,739,0,0,0,0,0],
[41,123,987,739,0,0,0,0,0],
[122,0,987,739,0,0,0,0,0],
[39,123,987,739,0,0,0,0,0],
[121,0,987,739,0,0,0,0,0],
[43,123,987,739,0,0,0,0,0],
[121,0,987,739,0,0,0,0,0],
[39,123,987,739,0,0,0,0,0],
[124,0,987,739,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[10,123,880,739,0,0,0,0,0],
[123,0,880,739,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[17,123,698,1108,0,0,0,0,0],
[160,138,698,1108,0,0,0,0,0],
[135,0,698,1108,0,0,0,0,0],
[41,138,698,1108,0,0,0,0,0],
[121,0,698,1108,0,0,0,0,0],
[29,138,698,1108,0,0,0,0,0],
[122,0,698,1108,0,0,0,0,0],
[41,138,698,1108,0,0,0,0,0],
[121,0,698,1108,0,0,0,0,0],
[42,138,698,1108,0,0,0,0,0],
[120,0,698,1108,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[12,138,698,1108,0,0,0,0,0],
[123,0,698,1108,0,0,0,0,0],
[16,0,0,1108,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[22,138,698,0,0,0,0,0,0],
[2,138,698,1108,0,0,0,0,0],
[121,0,698,1108,0,0,0,0,0],
[18,0,0,0,0,0,0,0,0],
[11,138,739,1108,0,0,0,0,0],
[163,0,739,1108,0,0,0,0,0],
[11,146,739,1108,0,0,0,0,0],
[153,0,739,1108,0,0,0,0,0],
[16,0,0,1108,0,0,0,0,0],
[12,146,369,1108,0,0,0,0,0],
[123,0,369,1108,0,0,0,0,0],
[12,0,0,1108,0,0,0,0,0],
[28,146,554,1108,0,0,0,0,0],
[123,0,554,1108,0,0,0,0,0],
[11,0,0,1108,0,0,0,0,0],
[27,146,739,1108,0,0,0,0,0],
[124,0,739,1108,0,0,0,0,0],
[28,0,0,1108,0,0,0,0,0],
[12,146,830,1108,0,0,0,0,0],
[122,0,830,1108,0,0,0,0,0],
[29,0,0,1108,0,0,0,0,0],
[10,146,554,1108,0,0,0,0,0],
[122,0,554,1108,0,0,0,0,0],
[18,0,0,1108,0,0,0,0,0],
[24,146,739,1108,0,0,0,0,0],
[122,0,739,1108,0,0,0,0,0],
[18,0,0,1108,0,0,0,0,0],
[10,146,830,1108,0,0,0,0,0],
[133,0,830,1108,0,0,0,0,0],
[18,0,0,1108,0,0,0,0,0],
[11,146,987,1108,0,0,0,0,0],
[151,146,0,1108,0,0,0,0,0],
[28,146,554,1108,0,0,0,0,0],
[122,0,554,1108,0,0,0,0,0],
[14,0,0,1108,0,0,0,0,0],
[11,987,0,1108,0,0,0,0,0],
[138,0,0,1108,0,0,0,0,0],
[24,932,0,1108,0,0,0,0,0],
[152,0,0,1108,0,0,0,0,0],
[17,146,293,1108,554,0,0,0,0],
[145,146,293,1108,0,0,0,0,0],
[18,146,293,1108,932,0,0,0,0],
[134,0,0,1108,932,0,0,0,0],
[1,0,0,1108,0,0,0,0,0],
[28,164,830,1108,329,0,0,0,0],
[132,164,0,1108,329,0,0,0,0],
[12,164,739,1108,329,0,0,0,0],
[151,0,739,1108,329,0,0,0,0],
[1,0,0,1108,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[13,184,0,0,0,0,0,0,0],
[149,0,0,0,0,0,0,0,0],
[24,184,0,0,0,0,0,0,0],
[123,0,0,0,0,0,0,0,0],
[39,184,0,0,0,0,0,0,0],
[124,0,0,0,0,0,0,0,0],
[40,184,0,0,0,0,0,0,0],
[127,0,0,0,0,0,0,0,0],
[40,184,466,0,0,0,0,0,0],
[123,0,466,0,0,0,0,0,0],
[24,0,0,0,0,0,0,0,0],
[16,184,493,0,0,0,0,0,0],
[122,0,493,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,184,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[11,184,554,0,0,0,0,0,0],
[168,174,554,0,0,0,0,0,0],
[133,0,554,0,0,0,0,0,0],
[42,174,554,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[28,174,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[42,174,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[27,174,698,0,0,0,0,0,0],
[124,0,698,0,0,0,0,0,0],
[40,174,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[31,174,739,0,0,0,0,0,0],
[120,0,739,0,0,0,0,0,0],
[30,174,739,0,0,0,0,0,0],
[152,174,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[11,155,830,0,0,0,0,0,0],
[151,0,830,0,0,0,0,0,0],
[29,155,830,0,0,0,0,0,0],
[122,0,830,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[30,155,932,0,0,0,0,0,0],
[121,0,932,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,155,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[41,155,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[42,155,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[40,155,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[29,155,739,0,0,0,0,0,0],
[161,138,739,0,0,0,0,0,0],
[133,0,739,0,0,0,0,0,0],
[40,138,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[28,138,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[38,138,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[39,138,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[39,138,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[10,138,698,0,0,0,0,0,0],
[128,0,698,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[13,138,739,0,0,0,0,0,0],
[151,138,0,0,0,0,0,0,0],
[10,0,0,0,0,0,0,0,0],
[18,123,1108,0,0,0,0,0,0],
[145,0,1108,0,0,0,0,0,0],
[29,123,1108,0,0,0,0,0,0],
[122,0,1108,0,0,0,0,0,0],
[40,123,1108,0,0,0,0,0,0],
[122,0,1108,0,0,0,0,0,0],
[41,123,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[11,123,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[41,123,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[40,123,739,0,0,0,0,0,0],
[128,0,739,0,0,0,0,0,0],
[25,123,739,0,0,0,0,0,0],
[162,130,739,0,0,0,0,0,0],
[140,0,739,0,0,0,0,0,0],
[39,130,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[30,130,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[41,130,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[41,130,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[40,130,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[31,0,0,0,0,0,0,0,0],
[11,130,739,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[29,130,0,0,0,0,0,0,0],
[2,130,739,0,0,0,0,0,0],
[122,130,0,0,0,0,0,0,0],
[38,0,0,0,0,0,0,0,0],
[13,138,739,0,0,0,0,0,0],
[152,0,739,0,0,0,0,0,0],
[21,138,739,0,0,0,0,0,0],
[130,0,739,0,0,0,0,0,0],
[41,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[39,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[40,138,739,0,0,0,0,0,0],
[124,0,739,0,0,0,0,0,0],
[21,0,0,0,0,0,0,0,0],
[17,138,830,0,0,0,0,0,0],
[122,0,830,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[30,138,0,0,0,0,0,0,0],
[2,138,739,0,0,0,0,0,0],
[120,0,739,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[17,138,698,0,0,0,0,0,0],
[131,0,698,0,0,0,0,0,0],
[29,138,698,0,0,0,0,0,0],
[133,0,698,0,0,0,0,0,0],
[42,138,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[28,138,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[40,138,698,0,0,0,0,0,0],
[129,0,698,0,0,0,0,0,0],
[38,138,698,0,0,0,0,0,0],
[125,0,698,0,0,0,0,0,0],
[40,138,698,0,0,0,0,0,0],
[128,0,698,0,0,0,0,0,0],
[39,138,698,0,0,0,0,0,0],
[129,0,698,0,0,0,0,0,0],
[27,138,698,0,0,0,0,0,0],
[169,0,0,0,0,0,0,0,0],
[18,466,184,0,0,0,0,0,0],
[155,466,0,0,0,0,0,0,0],
[30,466,184,0,0,0,0,0,0],
[128,466,0,0,0,0,0,0,0],
[41,466,184,0,0,0,0,0,0],
[122,466,0,0,0,0,0,0,0],
[41,466,184,0,0,0,0,0,0],
[119,466,0,0,0,0,0,0,0],
[43,466,184,0,0,0,0,0,0],
[121,466,0,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[11,184,415,0,0,0,0,0,0],
[122,0,415,0,0,0,0,0,0],
[18,0,0,0,0,0,0,0,0],
[24,184,369,0,0,0,0,0,0],
[122,0,369,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[12,184,554,0,0,0,0,0,0],
[161,164,554,0,0,0,0,0,0],
[135,0,554,0,0,0,0,0,0],
[46,164,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[23,164,554,0,0,0,0,0,0],
[122,0,554,0,0,0,0,0,0],
[43,164,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[12,164,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[46,164,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[27,164,830,0,0,0,0,0,0],
[122,0,830,0,0,0,0,0,0],
[24,164,830,0,0,0,0,0,0],
[150,164,0,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[19,155,987,0,0,0,0,0,0],
[149,0,987,0,0,0,0,0,0],
[24,155,987,0,0,0,0,0,0],
[123,0,987,0,0,0,0,0,0],
[41,155,987,0,0,0,0,0,0],
[121,0,987,0,0,0,0,0,0],
[40,155,932,0,0,0,0,0,0],
[120,0,932,0,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[11,155,932,0,0,0,0,0,0],
[130,0,932,0,0,0,0,0,0],
[40,155,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[40,155,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[24,155,932,0,0,0,0,0,0],
[162,0,932,146,0,0,0,0,0],
[139,0,932,0,0,0,0,0,0],
[42,146,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[29,146,932,0,0,0,0,0,0],
[120,0,932,0,0,0,0,0,0],
[41,146,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[42,1108,932,0,0,0,0,0,0],
[2,1108,0,146,0,0,0,0,0],
[119,1108,0,0,0,0,0,0,0],
[39,1108,146,0,0,0,0,0,0],
[123,1108,0,0,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[31,146,987,0,0,0,0,0,0],
[123,0,987,0,0,0,0,0,0],
[28,146,987,0,0,0,0,0,0],
[144,146,0,0,0,0,0,0,0],
[18,0,0,0,0,0,0,0,0],
[11,138,932,0,0,0,0,0,0],
[151,0,932,0,0,0,0,0,0],
[14,0,0,0,0,0,0,0,0],
[15,138,987,0,0,0,0,0,0],
[123,0,987,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[30,138,932,0,0,0,0,0,0],
[122,0,932,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,138,739,0,0,0,0,0,0],
[123,0,739,0,0,0,0,0,0],
[40,138,739,0,0,0,0,0,0],
[122,0,739,0,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[11,138,0,0,0,0,0,0,0],
[1,138,554,0,0,0,0,0,0],
[121,0,554,0,0,0,0,0,0],
[39,138,554,0,0,0,0,0,0],
[124,0,554,0,0,0,0,0,0],
[27,138,554,0,0,0,0,0,0],
[162,0,554,130,0,0,0,0,0],
[135,0,554,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[12,130,830,0,0,0,0,0,0],
[123,0,830,0,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[13,130,739,0,0,0,0,0,0],
[121,0,739,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[29,130,698,0,0,0,0,0,0],
[150,130,0,0,0,0,0,0,0],
[12,138,0,0,0,0,0,0,0],
[1,138,622,0,0,0,0,0,0],
[120,0,622,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[14,138,698,0,0,0,0,0,0],
[120,0,698,0,0,0,0,0,0],
[41,138,698,0,0,0,0,0,0],
[122,0,698,0,0,0,0,0,0],
[29,138,698,0,0,0,0,0,0],
[162,0,0,0,0,0,0,0,0],
[18,146,739,0,0,0,0,0,0],
[201,0,0,0,0,0,0,0,0],
[297,164,739,0,0,0,0,0,0],
[477,0,739,0,0,0,0,0,0],
[2,0,0,0,0,0,0,0,0],
[10,184,739,0,0,0,0,0,0],
[302,0,0,0,0,0,0,0,0],
[11,92,0,0,0,0,0,0,0],
[141,0,0,0,0,0,0,0,0],
[41,92,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[22,92,0,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[48,92,0,0,0,0,0,0,0],
[120,0,0,0,0,0,0,0,0],
[41,92,0,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[42,92,0,0,0,0,0,0,0],
[121,0,0,0,0,0,0,0,0],
[42,92,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[29,92,0,0,0,0,0,0,0],
[164,0,0,0,0,0,0,0,0],
[11,123,440,0,0,0,0,0,0],
[1,123,440,739,0,0,0,0,0],
[150,0,0,0,0,0,0,0,0],
[22,123,440,739,0,0,0,0,0],
[123,123,440,0,0,0,0,0,0],
[40,0,0,0,0,0,0,0,0],
[332,493,164,830,0,0,0,0,0],
[122,493,0,830,0,0,0,0,0],
[23,0,0,0,0,0,0,0,0],
[15,164,493,830,0,0,0,0,0],
[136,164,0,0,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[151,110,659,440,0,0,0,0,0],
[294,0,659,440,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[30,110,659,0,0,0,0,0,0],
[121,0,659,0,0,0,0,0,0],
[29,110,659,0,0,0,0,0,0],
[121,0,659,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[12,110,554,0,0,0,0,0,0],
[123,0,554,0,0,0,0,0,0],
[40,110,554,0,0,0,0,0,0],
[123,0,554,0,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[10,110,659,0,0,0,0,0,0],
[124,0,659,0,0,0,0,0,0],
[9,0,0,0,0,0,0,0,0],
[31,110,0,0,0,0,0,0,0],
[1,110,493,0,0,0,0,0,0],
[121,0,493,0,0,0,0,0,0],
[18,0,0,0,0,0,0,0,0],
[12,110,554,0,0,0,0,0,0],
[40,110,0,0,0,0,0,0,0],
[11,110,493,0,0,0,0,0,0],
[41,110,0,0,0,0,0,0,0],
[16,110,440,0,0,0,0,0,0],
[42,110,0,0,0,0,0,0,0],
[13,0,0,0,0,0,0,0,0],
[10,123,493,293,0,0,0,0,0],
[151,0,493,293,0,0,0,0,0],
[30,123,493,293,0,0,0,0,0],
[121,0,493,293,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[30,123,293,0,0,0,0,0,0],
[1,123,293,440,0,0,0,0,0],
[122,0,293,440,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[28,123,293,0,0,0,0,0,0],
[1,123,293,493,0,0,0,0,0],
[121,0,293,493,0,0,0,0,0],
[28,0,0,0,0,0,0,0,0],
[14,123,0,0,0,0,0,0,0],
[120,0,0,0,0,0,0,0,0],
[40,123,293,440,0,0,0,0,0],
[123,0,293,440,0,0,0,0,0],
[17,0,0,0,0,0,0,0,0],
[23,123,0,0,0,0,0,0,0],
[122,0,0,0,0,0,0,0,0],
[29,123,349,554,0,0,0,0,0],
[163,138,349,554,0,0,0,0,0],
[133,0,349,554,0,0,0,0,0],
[40,138,349,554,0,0,0,0,0],
[130,0,349,554,0,0,0,0,0],
[21,138,349,554,0,0,0,0,0],
[124,0,349,554,0,0,0,0,0],
[38,138,349,554,0,0,0,0,0],
[123,0,349,554,0,0,0,0,0],
[42,138,349,554,0,0,0,0,0],
[119,0,349,554,0,0,0,0,0],
[42,138,349,554,0,0,0,0,0],
[128,0,349,554,0,0,0,0,0],
[41,138,349,554,0,0,0,0,0],
[122,0,349,554,0,0,0,0,0],
[22,138,349,554,0,0,0,0,0],
[164,138,0,554,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[16,123,739,587,0,0,0,0,0],
[146,0,0,0,0,0,0,0,0],
[27,123,587,739,0,0,0,0,0],
[123,123,587,0,0,0,0,0,0],
[40,0,0,0,0,0,0,0,0],
[323,164,830,659,0,0,0,0,0],
[124,0,830,659,0,0,0,0,0],
[29,0,0,0,0,0,0,0,0],
[9,164,659,830,0,0,0,0,0],
[142,164,0,0,0,0,0,0,0],
[26,0,0,0,0,0,0,0,0],
[146,554,880,110,0,0,0,0,0],
[302,554,880,0,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[31,554,110,659,0,0,0,0,0],
[121,554,0,659,0,0,0,0,0],
[30,554,110,659,0,0,0,0,0],
[120,554,0,659,0,0,0,0,0],
[12,0,0,0,0,0,0,0,0],
[28,659,110,554,0,0,0,0,0],
[122,659,0,554,0,0,0,0,0],
[41,659,110,554,0,0,0,0,0],
[120,659,0,554,0,0,0,0,0],
[29,659,0,0,0,0,0,0,0],
[1,0,0,0,0,0,0,0,0],
[11,110,554,659,0,0,0,0,0],
[122,0,554,659,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[29,880,110,0,0,0,0,0,0],
[1,880,110,659,0,0,0,0,0],
[121,880,0,659,0,0,0,0,0],
[14,0,0,0,0,0,0,0,0],
[16,110,739,987,0,0,0,0,0],
[162,0,739,987,0,0,0,0,0],
[11,123,739,987,0,0,0,0,0],
[151,0,739,987,0,0,0,0,0],
[29,123,739,987,0,0,0,0,0],
[123,0,739,987,0,0,0,0,0],
[42,123,739,987,0,0,0,0,0],
[121,0,739,987,0,0,0,0,0],
[39,123,739,987,0,0,0,0,0],
[123,0,739,987,0,0,0,0,0],
[39,123,739,987,0,0,0,0,0],
[124,0,739,987,0,0,0,0,0],
[39,123,739,987,0,0,0,0,0],
[123,0,739,987,0,0,0,0,0],
[30,0,0,0,0,0,0,0,0],
[10,123,739,880,0,0,0,0,0],
[122,0,739,880,0,0,0,0,0],
[11,0,0,0,0,0,0,0,0],
[19,123,698,1108,0,0,0,0,0],
[162,138,698,1108,0,0,0,0,0],
[132,0,698,1108,0,0,0,0,0],
[42,138,698,1108,0,0,0,0,0],
[121,0,698,1108,0,0,0,0,0],
[30,138,698,1108,0,0,0,0,0],
[121,0,698,1108,0,0,0,0,0],
[41,138,698,1108,0,0,0,0,0],
[123,0,698,1108,0,0,0,0,0],
[39,138,698,1108,0,0,0,0,0],
[123,0,698,1108,0,0,0,0,0],
[27,0,0,0,0,0,0,0,0],
[13,138,698,1108,0,0,0,0,0],
[122,0,698,1108,0,0,0,0,0],
[17,0,0,0,0,0,0,0,0],
[22,138,1108,0,0,0,0,0,0],
[1,138,1108,698,0,0,0,0,0],
[123,0,1108,698,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0],
[12,138,739,1108,0,0,0,0,0],
[161,0,739,1108,0,0,0,0,0],
[14,146,739,1108,0,0,0,0,0],
[150,0,739,1108,0,0,0,0,0],
[17,0,0,1108,0,0,0,0,0],
[11,146,369,1108,0,0,0,0,0],
[123,0,369,1108,0,0,0,0,0],
[11,0,0,1108,0,0,0,0,0],
[29,146,554,1108,0,0,0,0,0],
[121,0,554,1108,0,0,0,0,0],
[13,0,0,1108,0,0,0,0,0],
[29,146,739,1108,0,0,0,0,0],
[122,0,739,1108,0,0,0,0,0],
[28,0,0,1108,0,0,0,0,0],
[14,146,830,1108,0,0,0,0,0],
[121,0,830,1108,0,0,0,0,0],
[30,0,0,1108,0,0,0,0,0],
[10,146,554,1108,0,0,0,0,0],
[122,0,554,1108,0,0,0,0,0],
[19,0,0,1108,0,0,0,0,0],
[23,146,739,1108,0,0,0,0,0],
[122,0,739,1108,0,0,0,0,0],
[16,0,0,1108,0,0,0,0,0],
[13,146,830,1108,0,0,0,0,0],
[139,0,830,1108,0,0,0,0,0],
[10,0,0,1108,0,0,0,0,0],
[14,987,146,1108,0,0,0,0,0],
[150,0,146,1108,0,0,0,0,0],
[29,554,146,1108,0,0,0,0,0],
[120,554,0,1108,0,0,0,0,0],
[14,0,0,1108,0,0,0,0,0],
[10,987,0,1108,0,0,0,0,0],
[140,0,0,1108,0,0,0,0,0],
[22,932,0,1108,0,0,0,0,0],
[152,0,0,1108,0,0,0,0,0],
[16,293,146,1108,554,0,0,0,0],
[145,293,146,1108,0,0,0,0,0],
[17,293,146,1108,932,0,0,0,0],
[134,0,0,1108,0,0,0,0,0],
[30,164,329,1108,830,0,0,0,0],
[132,164,329,1108,0,0,0,0,0],
[13,164,329,1108,739,0,0,0,0],
[151,0,0,1108,0,0,0,0,0],
[16,0,0,0,0,0,0,0,0]
]

_thread.start_new_thread("synth", synthThread, ())
while 1:
	for step in song:
		time.sleep_ms(int(step[0]//1.2))
		for i in range(channels):
			freq = step[1+i]//2
			if freq > 0:
				#notes[i][0] = freq
				if (freq != notes[i][0]) or (notes[i][1] == 0):
					on(i, freq, 100, 20, 50, 100)
				elif notes[i][0] > 0:
					off(i, 80)