<s> """<STR_LIT>""" <EOL> from __future__ import print_function , division <EOL> import sys <EOL> import os . path <EOL> def switch ( n , m ) : <EOL> """<STR_LIT>""" <EOL> out = [ ] <EOL> name_letters = { <NUM_LIT:1> : "<STR_LIT:S>" , <NUM_LIT:2> : "<STR_LIT:D>" } <EOL> name_n = name_letters [ n ] if n in name_letters else str ( n ) <EOL> name_m = name_letters [ m ] if m in name_letters else str ( m ) <EOL> n_pins_right = n * m + n - <NUM_LIT:1> <EOL> if n_pins_right % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> n_pins_right += <NUM_LIT:1> <EOL> height = <NUM_LIT:100> * ( n_pins_right - <NUM_LIT:1> ) <EOL> hheight = height // <NUM_LIT:2> <EOL> refheight = hheight + <NUM_LIT:100> <EOL> if m == <NUM_LIT:1> : <EOL> refheight += <NUM_LIT:50> <EOL> valheight = - ( hheight + <NUM_LIT:100> ) <EOL> if n % <NUM_LIT:2> == <NUM_LIT:1> and m % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> valheight += <NUM_LIT:100> <EOL> name = "<STR_LIT>" . format ( name_n , name_m ) <EOL> out . append ( "<STR_LIT>" . format ( name ) ) <EOL> out . append ( '<STR_LIT>' . format ( name ) ) <EOL> out . append ( '<STR_LIT>' . format ( refheight ) ) <EOL> out . append ( '<STR_LIT>' . format ( name , valheight ) ) <EOL> out . append ( '<STR_LIT>' ) <EOL> out . append ( '<STR_LIT>' ) <EOL> out . append ( '<STR_LIT>' ) <EOL> pole_top = hheight <EOL> for pole in range ( n ) : <EOL> pole_num = pole * ( m + <NUM_LIT:1> ) + <NUM_LIT:2> <EOL> pole_y = pole_top - ( <NUM_LIT:100> * ( m - <NUM_LIT:1> ) ) // <NUM_LIT:2> <EOL> if m % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> pole_y -= <NUM_LIT:50> <EOL> out . append ( '<STR_LIT>' <EOL> . format ( pole_num , pole_y ) ) <EOL> out . append ( '<STR_LIT>' . format ( pole_y ) ) <EOL> out . append ( '<STR_LIT>' <EOL> . format ( pole_y + <NUM_LIT:10> , pole_y + <NUM_LIT> ) ) <EOL> for throw in range ( m ) : <EOL> throw_num = pole_num + throw - <NUM_LIT:1> <EOL> throw_y = pole_top - <NUM_LIT:100> * throw <EOL> if throw > <NUM_LIT:0> : <EOL> throw_num += <NUM_LIT:1> <EOL> out . append ( '<STR_LIT>' <EOL> . format ( throw_num , throw_y ) ) <EOL> out . append ( '<STR_LIT>' . format ( throw_y ) ) <EOL> pole_top -= <NUM_LIT:100> * ( m + <NUM_LIT:1> ) <EOL> if n > <NUM_LIT:1> : <EOL> pole_y = hheight - ( <NUM_LIT:100> * ( m - <NUM_LIT:1> ) ) // <NUM_LIT:2> + <NUM_LIT:50> <EOL> if m % <NUM_LIT:2> == <NUM_LIT:0> : <EOL> pole_y -= <NUM_LIT:50> <EOL> for _ in range ( <NUM_LIT:5> * ( m + <NUM_LIT:1> ) * ( n - <NUM_LIT:1> ) ) : <EOL> out . append ( '<STR_LIT>' <EOL> . format ( pole_y , pole_y - <NUM_LIT:5> ) ) <EOL> pole_y -= <NUM_LIT:20> <EOL> out . append ( '<STR_LIT>' ) <EOL> return out <EOL> def main ( libpath , verify = False ) : <EOL> out = [ ] <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> out . append ( "<STR_LIT>" ) <EOL> for n in ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) : <EOL> for m in ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) : <EOL> out += switch ( n , m ) <EOL> out . append ( '<STR_LIT>' ) <EOL> lib = "<STR_LIT:\n>" . join ( out ) <EOL> if os . path . isfile ( libpath ) : <EOL> with open ( libpath ) as f : <EOL> oldlib = f . read ( ) <EOL> if lib == oldlib : <EOL> return True <EOL> if verify : <EOL> return False <EOL> else : <EOL> with open ( libpath , "<STR_LIT:w>" ) as f : <EOL> f . write ( lib ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if len ( sys . argv ) == <NUM_LIT:2> : <EOL> main ( sys . argv [ <NUM_LIT:1> ] ) <EOL> elif len ( sys . argv ) == <NUM_LIT:3> and sys . argv [ <NUM_LIT:2> ] == "<STR_LIT>" : <EOL> if main ( sys . argv [ <NUM_LIT:1> ] , verify = True ) : <EOL> print ( "<STR_LIT>" ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> print ( "<STR_LIT>" , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> else : <EOL> print ( "<STR_LIT>" . format ( sys . argv [ <NUM_LIT:0> ] ) ) <EOL> sys . exit ( <NUM_LIT:1> ) </s>
