code
stringlengths
2
1.05M
repo_name
stringlengths
5
104
path
stringlengths
4
251
language
stringclasses
1 value
license
stringclasses
15 values
size
int32
2
1.05M
from unicurses import * class Console: def __init__(self): stdscr = initscr() noecho() cbreak() curs_set(False) start_color() use_default_colors() init_pair( 0, COLOR_WHITE, COLOR_BLACK) init_pair( 1, COLOR_RED, COLOR_BLACK) init_pair( 2, COLOR_YELLOW, COLOR_BLACK) init_pair( 3, COLOR_GREEN, COLOR_BLACK) init_pair( 4, COLOR_CYAN, COLOR_BLACK) init_pair( 5, COLOR_BLUE, COLOR_BLACK) init_pair( 6, COLOR_MAGENTA, COLOR_BLACK) init_pair( 7, COLOR_WHITE, COLOR_BLACK) init_pair( 8, COLOR_RED, COLOR_BLACK) init_pair( 9, COLOR_YELLOW, COLOR_BLACK) init_pair(10, COLOR_GREEN, COLOR_BLACK) init_pair(11, COLOR_CYAN, COLOR_BLACK) init_pair(12, COLOR_BLUE, COLOR_BLACK) init_pair(13, COLOR_MAGENTA, COLOR_BLACK) def close(self): nocbreak() echo() endwin() def clear(self): refresh() clear() def add_char(self, x, y, char): move(y, x) addstr(char) def add_str(self, x, y, char): move(y, x) addstr(char) def setcolor(self, n): attron(color_pair(n) ) def unsetcolor(self, n): attroff(color_pair(n) ) def setbold(self): attron(A_BOLD) def unsetbold(self): attroff(A_BOLD)
zb89/pyrogue
console.py
Python
unlicense
1,242
#!/usr/bin/env python import sys import os import Pipeline.settings.BiotoolsSettings as BiotoolsSettings import DPyGetOpt from Pipeline.core.PipelineTemplate import PipelineTemplate import Pipeline.core.PipelineUtil as PipelineUtil from Pipeline.core.PipelineError import PipelineError from Pipeline.core.PipelineClusterJob import PipelineClusterJob #http://ipython.org/ipython-doc/rel-0.10.2/html/api/generated/IPython.DPyGetOpt.html #http://www.artima.com/weblogs/viewpost.jsp?thread=4829 class Usage(Exception): def __init__(self, msg=None, err=True): #msg is an error message to post before the usage info usage="Usage: %s (options)\n" % sys.argv[0] usage +="Options:\n" usage +="\t--template |-T=string : set template name\n" usage +="\t--clearsuffixes|-C : set flag to force suffix reset post-module\n" usage +="\t--cross |-c : set flag to inform SJM generator that this is a crossjob\n" usage +="\t (depends on pairs of input files from different samples)\n" usage +="\t--variable |-V=string : add pipeline variable to be used during variable replacement (multi-use)\n" usage +="\t--suffix |-S=string : set suffix to be used post-module\n" usage +="\t--subjob |-s=string : add a subjob to template\n" usage +="for help use --help\n" if msg is not None: self.msg = msg.strip() +"\n" + usage else: self.msg = usage self.exit_code=None if err == True: self.exit_code = 2 else: self.exit_code = 0 def main(argv=None): if argv is None: argv = sys.argv try: #try to parse option arguments try: opts=[] opts.append("variable|V=s@") opts.append("clearsuffixes|C") opts.append("suffix|S=s") opts.append("template|T=s") opts.append("subjob|J=s@") opts.append("cross|c") opts.append("help|h") opt_parser=DPyGetOpt.DPyGetOpt() opt_parser.setIgnoreCase(False) opt_parser.setAllowAbbreviations(False) opt_parser.setPosixCompliance(True) opt_parser.parseConfiguration(opts) opt_parser.processArguments(sys.argv) pipeline_vars=opt_parser.valueForOption("variable") pipeline_clearsuffixes=bool(opt_parser.valueForOption("clearsuffixes")) pipeline_crossjob=bool(opt_parser.valueForOption("cross")) pipeline_suffix=opt_parser.valueForOption("suffix") pipeline_templateName=opt_parser.valueForOption("template") pipeline_subjobs=opt_parser.valueForOption("subjob") help_flag=bool(opt_parser.valueForOption("help")) if help_flag: raise Usage(err=False) argv=opt_parser.freeValues print("defined vars:") if pipeline_vars is None: print("\t(No vars defined)") else: for var in pipeline_vars: print("\t%s" % var) if pipeline_subjobs is None: raise Usage("Must define at least one subjob",err=True) else: print("defined subjob commands:") for job in pipeline_subjobs: print("\t%s" % job) print("suffixes cleared after template:") print("\t%s" % pipeline_clearsuffixes) print("Is a CrossJob:") print("\t%s" % pipeline_crossjob) if pipeline_suffix is None: raise Usage("Must Specify a template suffix",err=True) print("Template Suffix:") print("\t%s" % pipeline_suffix) if pipeline_templateName is None: raise Usage("Must Specify a template name",err=True) print("Template Name:") print("\t%s" % pipeline_templateName) #TODO method stub temp=PipelineTemplate() temp.suffix=pipeline_suffix; temp.clearsuffixes=pipeline_clearsuffixes; temp.isCrossJob=pipeline_crossjob; temp.name=pipeline_templateName; parseVars(temp,pipeline_vars); parseSubJobs(temp,pipeline_subjobs); #temp.ClusterJobs=[]; #temp.vars={}; #temp.var_keys=[]; temp.writeTemplate() except DPyGetOpt.ArgumentError as DPyGetOptArgErr: raise Usage("DPyGetOptArgErr: " + DPyGetOptArgErr.__str__()) except DPyGetOpt.SpecificationError as DPyGetOptSpecErr: raise Usage("DPyGetOptSpecErr: " + DPyGetOptSpecErr.__str__()) except DPyGetOpt.TerminationError as DPyGetOptTermErr: raise Usage("DPyGetOptTermErr: " + DPyGetOptTermErr.__str__()) except DPyGetOpt.Error as DPyGetOptErr: raise Usage("DPyGetOptErr: " + DPyGetOptErr.__str__()) except PipelineError as pipe_err: sys.stderr.write (pipe_err.msg); return -1; print("PROGRAM EXECUTION REACHED END OF MAIN") return 0; except Usage as err: sys.stderr.write(err.msg) return err.exit_code def parseVars(template,Vars): if template is None: raise PipelineError("[PipelineTemplateGenerator.parseVars] template object is None"); if Vars is not None: #print("Vars: %s" % Vars) for Var in Vars: eqsplit=Var.split("=") if (len(eqsplit)!=2): raise PipelineError("[PipelineTemplateGenerator.parseVars] Incorrect syntax for var definition: "+ Var); if eqsplit[0] in template.vars: raise PipelineError("[PipelineTemplateGenerator.parseVars] defined same var twice: "+ eqsplit[0]); template.vars[eqsplit[0]]=eqsplit[1]; template.var_keys.append(eqsplit[0]); # print("var keys: %s" % template.var_keys) # print("vars: %s" % template.vars) def parseSubJobs(template,subjobs): if template is None: raise PipelineError("[PipelineTemplateGenerator.parseVars] template object is None"); if subjobs is None: raise PipelineError("[PipelineTemplateGenerator.parseVars] No subjobs provided"); for subjobopt in subjobs: clusterjob=template.getNewClusterJob(); parseSubJob(subjobopt,clusterjob) def parseSubJob(subjobopt,clusterjob): #subjobvars={}; commasplit=subjobopt.split(","); for commaItem in commasplit: eqsplit=commaItem.split("=") # print("split on equal sign: %s" % eqsplit) if (len(eqsplit)!=2): raise PipelineError("[PipelineTemplateGenerator.parseVars] invalid argument syntax! should have 2 elements separated by '=', have: %d" % len(eqsplit)); attrib_name=str(eqsplit[0].strip()) attrib_val=str(eqsplit[1]) # print("attrib_name:") # print(attrib_name) # print("attrib_val:") # print(attrib_val) if attrib_name == "order_after": # print("found order_after!!!"); # print("parsing: " + attrib_val); if ':' in attrib_val: arr=attrib_val.split(":"); # print("split order after: " + arr); clusterjob.order_after.append(arr); else: # print("order after: " + attrib_val); clusterjob.order_after.append(attrib_val); elif attrib_name == "cmd": # print("found cmd!!!"); # print("split cmd: " + attrib_val); clusterjob.cmd.append(attrib_val); else: # print("found " + attrib_name + " !!!") setattr(clusterjob, attrib_name, attrib_val) if clusterjob.module is None: clusterjob.module=BiotoolsSettings.getValue("MODULEFILE") if clusterjob.directory is None: clusterjob.directory=BiotoolsSettings.getValue("CURDIR") if clusterjob.queue is None: clusterjob.queue=BiotoolsSettings.getValue("JOBQUEUE") if __name__ == "__main__": sys.exit(main())
kotoroshinoto/Cluster_SimpleJob_Generator
pybin/Pipeline/commands/PipelineTemplateGenerator.py
Python
unlicense
8,154
""" uhbd_interface.py: Functions/data necessary to perform a UHBD calculation on a single pdb file. Core of the batch run suite. Required files: pkaS-doinp.inp (in ./inputs/) pkaS.dat (in ./inputs/) Version Notes: 0.4.1: Fixed bug: if multiple jobs running, sometimes two jobs would try to use same temporary directory, causing crash. Fixed by appending a random integer (1-1000) to temporary directory name. 0.4.2: Changed temporary directory structure. Temporary folders now created within 'scratch' directory inside the script directory. 0.4.3: 060310 Changed default grid sizes. Used to have program define first two grids, not have it define only the first grid. The last three grids are fixed. Added error checking for bin_path variable Fixed bug: if / not specified at end of bin_path, script crashed. (i.e. if bin_path were /home/harms/bin, the script would try to run: /home/harms/binmybin instead of /home/harms/bin/mybin 0.4.4: 060313 Fixed bug. For very small proteins, grid size would be too small, resulting in zero potentials. Set cutoff so that minimum final grid is 1.5 A * 65. 0.5.0: 060404 COMPATABILITY NOTE! THIS VERSION SHOULD ***ONLY*** BE USED WITH THE LAB-CERTIFIED UHBD COMPILES! THE LATEST COMPILE (060404) CREATES SLIGHTLY DIFFERENT OUTPUTS THAN THE COMPILE THIS SCRIPT WAS CREATED TO INTERACT WITH. runPrepares WILL DEAL CORRECTLY ONLY WITH THE NEW COMPILE! Altered runPrepares function. The new uhbd compile does not add N-terminal groups incorrectly as the old one did. Commented out portion of function that removes N-terminus. Hokiness fix. Changed from some_path = x + os.sep + y to os.path.join(x,y) Moved specification of binary path from a variable in uhbd.py to a system environment variable (UHBD). 0.6.0: 060519 Restructured call structure. New main file to look at for interface changes is pyUHBD.py. Changed name of this file to UhbdInterface.py """ __author__ = "Michael J. Harms" __version__ = "0.6.0" __date__ = "060519" #*****************************************************************************# # INITALIZE MODULE # #*****************************************************************************# # import modules import os, shutil, time, sys, math, random # Global variables global tmp_dir # Take bin_path from environment variable UHBD and make it points to a valid # directory. try: bin_path = os.environ['UHBD'] try: os.listdir(bin_path) except OSError: print "Invalid binary path specified in UHBD environment variable:" print "\tbin_path = %s" % bin_path sys.exit() except KeyError: print "Environment variable UHBD not defined!" sys.exit() # set up sundry strings to make code easier to read prep = os.path.join(bin_path,'prepares') uhbd = os.path.join(bin_path,'uhbd') getgrids = os.path.join(bin_path,'getgrids') doinps = os.path.join(bin_path,'doinps') getpots = os.path.join(bin_path,'getpots') hybrid = os.path.join(bin_path,'hybrid') # define location of script (for temporary folder creation) script_path = __file__ script_path = os.path.split(script_path)[0] #*****************************************************************************# # HOUSEKEEPING FUNCTIONS # #*****************************************************************************# def createTemporaryDirectory(): """Create temporary directory and chdir into it.""" global tmp_dir tmp_dir = os.path.join(script_path,'scratch',"tmp%i_%i" % \ (time.time(),random.choice(range(1000)))) os.mkdir(tmp_dir) os.chdir(tmp_dir) def runCleanup(): """A function to clean out temporary directory after UHBD run.""" os.chdir(script_path) for file in os.listdir(tmp_dir): os.remove(os.path.join(tmp_dir,file)) os.rmdir(tmp_dir) def copyFinalOutput(output_directory): """Copy output files from temporary directory to output_directory.""" shutil.copy('pkaS-potentials',output_directory) shutil.copy('hybrid.out',output_directory) shutil.copy('pkaS-sitesinpr.pdb',output_directory) shutil.copy('pkaS-doinp.inp',output_directory) shutil.copy('titraa.pdb',output_directory) #*****************************************************************************# # UHBD INTERFACE FUNCTIONS # #*****************************************************************************# def runPrepares(): """ Run prepares in UHBD package, fixing problems with input files it generates. """ # RUN PREPARES os.spawnl(os.P_WAIT,prep,'') # FIX SITESINPR (remove second line (i.e. N terminus)) f = open('sitesinpr.pdb','r') sitesinpr = f.readlines() f.close() """ See **** below. sitesinpr.pop(1) """ g = open('sitesinpr.pdb','w') g.writelines(sitesinpr) g.close() # FIX TITRAA (removes N and C-terminal groups) f = open('titraa.pdb','r') titraa = f.readlines() f.close() # remove last line (C-terminal oxygen) titraa.pop(-1) """" **** CHANGE! **** New compile of UHBD does not have bug at N-terminus where it keeps all N-terminal groups. This was my attempt to fix the N-terminal problem for previous compiles. Since this is no longer a problem, I'lve commented my fix out. #Removes titrating N-terminus j = 0 for line in titraa: i = line.split() i = int(i[1]) if i < j: for k in range(j): titraa.pop(0) break j += 1 """ g = open('titraa.pdb','w') g.writelines(titraa) g.close() def runUHBD(inputfile,outputfile): """Runs UHBD from an inputfile, putting standard out to outputfile.""" f = open(inputfile,'r') inp = f.read() f.close() cin, cout = os.popen2(uhbd) cin.write(inp) cin.close() out = cout.read() cout.close() g = open(outputfile,'w') g.write(out) g.close() def setupInp(pdb_name,ionic_strength,dielectric,css_cut=3.5): """ Function to set up pkaS-doinp.inp for a UHBD run. Finds the starting and stopping residues, histidines, titratable cysteines, and grid sizes. Arguments: pdb_name (string) name of pdb file to be processed ionic_strength (float) ionic_strength for calculation dielectric (float) protein dielectric constant css_cut (float) cutoff SG-SG distance for disulfide bond assignment (default = 3.5 angstroms). """ # Copy required files into temporary directory createTemporaryDirectory() shutil.copy(pdb_name,'pkaSH.pdb') shutil.copy(os.path.join(script_path,'inputs','pkaS-doinp.inp'), 'pkaS-doinp.inp') shutil.copy(os.path.join(script_path,'inputs','pkaS.dat'), 'pkaS.dat') # *****pdb file info ***** # grab first and last residue indicies from pdb file f = open('pkaSH.pdb','r') pdb = f.readlines() f.close() # Find the first and last atom in the pdb file for line in pdb: if line[0:4] == 'ATOM': start_index = int(line[22:26]) break end_index = int(pdb[-2][22:26]) # Grab HIS and CYS from pdb file hisnum = [] cysnum = [] cyscoord = [] for line in pdb: if line[17:20] == 'HIS': resi = int(line[22:26]) if (resi in hisnum) == 0: hisnum.append(resi) if line[17:20] == 'CSS' and line[12:14] == 'SG': cysnum.append(int(line[22:26])) cyscoord.append([float(line[31:38]),float(line[39:46]), \ float(line[47:54])]) number_his = len(hisnum) hisstring = number_his*"2 " # FIND DISULFIDE BONDS (look for SG - SG distances < css_cut) css_cut_squared = css_cut**2 cys_rem = [] for i in range(len(cysnum)): for j in range(i+1,len(cysnum)): sep = 0 for k in range(3): sep += (cyscoord[i][k] - cyscoord[j][k])**2 if sep < css_cut_squared: cys_rem.append(cysnum[i]) cys_rem.append(cysnum[j]) cysnum = [i for i in cysnum if (i in cys_rem) == 0] number_cys = len(cysnum) cysstring = '' for cys in cysnum: cysstring = 3*"%s" % (cysstring,cys,' ') # CALCULATE GRID SIZES # 1) Find maximum dimension CA = [line for line in pdb if line[0:4] == "ATOM" and line[12:15] == "CA "] coord = [] for atom in CA: coord.append([float(atom[30+8*i:37+8*i]) for i in range(3)]) size = len(coord) max_dim = 0.0 for i in range(size): for j in range(i+1,size): dist = 0.0 for k in range(3): dist += (coord[i][k] - coord[j][k])**2 if dist > max_dim: max_dim = dist # 2) Find grid sizes proper globalmax = 2*math.sqrt(max_dim) interval = globalmax/65 if interval < 1.5: interval = 1.5 # OPEN pkaS-doinp FOR EDITING f = open('pkaS-doinp.inp','r') inp = f.readlines() f.close() inp[7] = "%s\n" % start_index inp[9] = "%i\n" % (end_index + 2) inp[11] = "%s\n" % number_his inp[12] = "%s\n" % hisstring inp[15] = "%3.1F%s\n" % (interval,' 65 65 65') inp[24] = "78.5 %.1F\n" % dielectric inp[30] = "%s\n" % number_cys inp[31] = "%s\n" % cysstring if ionic_strength >= 0: inp[26] = "%.1F 2.0\n" % ionic_strength if number_his == 0: inp[12] = '' if number_cys == 0: inp[31] = '' # write input file g = open('pkaS-doinp.inp','w') g.writelines(inp) g.close() #*****************************************************************************# # MAIN # #*****************************************************************************# def main(filename,pH_start,pH_stop,pH_interval,ionic_strength,dielectric): """Peform full UHBD calculation (pH titration) on filename.""" # SETUP UHBD CALCULATIONS setupInp(filename,ionic_strength,dielectric) print 'Prepares' runPrepares() print 'uhbdini' runUHBD('pkaS-uhbdini.inp','pkaS-uhbdini.out') print 'Getgrids' os.spawnl(os.P_WAIT,getgrids,'') # RUN STOPNOW LOOP print 'Running stopnow loop.' while os.path.isfile('stopnow') == False: os.spawnl(os.P_WAIT,doinps,'') runUHBD('uhbdpr.inp','uhbdpr.out') runUHBD('uhbdaa.inp','uhbdaa.out') os.spawnl(os.P_WAIT,getpots,'') # RUN HYBRID shutil.copy('potentials','pkaS-potentials') shutil.copy('sitesinpr.pdb','pkaS-sitesinpr.pdb') hybrid_run = os.popen(hybrid,'w') hybrid_run.write("%s\n%s\n%s\n" % (pH_start,pH_stop,pH_interval)) hybrid_run.close()
harmsm/uhbd
previous_releases/0.6.0/UhbdInterface.py
Python
unlicense
11,201
from rk.ssh.tunnel import *
korniichuk/rk
rk/ssh/__init__.py
Python
unlicense
28
import time import json import os # Returns the list of reminders as dict. # @return reminders - Python Dictionary def get_reminders(): file = "{}/reminders.json".format(os.path.dirname(os.path.realpath(__file__))) with open(file, "r") as data_file: reminders = json.load(data_file) return reminders # Creates a reminder and writes it to file. def set_reminder(nick, msg, date, time): # Checks if user has existing reminders; if so: append to user reminders. reminders = get_reminders() reminder = {} if nick in reminders.keys(): reminders[nick].append([msg, date, time]) with open(file, "w+") as data_file: data_file.write(json.dumps(reminders, indent=4, sort_keys=True)) else: reminders[nick] = [[msg, date, time]] with open(file, "w+") as data_file: data_file.write(json.dumps(reminders, indent=4, sort_keys=True)) #print("After\n{}\n".format(reminders)) # Iterates over reminders and sends PM to users if time and date. def remind(nick): reminders = get_reminders() if reminders.get(nick): print(reminders.get(nick)) #set_reminder("hm","tannlege elns", "12.01.02","14:00") remind("svimanet")
svimanet/IRC-Bob
modules/reminders.py
Python
unlicense
1,220
#!/usr/bin/python # # Frontend for running support related commands on hyperic installations. # # Opens as an interactive shell if no parameters are passed, otherwise runs # the command and parameters that have been passed on the command line. # # Enter help to see available commands. # # # Adding a new command is done by just adding a do_<command>(self,line) method to the # SupportCmd class. The following will apply: # * line will contain a string with all the command parameters. # * The method's documentation becomes the command's help (Python documents methods by # using a """text....""" comment as the first line *inside* the method). # * If you want a more complicated help (e.g. dynamic), then just implement a help_<command>(self,line) # method which prints the help text. # # No need to reinvent the wheel - Use run_with_jython and run_java_jar functions in order to perform # the things that you need. # # Global variables can be accessed using gd.getGlobalVariable. import cmd import subprocess import os,sys import global_data as gd import hq_utils from architectures import * def run_with_jython(script_name,arg_str): run_jython = gd.getGlobalData(gd.RUN_JYTHON) s = "%s %s %s" % (run_jython,script_name,arg_str) subprocess.call(s,shell=True) def run_java_jar(jar_path,arg_str): java_executable = gd.getGlobalData(gd.JAVA_EXECUTABLE) s = "%s -jar %s %s" % (java_executable,jar_path,arg_str) subprocess.call(s,shell=True) class SupportCmd(cmd.Cmd): DELEGATED_HELP_COMMANDS = ['package'] def __init__(self,base_folder): self.base_folder = base_folder cmd.Cmd.__init__(self) def get_cmd_script_name(self,cmd_name): return os.path.join(self.base_folder,'support-%s.py' % cmd_name) def do_package(self,line): run_with_jython(self.get_cmd_script_name('package'),line) # Override the help command in order to delegate the help printing to the script # If it is the one implementing the command def do_help(self,arg): if arg in SupportCmd.DELEGATED_HELP_COMMANDS: run_with_jython(self.get_cmd_script_name(arg),'--help') else: cmd.Cmd.do_help(self,arg) def do_get_variables(self,line): """get_variables - Retrieves the values of all support-related variables""" for k in sorted(gd.globalData.keys()): print "%s: %s" % (k,gd.globalData[k]) def do_sigar(self,line): """Run a sigar command. See help for details""" if line.strip() != '': sigar_jar = gd.getGlobalData(gd.SIGAR_JAR) if not os.path.isfile(sigar_jar): if gd.getGlobalData(gd.INSTALLATION_TYPE) == hq_utils.DEV: print "Could not find sigar JAR file - Please build the project before using this command" else: print "Could not find sigar JAR file in. Expected location is %s" % sigar_jar return run_java_jar(sigar_jar,line) else: print "sigar command parameters are missing. Use 'sigar help' for details" def help_sigar(self): print "Run a sigar command\n" sigar_jar = gd.getGlobalData(gd.SIGAR_JAR) run_java_jar(sigar_jar,'help') def do_EOF(self,line): return True def do_quit(self,line): """quit - Quit the frontend""" return True def postloop(self): print def emptyline(self): pass detectArchitecture() # Find the path of the script scripts_path = os.path.split(os.path.abspath(sys.argv[0]))[0] # NOTE: Assumption is that script is in $HQ_HOME/support/scripts/ hq_utils.detectHQInformation(os.path.abspath(os.path.join(scripts_path,'..','..'))) s = SupportCmd(scripts_path) s.prompt = "hq>" try: if len(sys.argv) > 1: s.onecmd(" ".join(sys.argv[1:])) else: print "Hyperic HQ Support Frontend. Enter help to see available commands." print "HQ installation type is %s" % gd.getGlobalData(gd.INSTALLATION_TYPE) print "JRE folder %s" % os.path.abspath(gd.getGlobalData(gd.JRE)) print "Jython JAR location: %s" % os.path.abspath(gd.getGlobalData(gd.JYTHON_JAR_LOCATION)) s.cmdloop() except KeyboardInterrupt,e: pass
cc14514/hq6
dist/support/src/main/resources/scripts/support.py
Python
unlicense
4,294
import os # This function only READS the Commit info. # There is no point in loading any commit in memory. # What purpose can that serve? Nothing. (Prove this) def load(cls, name, path): try: with open(path, 'rb') as commit_info_file: commit_info_dict = pickle.load(commit_info_file.read()) return commit_info_dict except FileNotFoundError: print("Could not find commit-info here:\n`%s`" % path) sys.exit(1) # This object hold only some info about a SINGLE Commit class Commit: def __init__(self, parent, branch, message, repo): self.message = message self.hash = self.make_hash() # self.repo.dstore.get_commits_by_branch(branch) # make changes to tree # save # make chages to main tree? # exit def make_hash(self): return "yash uuid"
arrow-/pitstops
commit.py
Python
unlicense
862
""" Testing for enumerate_param, enumerate_params, and enumerate_keyed_param """ import unittest import mws # pylint: disable=invalid-name class TestParamsRaiseExceptions(unittest.TestCase): """ Simple test that asserts a ValueError is raised by an improper entry to `utils.enumerate_keyed_param`. """ def test_keyed_param_fails_without_dict(self): """ Should raise ValueError for values not being a dict. """ param = "something" values = ["this is not a dict like it should be!"] with self.assertRaises(ValueError): mws.utils.enumerate_keyed_param(param, values) def test_single_param_default(): """ Test each method type for their default empty dicts. """ # Single assert mws.utils.enumerate_param("something", []) == {} # Multi assert mws.utils.enumerate_params() == {} assert mws.utils.enumerate_params("antler") == {} # Keyed assert mws.utils.enumerate_keyed_param("acorn", []) == {} def test_single_param_not_dotted_list_values(): """ A param string with no dot at the end and a list of ints. List should be ingested in order. """ param = "SomethingOrOther" values = (123, 765, 3512, 756437, 3125) result = mws.utils.enumerate_param(param, values) assert result == { "SomethingOrOther.1": 123, "SomethingOrOther.2": 765, "SomethingOrOther.3": 3512, "SomethingOrOther.4": 756437, "SomethingOrOther.5": 3125, } def test_single_param_dotted_single_value(): """ A param string with a dot at the end and a single string value. Values that are not list, tuple, or set should coerce to a list and provide a single output. """ param = "FooBar." values = "eleven" result = mws.utils.enumerate_param(param, values) assert result == { "FooBar.1": "eleven", } def test_multi_params(): """ A series of params sent as a list of dicts to enumerate_params. Each param should generate a unique set of keys and values. Final result should be a flat dict. """ param1 = "Summat." values1 = ("colorful", "cheery", "turkey") param2 = "FooBaz.what" values2 = "singular" param3 = "hot_dog" values3 = ["something", "or", "other"] # We could test with values as a set, but we cannot be 100% of the order of the output, # and I don't feel it necessary to flesh this out enough to account for it. result = mws.utils.enumerate_params({ param1: values1, param2: values2, param3: values3, }) assert result == { "Summat.1": "colorful", "Summat.2": "cheery", "Summat.3": "turkey", "FooBaz.what.1": "singular", "hot_dog.1": "something", "hot_dog.2": "or", "hot_dog.3": "other", } def test_keyed_params(): """ Asserting the result through enumerate_keyed_param is as expected. """ # Example: # param = "InboundShipmentPlanRequestItems.member" # values = [ # {'SellerSKU': 'Football2415', # 'Quantity': 3}, # {'SellerSKU': 'TeeballBall3251', # 'Quantity': 5}, # ... # ] # Returns: # { # 'InboundShipmentPlanRequestItems.member.1.SellerSKU': 'Football2415', # 'InboundShipmentPlanRequestItems.member.1.Quantity': 3, # 'InboundShipmentPlanRequestItems.member.2.SellerSKU': 'TeeballBall3251', # 'InboundShipmentPlanRequestItems.member.2.Quantity': 5, # ... # } param = "AthingToKeyUp.member" item1 = { "thing": "stuff", "foo": "baz", } item2 = { "thing": 123, "foo": 908, "bar": "hello", } item3 = { "stuff": "foobarbazmatazz", "stuff2": "foobarbazmatazz5", } result = mws.utils.enumerate_keyed_param(param, [item1, item2, item3]) assert result == { "AthingToKeyUp.member.1.thing": "stuff", "AthingToKeyUp.member.1.foo": "baz", "AthingToKeyUp.member.2.thing": 123, "AthingToKeyUp.member.2.foo": 908, "AthingToKeyUp.member.2.bar": "hello", "AthingToKeyUp.member.3.stuff": "foobarbazmatazz", "AthingToKeyUp.member.3.stuff2": "foobarbazmatazz5", }
Bobspadger/python-amazon-mws
tests/test_param_methods.py
Python
unlicense
4,345
#!/usr/bin/python # -*- coding: utf-8 -*- ### # Copyright (2016-2019) Hewlett Packard Enterprise Development LP # # Licensed under the Apache License, Version 2.0 (the "License"); # You may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ### import pytest from mock import mock from hpe_test_utils import OneViewBaseFactsTest from oneview_module_loader import EthernetNetworkFactsModule ERROR_MSG = 'Fake message error' PARAMS_GET_ALL = dict( config='config.json', name=None ) PARAMS_GET_BY_NAME = dict( config='config.json', name="Test Ethernet Network", options=[] ) PARAMS_GET_BY_NAME_WITH_OPTIONS = dict( config='config.json', name="Test Ethernet Network", options=['associatedProfiles', 'associatedUplinkGroups'] ) PRESENT_ENETS = [{ "name": "Test Ethernet Network", "uri": "/rest/ethernet-networks/d34dcf5e-0d8e-441c-b00d-e1dd6a067188" }] ENET_ASSOCIATED_UPLINK_GROUP_URIS = [ "/rest/uplink-sets/c6bf9af9-48e7-4236-b08a-77684dc258a5", "/rest/uplink-sets/e2f0031b-52bd-4223-9ac1-d91cb519d548" ] ENET_ASSOCIATED_PROFILE_URIS = [ "/rest/server-profiles/83e2e117-59dc-4e33-9f24-462af951cbbe", "/rest/server-profiles/57d3af2a-b6d2-4446-8645-f38dd808ea4d" ] ENET_ASSOCIATED_UPLINK_GROUPS = [dict(uri=ENET_ASSOCIATED_UPLINK_GROUP_URIS[0], name='Uplink Set 1'), dict(uri=ENET_ASSOCIATED_UPLINK_GROUP_URIS[1], name='Uplink Set 2')] ENET_ASSOCIATED_PROFILES = [dict(uri=ENET_ASSOCIATED_PROFILE_URIS[0], name='Server Profile 1'), dict(uri=ENET_ASSOCIATED_PROFILE_URIS[1], name='Server Profile 2')] @pytest.mark.resource(TestEthernetNetworkFactsModule='ethernet_networks') class TestEthernetNetworkFactsModule(OneViewBaseFactsTest): def test_should_get_all_enets(self): self.resource.get_all.return_value = PRESENT_ENETS self.mock_ansible_module.params = PARAMS_GET_ALL EthernetNetworkFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(ethernet_networks=(PRESENT_ENETS)) ) def test_should_get_enet_by_name(self): self.resource.data = PRESENT_ENETS self.mock_ansible_module.params = PARAMS_GET_BY_NAME EthernetNetworkFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(ethernet_networks=(PRESENT_ENETS)) ) def test_should_get_enet_by_name_with_options(self): self.resource.data = PRESENT_ENETS self.resource.get_associated_profiles.return_value = ENET_ASSOCIATED_PROFILE_URIS self.resource.get_associated_uplink_groups.return_value = ENET_ASSOCIATED_UPLINK_GROUP_URIS profiles = [] for data in ENET_ASSOCIATED_PROFILES: obj = mock.Mock() obj.data = data profiles.append(obj) uplinks = [] for data in ENET_ASSOCIATED_UPLINK_GROUPS: obj = mock.Mock() obj.data = data uplinks.append(obj) self.mock_ov_client.server_profiles.get_by_uri.side_effect = profiles self.mock_ov_client.uplink_sets.get_by_uri.side_effect = uplinks self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_OPTIONS EthernetNetworkFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(ethernet_networks=PRESENT_ENETS, enet_associated_profiles=ENET_ASSOCIATED_PROFILES, enet_associated_uplink_groups=ENET_ASSOCIATED_UPLINK_GROUPS) ) if __name__ == '__main__': pytest.main([__file__])
HewlettPackard/oneview-ansible
test/test_oneview_ethernet_network_facts.py
Python
apache-2.0
4,198
# -*- coding: ascii -*- r""" :Copyright: Copyright 2007 - 2015 Andr\xe9 Malo or his licensors, as applicable :License: Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ===================== HTML forms reloaded ===================== Form helper classes. """ if __doc__: # pylint: disable = redefined-builtin __doc__ = __doc__.encode('ascii').decode('unicode_escape') __author__ = r"Andr\xe9 Malo".encode('ascii').decode('unicode_escape') __docformat__ = "restructuredtext en" __all__ = [ 'DictParameterAdapter', 'ListDictParameterAdapter', 'MultiDictParameterAdapter', 'NullParameterAdapter', ] from ._interfaces import ParameterAdapterInterface class DictParameterAdapter(object): """ HTMLForm parameter adapter from a simple dict :IVariables: `param` : ``dict`` Parameters """ __implements__ = [ParameterAdapterInterface] def __init__(self, param): """ Initialization :Parameters: `param` : ``dict`` Parameters """ self.param = param def getfirst(self, name, default=None): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ return self.param.get(name, default) def getlist(self, name): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ if name in self.param: return [self.param[name]] return [] class ListDictParameterAdapter(object): """ HTMLForm parameter adapter from a dict of sequences :IVariables: `param` : dict of sequences Parameters """ __implements__ = [ParameterAdapterInterface] def __init__(self, param): """ Initialization :Parameters: `param` : dict of sequences Parameters. Empty sequences act as if the key was not present. Otherwise ``getfirst`` will return the first element and ``getlist`` will return a shallow copy of the sequence as a ``list``. """ self.param = param def getfirst(self, name, default=None): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ try: result = self.param[name] except KeyError: pass else: if result: return result[0] return default def getlist(self, name): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ try: result = self.param[name] except KeyError: pass else: return list(result) return [] class MultiDictParameterAdapter(object): """ HTMLForm parameter adapter from a multidict (like paste provides) :IVariables: `param` : multidict Parameters """ __implements__ = [ParameterAdapterInterface] def __init__(self, param): """ Initialization :Parameters: `param` : multidict Parameters. The object is expected to provide a getall() method """ self.param = param def getfirst(self, name, default=None): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ try: return self.param.getall(name)[0] except IndexError: return default def getlist(self, name): """ :See: ``tdi.tools.htmlform.ParameterAdapterInterface`` """ return self.param.getall(name) class NullParameterAdapter(object): """ This adapter just returns nothing """ __implements__ = [ParameterAdapterInterface] def getlist(self, name): """ :See: `ParameterAdapterInterface.getlist` """ # pylint: disable = unused-argument return [] def getfirst(self, name, default=None): """ :See: `ParameterAdapterInterface.getfirst` """ # pylint: disable = unused-argument return default
ndparker/tdi
tdi/tools/htmlform/_adapters.py
Python
apache-2.0
4,395
__author__ = "Nitin Kumar, Rick Sherman" __credits__ = "Jeremy Schulman" import unittest from nose.plugins.attrib import attr from mock import patch import os from jnpr.junos import Device from jnpr.junos.facts.swver import facts_software_version as software_version, version_info from ncclient.manager import Manager, make_device_handler from ncclient.transport import SSHSession @attr('unit') class TestVersionInfo(unittest.TestCase): def test_version_info_after_type_len_else(self): self.assertIsNone(version_info('12.1X46-D10').build) def test_version_info_constructor_else_exception(self): self.assertEqual(version_info('11.4R7').build, '7') def test_version_info_repr(self): self.assertEqual(repr(version_info('11.4R7.5')), 'junos.version_info(major=(11, 4), ' 'type=R, minor=7, build=5)') def test_version_info_lt(self): self.assertLess(version_info('13.3-20131120'), (14, 1)) def test_version_info_lt_eq(self): self.assertLessEqual(version_info('13.3-20131120'), (14, 1)) def test_version_info_gt(self): self.assertGreater(version_info('13.3-20131120'), (12, 1)) def test_version_info_gt_eq(self): self.assertGreaterEqual(version_info('13.3-20131120'), (12, 1)) def test_version_info_eq(self): self.assertEqual(version_info('13.3-20131120'), (13, 3)) def test_version_info_not_eq(self): self.assertNotEqual(version_info('13.3-20131120'), (15, 3)) @attr('unit') class TestSrxCluster(unittest.TestCase): @patch('ncclient.manager.connect') def setUp(self, mock_connect): mock_connect.side_effect = self._mock_manager self.dev = Device(host='1.1.1.1', user='rick', password='password123', gather_facts=False) self.dev.open() self.facts = {} @patch('jnpr.junos.Device.execute') def test_swver(self, mock_execute): mock_execute.side_effect = self._mock_manager self.facts['master'] = 'RE0' software_version(self.dev, self.facts) self.assertEqual(self.facts['version'], '12.3R6.6') @patch('jnpr.junos.Device.execute') def test_swver_hostname_none(self, mock_execute): mock_execute.side_effect = self._mock_manager self.facts['master'] = 'RE5' self.facts['version_RE5'] = '15.3R6.6' software_version(self.dev, self.facts) self.assertEqual(self.facts['version'], '15.3R6.6') # --> JLS, there should always be a facts['master'] assigned. # @patch('jnpr.junos.Device.execute') # def test_swver_master_none(self, mock_execute): # mock_execute.side_effect = self._mock_manager # self.facts['master'] = None # software_version(self.dev, self.facts) # self.assertEqual(self.facts['version'], '12.3R6.6') @patch('jnpr.junos.Device.execute') @patch('jnpr.junos.facts.swver.re.findall') def test_swver_exception_handling(self, mock_re_findall, mock_execute): mock_execute.side_effect = self._mock_manager mock_re_findall.side_effect = IndexError self.facts['master'] = 'RE0' software_version(self.dev, self.facts) self.assertEqual(self.facts['version'], '0.0I0.0') def _read_file(self, fname): from ncclient.xml_ import NCElement fpath = os.path.join(os.path.dirname(__file__), 'rpc-reply', fname) foo = open(fpath).read() rpc_reply = NCElement(foo, self.dev._conn. _device_handler.transform_reply())\ ._NCElement__doc[0] return rpc_reply def _mock_manager(self, *args, **kwargs): if kwargs: device_params = kwargs['device_params'] device_handler = make_device_handler(device_params) session = SSHSession(device_handler) return Manager(session, device_handler) if args: return self._read_file(args[0].tag + '.xml')
dgjnpr/py-junos-eznc
tests/unit/facts/test_swver.py
Python
apache-2.0
4,029
# Copyright (c) 2016-2017 Dustin Doloff # Licensed under Apache License v2.0 import argparse import difflib import hashlib import os import subprocess import zipfile # Resets color formatting COLOR_END = '\33[0m' # Modifies characters or color COLOR_BOLD = '\33[1m' COLOR_DISABLED = '\33[02m' # Mostly just means darker # Sets the text color COLOR_GREEN = '\33[32m' COLOR_YELLOW = '\33[33m' COLOR_RED = '\33[31m' def parse_args(): parser = argparse.ArgumentParser(description='Asserts files are the same') parser.add_argument('--stamp', type=argparse.FileType('w+'), required=True, help='Stamp file to record action completed') parser.add_argument('--files', type=str, nargs='+', required=True) return parser.parse_args() def bytes_to_str(bytes): return bytes.decode('utf-8', 'backslashreplace') def color_diff(text_a, text_b): """ Compares two pieces of text and returns a tuple The first value is a colorized diff of the texts. The second value is a boolean, True if there was a diff, False if there wasn't. """ sequence_matcher = difflib.SequenceMatcher(None, text_a, text_b) colorized_diff = '' diff = False for opcode, a0, a1, b0, b1 in sequence_matcher.get_opcodes(): if opcode == 'equal': colorized_diff += bytes_to_str(sequence_matcher.a[a0:a1]) elif opcode == 'insert': colorized_diff += COLOR_BOLD + COLOR_GREEN + bytes_to_str(sequence_matcher.b[b0:b1]) + COLOR_END diff = True elif opcode == 'delete': colorized_diff += COLOR_BOLD + COLOR_RED + bytes_to_str(sequence_matcher.a[a0:a1]) + COLOR_END diff = True elif opcode == 'replace': colorized_diff += (COLOR_BOLD + COLOR_YELLOW + bytes_to_str(sequence_matcher.a[a0:a1]) + COLOR_DISABLED + bytes_to_str(sequence_matcher.b[b0:b1]) + COLOR_END) diff = True else: raise RuntimeError('unexpected opcode ' + opcode) return colorized_diff, diff def hash_file(file): """ Computes the SHA-256 hash of the file file - The file to hash """ hasher = hashlib.sha256() with open(file, 'rb') as f: for block in iter(lambda: f.read(1024), b''): hasher.update(block) return hasher.digest() def summarize(file): """ Summarizes a file via it's metadata to provide structured text for diffing """ summary = None if zipfile.is_zipfile(file): with zipfile.ZipFile(file) as zf: summary = '' for info in zf.infolist(): summary += 'Entry: (' summary += ', '.join(s + ': ' + repr(getattr(info, s)) for s in info.__slots__) summary += ') ' + os.linesep assert summary is not None, 'Unable to summarize %s' % file return summary def main(): args = parse_args() files = args.files assert len(files) >= 2, 'There must be at least two files to compare' files_hashes = set() max_file_size = 0 for file in files: files_hashes.add(hash_file(file)) max_file_size = max(max_file_size, os.stat(file).st_size) # Check hashes first if len(files_hashes) != 1: for i in range(len(files) - 1): file_a = files[i] file_b = files[i + 1] file_a_contents = None file_b_contents = None if max_file_size > 1024 * 1024: file_a_contents = summarize(file_a) file_b_contents = summarize(file_b) else: with open(file_a, 'rb') as a: file_a_contents = a.read() with open(file_b, 'rb') as b: file_b_contents = b.read() diff, problem = color_diff(file_a_contents, file_b_contents) assert not problem, 'File {a} does not match {b}:{newline}{diff}'.format( a = file_a, b = file_b, newline = os.linesep, diff = diff) assert False, 'File hashes don\'t match.' with args.stamp as stamp_file: stamp_file.write(str(args)) if __name__ == '__main__': main()
quittle/bazel_toolbox
assert/scripts/assert_equal.py
Python
apache-2.0
4,276
# Copyright 2012, Nachi Ueno, NTT MCL, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import copy import mock from neutron_lib import constants from oslo_config import cfg import six import testtools from neutron.agent.common import config as a_cfg from neutron.agent import firewall from neutron.agent.linux import ipset_manager from neutron.agent.linux import iptables_comments as ic from neutron.agent.linux import iptables_firewall from neutron.common import exceptions as n_exc from neutron.common import utils from neutron.conf.agent import securitygroups_rpc as security_config from neutron.tests import base from neutron.tests.unit.api.v2 import test_base _uuid = test_base._uuid #TODO(mangelajo): replace all 'IPv4', 'IPv6' to constants FAKE_PREFIX = {'IPv4': '10.0.0.0/24', 'IPv6': 'fe80::/48'} FAKE_IP = {'IPv4': '10.0.0.1', 'IPv6': 'fe80::1'} #TODO(mangelajo): replace all '*_sgid' strings for the constants FAKE_SGID = 'fake_sgid' OTHER_SGID = 'other_sgid' _IPv6 = constants.IPv6 _IPv4 = constants.IPv4 RAW_TABLE_OUTPUT = """ # Generated by iptables-save v1.4.21 on Fri Jul 31 16:13:28 2015 *raw :PREROUTING ACCEPT [11561:3470468] :OUTPUT ACCEPT [11504:4064044] :neutron-openvswi-OUTPUT - [0:0] :neutron-openvswi-PREROUTING - [0:0] -A PREROUTING -j neutron-openvswi-PREROUTING -A OUTPUT -j neutron-openvswi-OUTPUT -A neutron-openvswi-PREROUTING -m physdev --physdev-in qvbe804433b-61 -j CT --zone 1 -A neutron-openvswi-PREROUTING -m physdev --physdev-in tape804433b-61 -j CT --zone 1 -A neutron-openvswi-PREROUTING -m physdev --physdev-in qvb95c24827-02 -j CT --zone 2 -A neutron-openvswi-PREROUTING -m physdev --physdev-in tap95c24827-02 -j CT --zone 2 -A neutron-openvswi-PREROUTING -m physdev --physdev-in qvb61634509-31 -j CT --zone 2 -A neutron-openvswi-PREROUTING -m physdev --physdev-in tap61634509-31 -j CT --zone 2 -A neutron-openvswi-PREROUTING -m physdev --physdev-in qvb8f46cf18-12 -j CT --zone 9 -A neutron-openvswi-PREROUTING -m physdev --physdev-in tap8f46cf18-12 -j CT --zone 9 COMMIT # Completed on Fri Jul 31 16:13:28 2015 """ # noqa class BaseIptablesFirewallTestCase(base.BaseTestCase): def setUp(self): super(BaseIptablesFirewallTestCase, self).setUp() cfg.CONF.register_opts(a_cfg.ROOT_HELPER_OPTS, 'AGENT') security_config.register_securitygroups_opts() cfg.CONF.set_override('comment_iptables_rules', False, 'AGENT') self.utils_exec_p = mock.patch( 'neutron.agent.linux.utils.execute') self.utils_exec = self.utils_exec_p.start() self.iptables_cls_p = mock.patch( 'neutron.agent.linux.iptables_manager.IptablesManager') iptables_cls = self.iptables_cls_p.start() self.iptables_inst = mock.Mock() self.v4filter_inst = mock.Mock() self.v6filter_inst = mock.Mock() self.iptables_inst.ipv4 = {'filter': self.v4filter_inst, 'raw': self.v4filter_inst } self.iptables_inst.ipv6 = {'filter': self.v6filter_inst, 'raw': self.v6filter_inst } iptables_cls.return_value = self.iptables_inst self.iptables_inst.get_rules_for_table.return_value = ( RAW_TABLE_OUTPUT.splitlines()) self.firewall = iptables_firewall.IptablesFirewallDriver() self.firewall.iptables = self.iptables_inst class IptablesFirewallTestCase(BaseIptablesFirewallTestCase): def _fake_port(self): return {'device': 'tapfake_dev', 'mac_address': 'ff:ff:ff:ff:ff:ff', 'network_id': 'fake_net', 'fixed_ips': [FAKE_IP['IPv4'], FAKE_IP['IPv6']]} def test_prepare_port_filter_with_no_sg(self): port = self._fake_port() self.firewall.prepare_port_filter(port) calls = [mock.call.add_chain('sg-fallback'), mock.call.add_rule( 'sg-fallback', '-j DROP', comment=ic.UNMATCH_DROP), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $ifake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule( 'ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule('INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-s 10.0.0.1/32 -m mac --mac-source FF:FF:FF:FF:FF:FF ' '-j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-j DROP', comment=ic.PAIR_DROP), mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT')] self.v4filter_inst.assert_has_calls(calls) def test_filter_ipv4_ingress(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress'} ingress = mock.call.add_rule('ifake_dev', '-j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_tcp(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'tcp'} ingress = mock.call.add_rule( 'ifake_dev', '-p tcp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_tcp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'tcp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule('ifake_dev', '-s %s -p tcp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_icmp(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'icmp'} ingress = mock.call.add_rule('ifake_dev', '-p icmp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_icmp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'icmp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p icmp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_tcp_port(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 10} ingress = mock.call.add_rule('ifake_dev', '-p tcp -m tcp --dport 10 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_tcp_mport(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100} ingress = mock.call.add_rule( 'ifake_dev', '-p tcp -m tcp -m multiport --dports 10:100 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_tcp_mport_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p tcp -m tcp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_udp(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'udp'} ingress = mock.call.add_rule( 'ifake_dev', '-p udp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_udp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'udp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule('ifake_dev', '-s %s -p udp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_udp_port(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 10} ingress = mock.call.add_rule('ifake_dev', '-p udp -m udp --dport 10 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_udp_mport(self): rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100} ingress = mock.call.add_rule( 'ifake_dev', '-p udp -m udp -m multiport --dports 10:100 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_ingress_udp_mport_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p udp -m udp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress(self): rule = {'ethertype': 'IPv4', 'direction': 'egress'} egress = mock.call.add_rule('ofake_dev', '-j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_tcp(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'tcp'} egress = mock.call.add_rule( 'ofake_dev', '-p tcp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_tcp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'tcp', 'source_ip_prefix': prefix} egress = mock.call.add_rule('ofake_dev', '-s %s -p tcp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_icmp(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'icmp'} egress = mock.call.add_rule('ofake_dev', '-p icmp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_icmp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'icmp', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p icmp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_icmp_type(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 8, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p icmp -m icmp --icmp-type 8 -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_icmp_type_name(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 'echo-request', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p icmp -m icmp --icmp-type echo-request ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_icmp_type_code(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 8, 'source_port_range_max': 0, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p icmp -m icmp --icmp-type 8/0 -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_tcp_port(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 10} egress = mock.call.add_rule('ofake_dev', '-p tcp -m tcp --dport 10 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_tcp_mport(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100} egress = mock.call.add_rule( 'ofake_dev', '-p tcp -m tcp -m multiport --dports 10:100 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_tcp_mport_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p tcp -m tcp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_udp(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'udp'} egress = mock.call.add_rule( 'ofake_dev', '-p udp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_udp_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'udp', 'source_ip_prefix': prefix} egress = mock.call.add_rule('ofake_dev', '-s %s -p udp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_udp_port(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 10} egress = mock.call.add_rule('ofake_dev', '-p udp -m udp --dport 10 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_udp_mport(self): rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100} egress = mock.call.add_rule( 'ofake_dev', '-p udp -m udp -m multiport --dports 10:100 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv4_egress_udp_mport_prefix(self): prefix = FAKE_PREFIX['IPv4'] rule = {'ethertype': 'IPv4', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p udp -m udp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress'} ingress = mock.call.add_rule('ifake_dev', '-j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_tcp(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'tcp'} ingress = mock.call.add_rule( 'ifake_dev', '-p tcp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_tcp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'tcp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule('ifake_dev', '-s %s -p tcp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_tcp_port(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 10} ingress = mock.call.add_rule('ifake_dev', '-p tcp -m tcp --dport 10 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_icmp(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'icmp'} ingress = mock.call.add_rule( 'ifake_dev', '-p ipv6-icmp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_icmp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'icmp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p ipv6-icmp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_tcp_mport(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100} ingress = mock.call.add_rule( 'ifake_dev', '-p tcp -m tcp -m multiport --dports 10:100 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def _test_filter_ingress_tcp_min_port_0(self, ethertype): rule = {'ethertype': ethertype, 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 0, 'port_range_max': 100} ingress = mock.call.add_rule( 'ifake_dev', '-p tcp -m tcp -m multiport --dports 0:100 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ingress_tcp_min_port_0_for_ipv4(self): self._test_filter_ingress_tcp_min_port_0('IPv4') def test_filter_ingress_tcp_min_port_0_for_ipv6(self): self._test_filter_ingress_tcp_min_port_0('IPv6') def test_filter_ipv6_ingress_tcp_mport_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p tcp -m tcp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_udp(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'udp'} ingress = mock.call.add_rule( 'ifake_dev', '-p udp -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_udp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'udp', 'source_ip_prefix': prefix} ingress = mock.call.add_rule('ifake_dev', '-s %s -p udp -j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_udp_port(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 10} ingress = mock.call.add_rule('ifake_dev', '-p udp -m udp --dport 10 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_udp_mport(self): rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100} ingress = mock.call.add_rule( 'ifake_dev', '-p udp -m udp -m multiport --dports 10:100 -j RETURN', comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_ingress_udp_mport_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'ingress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} ingress = mock.call.add_rule( 'ifake_dev', '-s %s -p udp -m udp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) egress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress(self): rule = {'ethertype': 'IPv6', 'direction': 'egress'} egress = mock.call.add_rule('ofake_dev', '-j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_tcp(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'tcp'} egress = mock.call.add_rule( 'ofake_dev', '-p tcp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_tcp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'tcp', 'source_ip_prefix': prefix} egress = mock.call.add_rule('ofake_dev', '-s %s -p tcp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_icmp(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'icmp'} egress = mock.call.add_rule( 'ofake_dev', '-p ipv6-icmp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_icmp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'icmp', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p ipv6-icmp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_icmp_type(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 8, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p ipv6-icmp -m icmp6 --icmpv6-type 8 -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_icmp_type_name(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 'echo-request', 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p ipv6-icmp -m icmp6 --icmpv6-type echo-request ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_icmp_type_code(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'icmp', 'source_port_range_min': 8, 'source_port_range_max': 0, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p ipv6-icmp -m icmp6 --icmpv6-type 8/0 -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_tcp_port(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 10} egress = mock.call.add_rule('ofake_dev', '-p tcp -m tcp --dport 10 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_tcp_mport(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100} egress = mock.call.add_rule( 'ofake_dev', '-p tcp -m tcp -m multiport --dports 10:100 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_tcp_mport_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'tcp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p tcp -m tcp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_udp(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'udp'} egress = mock.call.add_rule( 'ofake_dev', '-p udp -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_udp_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'udp', 'source_ip_prefix': prefix} egress = mock.call.add_rule('ofake_dev', '-s %s -p udp -j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_udp_port(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 10} egress = mock.call.add_rule('ofake_dev', '-p udp -m udp --dport 10 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_udp_mport(self): rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100} egress = mock.call.add_rule( 'ofake_dev', '-p udp -m udp -m multiport --dports 10:100 -j RETURN', comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def test_filter_ipv6_egress_udp_mport_prefix(self): prefix = FAKE_PREFIX['IPv6'] rule = {'ethertype': 'IPv6', 'direction': 'egress', 'protocol': 'udp', 'port_range_min': 10, 'port_range_max': 100, 'source_ip_prefix': prefix} egress = mock.call.add_rule( 'ofake_dev', '-s %s -p udp -m udp -m multiport --dports 10:100 ' '-j RETURN' % prefix, comment=None) ingress = None self._test_prepare_port_filter(rule, ingress, egress) def _test_prepare_port_filter(self, rule, ingress_expected_call=None, egress_expected_call=None): port = self._fake_port() ethertype = rule['ethertype'] prefix = utils.ip_to_cidr(FAKE_IP[ethertype]) filter_inst = self.v4filter_inst dhcp_rule = [mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None)] if ethertype == 'IPv6': filter_inst = self.v6filter_inst dhcp_rule = [mock.call.add_rule('ofake_dev', '-s ::/128 -d ff02::/16 ' '-p ipv6-icmp -m icmp6 ' '--icmpv6-type %s -j RETURN' % icmp6_type, comment=None) for icmp6_type in constants.ICMPV6_ALLOWED_UNSPEC_ADDR_TYPES] sg = [rule] port['security_group_rules'] = sg self.firewall.prepare_port_filter(port) calls = [mock.call.add_chain('sg-fallback'), mock.call.add_rule( 'sg-fallback', '-j DROP', comment=ic.UNMATCH_DROP), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $ifake_dev', comment=ic.SG_TO_VM_SG) ] if ethertype == 'IPv6': for icmp6_type in firewall.ICMPV6_ALLOWED_TYPES: calls.append( mock.call.add_rule('ifake_dev', '-p ipv6-icmp -m icmp6 --icmpv6-type ' '%s -j RETURN' % icmp6_type, comment=None)) calls += [ mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None ) ] if ingress_expected_call: calls.append(ingress_expected_call) calls += [mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule('INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-s %s -m mac --mac-source FF:FF:FF:FF:FF:FF -j RETURN' % prefix, comment=ic.PAIR_ALLOW)] if ethertype == 'IPv6': calls.append(mock.call.add_rule('sfake_dev', '-s fe80::fdff:ffff:feff:ffff/128 -m mac ' '--mac-source FF:FF:FF:FF:FF:FF -j RETURN', comment=ic.PAIR_ALLOW)) calls.append(mock.call.add_rule('sfake_dev', '-j DROP', comment=ic.PAIR_DROP)) calls += dhcp_rule calls.append(mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None)) if ethertype == 'IPv4': calls.append(mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None)) calls.append(mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None)) if ethertype == 'IPv6': calls.append(mock.call.add_rule('ofake_dev', '-p ipv6-icmp -m icmp6 ' '--icmpv6-type %s -j DROP' % constants.ICMPV6_TYPE_RA, comment=None)) calls.append(mock.call.add_rule('ofake_dev', '-p ipv6-icmp -j RETURN', comment=None)) calls.append(mock.call.add_rule('ofake_dev', '-p udp -m udp ' '--sport 546 -m udp --dport 547 ' '-j RETURN', comment=None)) calls.append(mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 547 -m udp --dport 546 -j DROP', comment=None)) calls += [ mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), ] if egress_expected_call: calls.append(egress_expected_call) calls += [mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT')] comb = zip(calls, filter_inst.mock_calls) for (l, r) in comb: self.assertEqual(l, r) filter_inst.assert_has_calls(calls) def _test_remove_conntrack_entries(self, ethertype, protocol, direction): port = self._fake_port() port['security_groups'] = 'fake_sg_id' self.firewall.filtered_ports[port['device']] = port self.firewall.updated_rule_sg_ids = set(['fake_sg_id']) self.firewall.sg_rules['fake_sg_id'] = [ {'direction': direction, 'ethertype': ethertype, 'protocol': protocol}] self.firewall.filter_defer_apply_on() self.firewall.sg_rules['fake_sg_id'] = [] self.firewall.filter_defer_apply_off() cmd = ['conntrack', '-D'] if protocol: cmd.extend(['-p', protocol]) if ethertype == 'IPv4': cmd.extend(['-f', 'ipv4']) if direction == 'ingress': cmd.extend(['-d', '10.0.0.1']) else: cmd.extend(['-s', '10.0.0.1']) else: cmd.extend(['-f', 'ipv6']) if direction == 'ingress': cmd.extend(['-d', 'fe80::1']) else: cmd.extend(['-s', 'fe80::1']) # initial data has 1, 2, and 9 in use, CT zone will start at 10. cmd.extend(['-w', 10]) calls = [ mock.call(cmd, run_as_root=True, check_exit_code=True, extra_ok_codes=[1])] self.utils_exec.assert_has_calls(calls) def test_remove_conntrack_entries_for_delete_rule_ipv4(self): for direction in ['ingress', 'egress']: for pro in [None, 'tcp', 'icmp', 'udp']: self._test_remove_conntrack_entries( 'IPv4', pro, direction) def test_remove_conntrack_entries_for_delete_rule_ipv6(self): for direction in ['ingress', 'egress']: for pro in [None, 'tcp', 'icmp', 'udp']: self._test_remove_conntrack_entries( 'IPv6', pro, direction) def test_remove_conntrack_entries_for_port_sec_group_change(self): port = self._fake_port() port['security_groups'] = ['fake_sg_id'] self.firewall.filtered_ports[port['device']] = port self.firewall.updated_sg_members = set(['tapfake_dev']) self.firewall.filter_defer_apply_on() new_port = copy.deepcopy(port) new_port['security_groups'] = ['fake_sg_id2'] self.firewall.filtered_ports[port['device']] = new_port self.firewall.filter_defer_apply_off() calls = [ # initial data has 1, 2, and 9 in use, CT zone will start at 10. mock.call(['conntrack', '-D', '-f', 'ipv4', '-d', '10.0.0.1', '-w', 10], run_as_root=True, check_exit_code=True, extra_ok_codes=[1]), mock.call(['conntrack', '-D', '-f', 'ipv4', '-s', '10.0.0.1', '-w', 10], run_as_root=True, check_exit_code=True, extra_ok_codes=[1]), mock.call(['conntrack', '-D', '-f', 'ipv6', '-d', 'fe80::1', '-w', 10], run_as_root=True, check_exit_code=True, extra_ok_codes=[1]), mock.call(['conntrack', '-D', '-f', 'ipv6', '-s', 'fe80::1', '-w', 10], run_as_root=True, check_exit_code=True, extra_ok_codes=[1])] self.utils_exec.assert_has_calls(calls) def test_remove_conntrack_entries_for_sg_member_changed_ipv4(self): for direction in ['ingress', 'egress']: for protocol in [None, 'tcp', 'icmp', 'udp']: self._test_remove_conntrack_entries_sg_member_changed( 'IPv4', protocol, direction) def test_remove_conntrack_entries_for_sg_member_changed_ipv6(self): for direction in ['ingress', 'egress']: for protocol in [None, 'tcp', 'icmp', 'udp']: self._test_remove_conntrack_entries_sg_member_changed( 'IPv6', protocol, direction) def _test_remove_conntrack_entries_sg_member_changed(self, ethertype, protocol, direction): port = self._fake_port() port['security_groups'] = ['fake_sg_id'] self.firewall.sg_rules.setdefault('fake_sg_id', []) self.firewall.sg_rules['fake_sg_id'].append( {'direction': direction, 'remote_group_id': 'fake_sg_id2', 'ethertype': ethertype}) self.firewall.filter_defer_apply_on() self.firewall.devices_with_updated_sg_members['fake_sg_id2'] = [port] if ethertype == "IPv4": self.firewall.pre_sg_members = {'fake_sg_id2': { 'IPv4': ['10.0.0.2', '10.0.0.3']}} self.firewall.sg_members = {'fake_sg_id2': { 'IPv4': ['10.0.0.3']}} ethertype = "ipv4" else: self.firewall.pre_sg_members = {'fake_sg_id2': { 'IPv6': ['fe80::2', 'fe80::3']}} self.firewall.sg_members = {'fake_sg_id2': { 'IPv6': ['fe80::3']}} ethertype = "ipv6" self.firewall.filter_defer_apply_off() direction = '-d' if direction == 'ingress' else '-s' remote_ip_direction = '-s' if direction == '-d' else '-d' ips = {"ipv4": ['10.0.0.1', '10.0.0.2'], "ipv6": ['fe80::1', 'fe80::2']} calls = [ # initial data has 1, 2, and 9 in use, CT zone will start # at 10. mock.call(['conntrack', '-D', '-f', ethertype, direction, ips[ethertype][0], '-w', 10, remote_ip_direction, ips[ethertype][1]], run_as_root=True, check_exit_code=True, extra_ok_codes=[1])] self.utils_exec.assert_has_calls(calls) def test_user_sg_rules_deduped_before_call_to_iptables_manager(self): port = self._fake_port() port['security_group_rules'] = [{'ethertype': 'IPv4', 'direction': 'ingress'}] * 2 self.firewall.prepare_port_filter(port) rules = [''.join(c[1]) for c in self.v4filter_inst.add_rule.mock_calls] self.assertEqual(len(set(rules)), len(rules)) def test_update_delete_port_filter(self): port = self._fake_port() port['security_group_rules'] = [{'ethertype': 'IPv4', 'direction': 'ingress'}] self.firewall.prepare_port_filter(port) port['security_group_rules'] = [{'ethertype': 'IPv4', 'direction': 'egress'}] self.firewall.update_port_filter(port) self.firewall.update_port_filter({'device': 'no-exist-device'}) self.firewall.remove_port_filter(port) self.firewall.remove_port_filter({'device': 'no-exist-device'}) calls = [mock.call.add_chain('sg-fallback'), mock.call.add_rule( 'sg-fallback', '-j DROP', comment=ic.UNMATCH_DROP), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule( 'FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged -j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule( 'sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged -j $ifake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule('ifake_dev', '-j RETURN', comment=None), mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule( 'ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule( 'FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule( 'sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-s 10.0.0.1/32 -m mac --mac-source FF:FF:FF:FF:FF:FF ' '-j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-j DROP', comment=ic.PAIR_DROP), mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT'), mock.call.remove_chain('ifake_dev'), mock.call.remove_chain('ofake_dev'), mock.call.remove_chain('sfake_dev'), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule( 'FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged -j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule( 'sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged -j $ifake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule( 'ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule( 'FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule( 'sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-s 10.0.0.1/32 -m mac --mac-source FF:FF:FF:FF:FF:FF ' '-j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-j DROP', comment=ic.PAIR_DROP), mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT'), mock.call.remove_chain('ifake_dev'), mock.call.remove_chain('ofake_dev'), mock.call.remove_chain('sfake_dev'), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain')] self.v4filter_inst.assert_has_calls(calls) def test_remove_unknown_port(self): port = self._fake_port() self.firewall.remove_port_filter(port) # checking no exception occurs self.assertFalse(self.v4filter_inst.called) def test_defer_apply(self): with self.firewall.defer_apply(): pass self.iptables_inst.assert_has_calls([mock.call.defer_apply_on(), mock.call.defer_apply_off()]) def test_filter_defer_with_exception(self): try: with self.firewall.defer_apply(): raise Exception("same exception") except Exception: pass self.iptables_inst.assert_has_calls([mock.call.defer_apply_on(), mock.call.defer_apply_off()]) def _mock_chain_applies(self): class CopyingMock(mock.MagicMock): """Copies arguments so mutable arguments can be asserted on. Copied verbatim from unittest.mock documentation. """ def __call__(self, *args, **kwargs): args = copy.deepcopy(args) kwargs = copy.deepcopy(kwargs) return super(CopyingMock, self).__call__(*args, **kwargs) # Need to use CopyingMock because _{setup,remove}_chains_apply are # usually called with that's modified between calls (i.e., # self.firewall.filtered_ports). chain_applies = CopyingMock() self.firewall._setup_chains_apply = chain_applies.setup self.firewall._remove_chains_apply = chain_applies.remove return chain_applies def test_mock_chain_applies(self): chain_applies = self._mock_chain_applies() port_prepare = {'device': 'd1', 'mac_address': 'prepare'} port_update = {'device': 'd1', 'mac_address': 'update'} self.firewall.prepare_port_filter(port_prepare) self.firewall.update_port_filter(port_update) self.firewall.remove_port_filter(port_update) chain_applies.assert_has_calls([mock.call.remove({}, {}), mock.call.setup({'d1': port_prepare}, {}), mock.call.remove({'d1': port_prepare}, {}), mock.call.setup({'d1': port_update}, {}), mock.call.remove({'d1': port_update}, {}), mock.call.setup({}, {})]) def test_defer_chain_apply_need_pre_defer_copy(self): chain_applies = self._mock_chain_applies() port = self._fake_port() device2port = {port['device']: port} self.firewall.prepare_port_filter(port) with self.firewall.defer_apply(): self.firewall.remove_port_filter(port) chain_applies.assert_has_calls([mock.call.remove({}, {}), mock.call.setup(device2port, {}), mock.call.remove(device2port, {}), mock.call.setup({}, {})]) def test_defer_chain_apply_coalesce_simple(self): chain_applies = self._mock_chain_applies() port = self._fake_port() with self.firewall.defer_apply(): self.firewall.prepare_port_filter(port) self.firewall.update_port_filter(port) self.firewall.remove_port_filter(port) chain_applies.assert_has_calls([mock.call.remove({}, {}), mock.call.setup({}, {})]) def test_defer_chain_apply_coalesce_multiple_ports(self): chain_applies = self._mock_chain_applies() port1 = {'device': 'd1', 'mac_address': 'mac1', 'network_id': 'net1'} port2 = {'device': 'd2', 'mac_address': 'mac2', 'network_id': 'net1'} device2port = {'d1': port1, 'd2': port2} with self.firewall.defer_apply(): self.firewall.prepare_port_filter(port1) self.firewall.prepare_port_filter(port2) chain_applies.assert_has_calls([mock.call.remove({}, {}), mock.call.setup(device2port, {})]) def test_ip_spoofing_filter_with_multiple_ips(self): port = {'device': 'tapfake_dev', 'mac_address': 'ff:ff:ff:ff:ff:ff', 'network_id': 'fake_net', 'fixed_ips': ['10.0.0.1', 'fe80::1', '10.0.0.2']} self.firewall.prepare_port_filter(port) calls = [mock.call.add_chain('sg-fallback'), mock.call.add_rule( 'sg-fallback', '-j DROP', comment=ic.UNMATCH_DROP), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $ifake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule('INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-s 10.0.0.1/32 -m mac --mac-source FF:FF:FF:FF:FF:FF ' '-j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-s 10.0.0.2/32 -m mac --mac-source FF:FF:FF:FF:FF:FF ' '-j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-j DROP', comment=ic.PAIR_DROP), mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT')] self.v4filter_inst.assert_has_calls(calls) def test_ip_spoofing_no_fixed_ips(self): port = {'device': 'tapfake_dev', 'mac_address': 'ff:ff:ff:ff:ff:ff', 'network_id': 'fake_net', 'fixed_ips': []} self.firewall.prepare_port_filter(port) calls = [mock.call.add_chain('sg-fallback'), mock.call.add_rule( 'sg-fallback', '-j DROP', comment=ic.UNMATCH_DROP), mock.call.remove_chain('sg-chain'), mock.call.add_chain('sg-chain'), mock.call.add_chain('ifake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-out tapfake_dev ' '--physdev-is-bridged ' '-j $ifake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule( 'ifake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ifake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ifake_dev', '-j $sg-fallback', comment=None), mock.call.add_chain('ofake_dev'), mock.call.add_rule('FORWARD', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged ' '-j $sg-chain', comment=ic.VM_INT_SG), mock.call.add_rule('sg-chain', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.SG_TO_VM_SG), mock.call.add_rule('INPUT', '-m physdev --physdev-in tapfake_dev ' '--physdev-is-bridged -j $ofake_dev', comment=ic.INPUT_TO_SG), mock.call.add_chain('sfake_dev'), mock.call.add_rule( 'sfake_dev', '-m mac --mac-source FF:FF:FF:FF:FF:FF -j RETURN', comment=ic.PAIR_ALLOW), mock.call.add_rule( 'sfake_dev', '-j DROP', comment=ic.PAIR_DROP), mock.call.add_rule( 'ofake_dev', '-s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp ' '--sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule('ofake_dev', '-j $sfake_dev', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 68 --dport 67 -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-p udp -m udp --sport 67 -m udp --dport 68 -j DROP', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state RELATED,ESTABLISHED -j RETURN', comment=None), mock.call.add_rule( 'ofake_dev', '-m state --state INVALID -j DROP', comment=None), mock.call.add_rule('ofake_dev', '-j $sg-fallback', comment=None), mock.call.add_rule('sg-chain', '-j ACCEPT')] self.v4filter_inst.assert_has_calls(calls) class IptablesFirewallEnhancedIpsetTestCase(BaseIptablesFirewallTestCase): def setUp(self): super(IptablesFirewallEnhancedIpsetTestCase, self).setUp() self.firewall.ipset = mock.Mock() self.firewall.ipset.get_name.side_effect = ( ipset_manager.IpsetManager.get_name) self.firewall.ipset.set_name_exists.return_value = True def _fake_port(self, sg_id=FAKE_SGID): return {'device': 'tapfake_dev', 'mac_address': 'ff:ff:ff:ff:ff:ff', 'network_id': 'fake_net', 'fixed_ips': [FAKE_IP['IPv4'], FAKE_IP['IPv6']], 'security_groups': [sg_id], 'security_group_source_groups': [sg_id]} def _fake_sg_rule_for_ethertype(self, ethertype, remote_group): return {'direction': 'ingress', 'remote_group_id': remote_group, 'ethertype': ethertype} def _fake_sg_rules(self, sg_id=FAKE_SGID, remote_groups=None): remote_groups = remote_groups or {_IPv4: [FAKE_SGID], _IPv6: [FAKE_SGID]} rules = [] for ip_version, remote_group_list in six.iteritems(remote_groups): for remote_group in remote_group_list: rules.append(self._fake_sg_rule_for_ethertype(ip_version, remote_group)) return {sg_id: rules} def _fake_sg_members(self, sg_ids=None): return {sg_id: copy.copy(FAKE_IP) for sg_id in (sg_ids or [FAKE_SGID])} def test_update_security_group_members(self): sg_members = {'IPv4': ['10.0.0.1', '10.0.0.2'], 'IPv6': ['fe80::1']} self.firewall.update_security_group_members('fake_sgid', sg_members) calls = [ mock.call.set_members('fake_sgid', 'IPv4', ['10.0.0.1', '10.0.0.2']), mock.call.set_members('fake_sgid', 'IPv6', ['fe80::1']) ] self.firewall.ipset.assert_has_calls(calls, any_order=True) def _setup_fake_firewall_members_and_rules(self, firewall): firewall.sg_rules = self._fake_sg_rules() firewall.pre_sg_rules = self._fake_sg_rules() firewall.sg_members = self._fake_sg_members() firewall.pre_sg_members = firewall.sg_members def _prepare_rules_and_members_for_removal(self): self._setup_fake_firewall_members_and_rules(self.firewall) self.firewall.pre_sg_members[OTHER_SGID] = ( self.firewall.pre_sg_members[FAKE_SGID]) def test_determine_remote_sgs_to_remove(self): self._prepare_rules_and_members_for_removal() ports = [self._fake_port()] self.assertEqual( {_IPv4: set([OTHER_SGID]), _IPv6: set([OTHER_SGID])}, self.firewall._determine_remote_sgs_to_remove(ports)) def test_determine_remote_sgs_to_remove_ipv6_unreferenced(self): self._prepare_rules_and_members_for_removal() ports = [self._fake_port()] self.firewall.sg_rules = self._fake_sg_rules( remote_groups={_IPv4: [OTHER_SGID, FAKE_SGID], _IPv6: [FAKE_SGID]}) self.assertEqual( {_IPv4: set(), _IPv6: set([OTHER_SGID])}, self.firewall._determine_remote_sgs_to_remove(ports)) def test_get_remote_sg_ids_by_ipversion(self): self.firewall.sg_rules = self._fake_sg_rules( remote_groups={_IPv4: [FAKE_SGID], _IPv6: [OTHER_SGID]}) ports = [self._fake_port()] self.assertEqual( {_IPv4: set([FAKE_SGID]), _IPv6: set([OTHER_SGID])}, self.firewall._get_remote_sg_ids_sets_by_ipversion(ports)) def test_get_remote_sg_ids(self): self.firewall.sg_rules = self._fake_sg_rules( remote_groups={_IPv4: [FAKE_SGID, FAKE_SGID, FAKE_SGID], _IPv6: [OTHER_SGID, OTHER_SGID, OTHER_SGID]}) port = self._fake_port() self.assertEqual( {_IPv4: set([FAKE_SGID]), _IPv6: set([OTHER_SGID])}, self.firewall._get_remote_sg_ids(port)) def test_determine_sg_rules_to_remove(self): self.firewall.pre_sg_rules = self._fake_sg_rules(sg_id=OTHER_SGID) ports = [self._fake_port()] self.assertEqual(set([OTHER_SGID]), self.firewall._determine_sg_rules_to_remove(ports)) def test_get_sg_ids_set_for_ports(self): sg_ids = set([FAKE_SGID, OTHER_SGID]) ports = [self._fake_port(sg_id) for sg_id in sg_ids] self.assertEqual(sg_ids, self.firewall._get_sg_ids_set_for_ports(ports)) def test_remove_sg_members(self): self.firewall.sg_members = self._fake_sg_members([FAKE_SGID, OTHER_SGID]) remote_sgs_to_remove = {_IPv4: set([FAKE_SGID]), _IPv6: set([FAKE_SGID, OTHER_SGID])} self.firewall._remove_sg_members(remote_sgs_to_remove) self.assertIn(OTHER_SGID, self.firewall.sg_members) self.assertNotIn(FAKE_SGID, self.firewall.sg_members) def test_remove_unused_security_group_info_clears_unused_rules(self): self._setup_fake_firewall_members_and_rules(self.firewall) self.firewall.prepare_port_filter(self._fake_port()) # create another SG which won't be referenced by any filtered port fake_sg_rules = self.firewall.sg_rules['fake_sgid'] self.firewall.pre_sg_rules[OTHER_SGID] = fake_sg_rules self.firewall.sg_rules[OTHER_SGID] = fake_sg_rules # call the cleanup function, and check the unused sg_rules are out self.firewall._remove_unused_security_group_info() self.assertNotIn(OTHER_SGID, self.firewall.sg_rules) def test_remove_unused_security_group_info(self): self.firewall.sg_members = {OTHER_SGID: {_IPv4: [], _IPv6: []}} self.firewall.pre_sg_members = self.firewall.sg_members self.firewall.sg_rules = self._fake_sg_rules( remote_groups={_IPv4: [FAKE_SGID], _IPv6: [FAKE_SGID]}) self.firewall.pre_sg_rules = self.firewall.sg_rules port = self._fake_port() self.firewall.filtered_ports['tapfake_dev'] = port self.firewall._remove_unused_security_group_info() self.assertNotIn(OTHER_SGID, self.firewall.sg_members) def test_not_remove_used_security_group_info(self): self.firewall.sg_members = {OTHER_SGID: {_IPv4: [], _IPv6: []}} self.firewall.pre_sg_members = self.firewall.sg_members self.firewall.sg_rules = self._fake_sg_rules( remote_groups={_IPv4: [OTHER_SGID], _IPv6: [OTHER_SGID]}) self.firewall.pre_sg_rules = self.firewall.sg_rules port = self._fake_port() self.firewall.filtered_ports['tapfake_dev'] = port self.firewall._remove_unused_security_group_info() self.assertIn(OTHER_SGID, self.firewall.sg_members) def test_remove_all_unused_info(self): self._setup_fake_firewall_members_and_rules(self.firewall) self.firewall.filtered_ports = {} self.firewall._remove_unused_security_group_info() self.assertFalse(self.firewall.sg_members) self.assertFalse(self.firewall.sg_rules) def test_single_fallback_accept_rule(self): p1, p2 = self._fake_port(), self._fake_port() self.firewall._setup_chains_apply(dict(p1=p1, p2=p2), {}) v4_adds = self.firewall.iptables.ipv4['filter'].add_rule.mock_calls v6_adds = self.firewall.iptables.ipv6['filter'].add_rule.mock_calls sg_chain_v4_accept = [call for call in v4_adds if call == mock.call('sg-chain', '-j ACCEPT')] sg_chain_v6_accept = [call for call in v6_adds if call == mock.call('sg-chain', '-j ACCEPT')] self.assertEqual(1, len(sg_chain_v4_accept)) self.assertEqual(1, len(sg_chain_v6_accept)) def test_remove_port_filter_with_destroy_ipset_chain(self): self.firewall.sg_rules = self._fake_sg_rules() port = self._fake_port() self.firewall.pre_sg_members = {'fake_sgid': { 'IPv4': [], 'IPv6': []}} sg_members = {'IPv4': ['10.0.0.1'], 'IPv6': ['fe80::1']} self.firewall.update_security_group_members('fake_sgid', sg_members) self.firewall.prepare_port_filter(port) self.firewall.filter_defer_apply_on() self.firewall.sg_members = {'fake_sgid': { 'IPv4': [], 'IPv6': []}} self.firewall.pre_sg_members = {'fake_sgid': { 'IPv4': ['10.0.0.1'], 'IPv6': ['fe80::1']}} self.firewall.remove_port_filter(port) self.firewall.filter_defer_apply_off() calls = [ mock.call.set_members('fake_sgid', 'IPv4', ['10.0.0.1']), mock.call.set_members('fake_sgid', 'IPv6', ['fe80::1']), mock.call.get_name('fake_sgid', 'IPv4'), mock.call.set_name_exists('NIPv4fake_sgid'), mock.call.get_name('fake_sgid', 'IPv6'), mock.call.set_name_exists('NIPv6fake_sgid'), mock.call.destroy('fake_sgid', 'IPv4'), mock.call.destroy('fake_sgid', 'IPv6')] self.firewall.ipset.assert_has_calls(calls, any_order=True) def test_filter_defer_apply_off_with_sg_only_ipv6_rule(self): self.firewall.sg_rules = self._fake_sg_rules() self.firewall.pre_sg_rules = self._fake_sg_rules() self.firewall.ipset_chains = {'IPv4fake_sgid': ['10.0.0.2'], 'IPv6fake_sgid': ['fe80::1']} self.firewall.sg_members = {'fake_sgid': { 'IPv4': ['10.0.0.2'], 'IPv6': ['fe80::1']}} self.firewall.pre_sg_members = {'fake_sgid': { 'IPv4': ['10.0.0.2'], 'IPv6': ['fe80::1']}} self.firewall.sg_rules['fake_sgid'].remove( {'direction': 'ingress', 'remote_group_id': 'fake_sgid', 'ethertype': 'IPv4'}) self.firewall.sg_rules.update() self.firewall._defer_apply = True port = self._fake_port() self.firewall.filtered_ports['tapfake_dev'] = port self.firewall._pre_defer_filtered_ports = {} self.firewall._pre_defer_unfiltered_ports = {} self.firewall.filter_defer_apply_off() calls = [mock.call.destroy('fake_sgid', 'IPv4')] self.firewall.ipset.assert_has_calls(calls, True) def test_sg_rule_expansion_with_remote_ips(self): other_ips = ['10.0.0.2', '10.0.0.3', '10.0.0.4'] self.firewall.sg_members = {'fake_sgid': { 'IPv4': [FAKE_IP['IPv4']] + other_ips, 'IPv6': [FAKE_IP['IPv6']]}} port = self._fake_port() rule = self._fake_sg_rule_for_ethertype(_IPv4, FAKE_SGID) rules = self.firewall._expand_sg_rule_with_remote_ips( rule, port, 'ingress') self.assertEqual(list(rules), [dict(list(rule.items()) + [('source_ip_prefix', '%s/32' % ip)]) for ip in other_ips]) def test_build_ipv4v6_mac_ip_list(self): mac_oth = 'ffff-ff0f-ffff' mac_unix = 'FF:FF:FF:0F:FF:FF' ipv4 = FAKE_IP['IPv4'] ipv6 = FAKE_IP['IPv6'] fake_ipv4_pair = [] fake_ipv4_pair.append((mac_unix, ipv4)) fake_ipv6_pair = [] fake_ipv6_pair.append((mac_unix, ipv6)) fake_ipv6_pair.append((mac_unix, 'fe80::fdff:ffff:fe0f:ffff')) mac_ipv4_pairs = [] mac_ipv6_pairs = [] self.firewall._build_ipv4v6_mac_ip_list(mac_oth, ipv4, mac_ipv4_pairs, mac_ipv6_pairs) self.assertEqual(fake_ipv4_pair, mac_ipv4_pairs) self.firewall._build_ipv4v6_mac_ip_list(mac_oth, ipv6, mac_ipv4_pairs, mac_ipv6_pairs) self.assertEqual(fake_ipv6_pair, mac_ipv6_pairs) class OVSHybridIptablesFirewallTestCase(BaseIptablesFirewallTestCase): def setUp(self): super(OVSHybridIptablesFirewallTestCase, self).setUp() self.firewall = iptables_firewall.OVSHybridIptablesFirewallDriver() # initial data has 1, 2, and 9 in use, see RAW_TABLE_OUTPUT above. self._dev_zone_map = {'61634509-31': 2, '8f46cf18-12': 9, '95c24827-02': 2, 'e804433b-61': 1} def test__populate_initial_zone_map(self): self.assertEqual(self._dev_zone_map, self.firewall._device_zone_map) def test__generate_device_zone(self): # initial data has 1, 2, and 9 in use. # we fill from top up first. self.assertEqual(10, self.firewall._generate_device_zone('test')) # once it's maxed out, it scans for gaps self.firewall._device_zone_map['someport'] = ( iptables_firewall.MAX_CONNTRACK_ZONES) for i in range(3, 9): self.assertEqual(i, self.firewall._generate_device_zone(i)) # 9 and 10 are taken so next should be 11 self.assertEqual(11, self.firewall._generate_device_zone('p11')) # take out zone 1 and make sure it's selected self.firewall._device_zone_map.pop('e804433b-61') self.assertEqual(1, self.firewall._generate_device_zone('p1')) # fill it up and then make sure an extra throws an error for i in range(1, 65536): self.firewall._device_zone_map['dev-%s' % i] = i with testtools.ExpectedException(n_exc.CTZoneExhaustedError): self.firewall._find_open_zone() # with it full, try again, this should trigger a cleanup and return 1 self.assertEqual(1, self.firewall._generate_device_zone('p12')) self.assertEqual({'p12': 1}, self.firewall._device_zone_map) def test_get_device_zone(self): # initial data has 1, 2, and 9 in use. self.assertEqual(10, self.firewall.get_device_zone('12345678901234567')) # should have been truncated to 11 chars self._dev_zone_map.update({'12345678901': 10}) self.assertEqual(self._dev_zone_map, self.firewall._device_zone_map)
igor-toga/local-snat
neutron/tests/unit/agent/linux/test_iptables_firewall.py
Python
apache-2.0
86,232
# coding=utf-8 # Copyright 2021 Google Health Research. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Utilities for calculating masks. Mask values are, 1 for values that are *kept* vs 0 for values that are *masked out*. """ import copy import functools from typing import Any, Dict, List, Union from ehr_prediction_modeling import types from ehr_prediction_modeling.utils import batches from ehr_prediction_modeling.utils import label_utils from ehr_prediction_modeling.utils import mask_utils import tensorflow.compat.v1 as tf from ehr_prediction_modeling import configdict class MaskManager: """Mask manager.""" def __init__( self, task_config: configdict.ConfigDict, window_hours: List[int], label_keys: List[str], supported_train_masks: Dict[str, List[str]], supported_eval_masks: Dict[str, List[str]], ): self._task_type = task_config.task_type if self._task_type == types.TaskTypes.READMISSION: self._discard_final_admission = task_config.discard_final_admission # List of hours since event to use for train mask. self._time_since_event_hours_list = task_config.get( "time_since_event_hours_list", []) # Label key for numerical time since event value. Default is time since # admission key. self._time_since_event_label_key = task_config.get( "time_since_event_label_key", label_utils.TSA_LABEL) self._time_buckets_per_day = task_config.get("time_buckets_per_day", None) self._window_hours = window_hours self._label_keys = label_keys self._supported_train_masks = supported_train_masks self._supported_eval_masks = supported_eval_masks self._all_supported_masks = copy.copy(self._supported_train_masks) self._all_supported_masks.update(self._supported_eval_masks) if self._task_type == types.TaskTypes.LAB_REGRESSION: # If there are multiple aggregations for each lab window_hours contains # duplicated values and its length is the real number of targets. self._num_targets = len(window_hours) else: self._num_targets = len(self._label_keys) def _get_component_mask( self, composite_mask_name: str, component_mask_name: str, batch: batches.TFBatch, ) -> Union[Dict[Union[str, int], tf.Tensor], tf.Tensor]: """Gets a mask from a batch of data. Args: composite_mask_name: str, the name of the composite mask. component_mask_name: str, the name of the mask to be extracted. batch: tf.NextQueuedSequenceBatch, containing a batch of data. Returns: Tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets] with the mask value. """ if (component_mask_name not in self._all_supported_masks[composite_mask_name]): raise ValueError( f"Component {component_mask_name} is not part of composite " f"{composite_mask_name}, its components are " f"{self._all_supported_masks[composite_mask_name]}") mask_name_to_fn = { mask_utils.SINCE_EVENT_TRAIN_MASK: self._time_since_event_train_mask, mask_utils.SINCE_EVENT_EVAL_MASK: functools.partial( self._time_since_event_eval_mask, composite_mask_name), mask_utils.AT_DISCHARGE_MASK: self._at_discharge_mask, mask_utils.INTERVAL_MASK: self._interval_mask, mask_utils.PATIENT_MASK: self._patient_mask, mask_utils.END_OF_ADMISSION_MASK: self._end_of_admission_mask, mask_utils.IGNORE_MASK: self._ignore_mask, mask_utils.PADDED_EVENT_MASK: self._padded_event_mask, mask_utils.UNKNOWN_LOOKAHEAD_MASK: self._unknown_lookahead_mask, } if component_mask_name in mask_name_to_fn: return mask_name_to_fn[component_mask_name](batch) else: raise ValueError(f"Unknown component mask {component_mask_name}") def get_masks( self, mask_names: List[str], batch: batches.TFBatch, ) -> Dict[str, tf.Tensor]: """Gets a dict of masks for a given batch. Args: mask_names: list of str, corresponding to composite masks in _supported_train_masks or _supported_eval_masks. batch: tf.NextQueuedSequenceBatch, containing a batch of data. Returns: Dict of str, the mask name, to mask tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets]. The value of the mask mask tensor is the cross-multiplication of the component boolean masks as specified in _supported_train_masks or _supported_eval_masks. """ mask_dict = {} for mask_name in mask_names: mask_dict[mask_name] = self._build_composite_mask_from_components( composite_mask_name=mask_name, batch=batch, ) return mask_dict def _build_composite_mask_from_components(self, composite_mask_name: str, batch: batches.TFBatch) -> None: """Returns a composite mask. The SINCE_EVENT_MASK has a different behavior depending on model mode. During training, its different components (one per `_time_since_event_hours_list`) are summed. During eval, they are kept separate so that it is possible to evaluate at each chosen time after event. Args: composite_mask_name: str. Name of the mask. batch: container for a batch of data Returns: A mask tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets]. The value of the mask mask tensor is the cross-multiplication of the component boolean masks as specified in _supported_train_masks or _supported_eval_masks for the composite_mask_name. """ computed_masks = [] for component_mask_name in self._all_supported_masks[composite_mask_name]: computed_masks.append( self._get_component_mask( composite_mask_name=composite_mask_name, component_mask_name=component_mask_name, batch=batch)) return mask_utils.get_combined_mask(computed_masks) def _time_since_event_eval_mask( self, composite_mask_name: str, batch: batches.TFBatch ) -> tf.Tensor: """Returns mask generated for time since event eval. Args: composite_mask_name: Name of the composite mask this mask is being generated for. Used to parse the hours after event that should be set for the mask. batch: Batch of the data to create a mask for. Returns: A single mask with a positive value for any event at hours since event parsed from the composite mask name. """ hours = mask_utils.get_time_since_event_mask_hours(composite_mask_name) return self._time_since_event_mask(batch, target_hours=hours) def _time_since_event_train_mask( self, batch: batches.TFBatch) -> tf.Tensor: """Returns mask generated for specific times since some event of interest. Mask generated will have a positive value for any hour in self._time_since_event_hours_list that is also positive in the base_mask. Args: batch: Batch of the data to create a mask for. Returns: A single mask with a positive value for any event at hours after some event for every hour in self._time_since_event_hours_list. """ if not self._time_since_event_hours_list: raise ValueError("Time since masks require a non-empty list of " "times that indicate how many hours after the event" " the mask will be nonzero.") time_mask = self._time_since_event_mask( batch=batch, target_hours=self._time_since_event_hours_list[0]) for hours in self._time_since_event_hours_list[1:]: time_mask += self._time_since_event_mask(batch, hours) return time_mask def _time_since_event_mask( self, batch: batches.TFBatch, target_hours: int) -> tf.Tensor: """Mask that is 1 for events at hours since some event of interest. To accommodate shifting between time since event timestamps and the target hours, we take the difference as (time since event - target time) and select only those timesteps which have a difference >=0 (happen at or after the target) and < bucket length (closest time after target). Args: batch: Batch of the data to create a mask for. target_hours: target number of hours since event to set mask to 1. Returns: A single mask with a positive value for any event at target hours after some event. """ if not self._time_buckets_per_day: raise ValueError( "Must specify time_buckets_per_day in the task config if using a " "time since event mask.") time_since_event = self._extract_mask_from_sequence( batch, self._time_since_event_label_key) target_sortable_time = tf.constant( target_hours / 24., dtype=tf.float32) diff_since_target = time_since_event - target_sortable_time after_target_time = tf.cast( tf.greater_equal( diff_since_target, tf.constant( 0., dtype=tf.float32)), tf.float32) # We subtract 1e-6 from the upper bound to account for the case in which # there is a trigger time exactly one bucket away from the target time. Due # to precision issues when the length of a bucket has many decimal places, # this timestamp can be slightly smaller than the exact length of the # bucket, resulting in 2 eligible trigger times instead of 1. less_than_one_bucket_from_target_time = tf.cast( tf.less( diff_since_target, tf.constant( (1. / self._time_buckets_per_day) - 1e-6, dtype=tf.float32)), tf.float32) return after_target_time * less_than_one_bucket_from_target_time def _at_discharge_mask(self, batch: batches.TFBatch) -> tf.Tensor: """Returns 1 for discharge events and 0 for the rest.""" per_target_list = [batch.sequences[mask_utils.AT_DISCHARGE_MASK] ] * self._num_targets # Note that the label 2 represents the final event of an admission that is # also the final episode of a given medical history for which the patient # was discharged. if self._discard_final_admission: # In that case only labels 1 are considered. return tf.cast( tf.equal( tf.stack(per_target_list, axis=3), 1), tf.float32) else: # In that case both labels 1 and 2 are considered. return tf.cast( tf.greater_equal( tf.stack(per_target_list, axis=3), 1), tf.float32) def _interval_mask(self, batch: batches.TFBatch) -> tf.Tensor: return self._extract_mask_from_sequence( batch, label_utils.SEGMENT_LABEL, invert=True, ) def _patient_mask(self, batch: batches.TFBatch) -> tf.Tensor: return self._extract_mask_from_context( batch, label_utils.CENSORED_PATIENT_LABEL, invert=True, ) def _end_of_admission_mask(self, batch: batches.TFBatch) -> tf.Tensor: """Returns 0 for the final event of an admission, and 1 otherwise.""" los_labels = self._extract_mask_from_sequence(batch, label_utils.LOS_LABEL) return tf.cast( tf.not_equal( los_labels, tf.constant(0, dtype=tf.float32)), tf.float32) def _extract_labels(self, batch: batches.TFBatch) -> tf.Tensor: """Extracts the labels denoted by label_keys from the data. Args: batch: containing a batch of data. Returns: Tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets] with the labels for each key given in label_keys. """ return tf.stack( [batch.sequences[label_key] for label_key in self._label_keys], axis=3) def _extract_mask_from_context(self, batch: batches.TFBatch, mask_label_name: str, invert: bool = False) -> tf.Tensor: """Extracts a mask from the batch context. Args: batch: tf.NextQueuedSequenceBatch, containing a batch of data. mask_label_name: string, the name of the label required. invert: bool. whether to invert the mask before returning. Returns: Tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets] with the float mask value. """ per_target_list = self._num_targets * [ tf.expand_dims(batch.context[mask_label_name], -1) ] mask_concat = tf.stack(per_target_list, axis=3) mask_concat = tf.cast(mask_concat, tf.float32) if invert: mask_concat = tf.ones_like( mask_concat, dtype=tf.float32) - mask_concat return tf.cast( mask_concat, dtype=tf.float32) def _extract_mask_from_sequence(self, batch: batches.TFBatch, mask_label_name: str, invert: bool = False) -> tf.Tensor: """Extracts a mask from the sequences in a batch. Args: batch: tf.NextQueuedSequenceBatch, containing a batch of data. mask_label_name: string, the name of the label required. invert: bool, whether to invert the mask before returning. Returns: Tensor in time-major shape wnct [num_unroll, batch_size, channels, num_targets] with the float mask value. """ per_target_list = [batch.sequences[mask_label_name]] * self._num_targets mask_concat = tf.stack(per_target_list, axis=3) mask_concat = tf.cast(mask_concat, tf.float32) if invert: mask_concat = tf.ones_like( mask_concat, dtype=tf.float32) - mask_concat return tf.cast( mask_concat, dtype=tf.float32) def _ignore_mask(self, batch: batches.TFBatch) -> tf.Tensor: """Mask that is set to 0 for outpatient and unknown TOD events.""" return self._extract_mask_from_sequence( batch, label_utils.IGNORE_LABEL, invert=True) def _padded_event_mask(self, batch: batches.TFBatch) -> tf.Tensor: """Mask that is 0 for timestamps less than or equal to 0 i.e. padded.""" timestamps = self._extract_mask_from_sequence(batch, label_utils.TIMESTAMP_KEY) return tf.cast( tf.greater( timestamps, tf.constant(0, dtype=tf.float32)), tf.float32) def _unknown_lookahead_mask(self, batch: batches.TFBatch) -> tf.Tensor: """Extracts a mask to ignore unknown lookaheads from the data.""" if self._task_type == types.TaskTypes.LAB_REGRESSION: targets = self._extract_labels(batch) is_positive = tf.greater( targets, tf.zeros_like(targets)) return tf.cast( is_positive, dtype=tf.float32) else: raise ValueError("UNKNOWN_LOOKAHEAD_MASK is defined only for tasks " f"{types.TaskTypes.LAB_REGRESSION} but the task is " f"{self._task_type}")
google/ehr-predictions
ehr_prediction_modeling/mask_manager.py
Python
apache-2.0
15,792
# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Device logs for DLI powerswitch devices.""" RETURN_CODE = "200\n" ERROR_RETURN_CODE = "409\n" DEFAULT_BEHAVIOR = { "http://123.45.67.89/restapi/config/=version/": { "text": '["1.7.15.0"]', "status_code": "207" }, "http://123.45.67.89/restapi/config/=serial/": { "text": '["ABCD1234"]', "status_code": "207" }, "http://123.45.67.89/restapi/config/=brand_company_name/": { "text": '["Digital Loggers, Inc."]', "status_code": "207" }, "http://123.45.67.89/restapi/config/=brand_name/": { "text": '["Web Power Switch"]', "status_code": "207" }, "http://123.45.67.89/restapi/relay/outlets/=1/state/": { "text": '["true"]', "status_code": "207" }, }
google/gazoo-device
gazoo_device/tests/unit_tests/utils/dli_powerswitch_logs.py
Python
apache-2.0
1,345
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import re import sys if __name__ == '__main__': sys.path.append('../../') import json import logging import sqlite3 from gchelpers.ip.GeoDbManager import GeoDbManager from gchelpers.dt import DateTimeHandler GEO_MANAGER = GeoDbManager() def splitpath(path, n): path_array = re.split('[\\\/]',path) start_index = -(n+1) # Check that path has enough elements if abs(start_index) > len(path_array): new_path = os.path.join(path_array[0],*path_array[1:]) else: new_path = os.path.join(path_array[start_index],*path_array[start_index+1:]) return new_path def RegisterSQLiteFunctions(dbh): sqlite3.enable_callback_tracebacks(True) dbh.create_function("REGEXP", 2, Regexp) dbh.create_function('Basename',1,Basename) dbh.create_function('BasenameN',2,BasenameN) dbh.create_function("GetRegMatch", 3, GetRegMatch) dbh.create_function("GetRegMatchArray", 3, GetRegMatchArray) dbh.create_function("RemoveNewLines", 1, RemoveNewLines) dbh.create_function("DtFormat", 2, DtFormat) dbh.create_function("DtFormatTz", 4, DtFormatTz) if GEO_MANAGER.DB_ATTACHED: dbh.create_function("GetIpInfo", 1, GetIpInfo) def DtFormatTz(dtstringin,newformat,current_tz_str,new_tz_str): if dtstringin: string_out = None # Get object from in string datetime_obj = DateTimeHandler.DatetimeFromString( dtstringin ) # Timezone Conversion new_datetime_obj = DateTimeHandler.ConvertDatetimeTz( datetime_obj, current_tz_str, new_tz_str ) # Format object string_out = DateTimeHandler.StringFromDatetime( new_datetime_obj, newformat ) return string_out return None def DtFormat(dtstringin,newformat): if dtstringin: string_out = None # Get object from in string datetime_obj = DateTimeHandler.DatetimeFromString( dtstringin ) # Format object string_out = DateTimeHandler.StringFromDatetime( datetime_obj, newformat ) return string_out return None def Regexp(pattern,input): if input is None: return False try: if re.search(pattern, input): return True else: return False except Exception as error: print(u'ERROR: {}'.format(str(error))) return False def Basename(fullname): '''Get the base name of a fullname string''' value = '' if fullname: try: value = os.path.basename(fullname) except: value = filename return value def BasenameN(fullname,n): '''Get the base name of a fullname string''' value = '' if fullname is None: return None value = splitpath(fullname,n) return value def GetIpInfo(ip_address): if ip_address is None: return None geo = GEO_MANAGER info = geo.GetIpInfo(ip_address) return json.dumps(info) def RemoveNewLines(input): if input is None: return None input = input.replace("\n", "") input = input.replace("\r", "") return input def GetRegMatch(input,group,pattern): if input is None: return None match = re.search(pattern, input) result = None if match: result = match.group(group) return result def GetRegMatchArray(input,group,pattern): hits = [] if input is None: return json.dumps(hits) for result in re.finditer(pattern, input): hits.append(result.group(group)) if len(hits) > 0: return json.dumps(hits) return json.dumps(hits) def test1(): n = 2 fullname = "Partition 1\\TEST_P1 [NTFS]\\[root]\\testfolder002\\testfolder001\\testfile088.png" splitname = splitpath(fullname,n) print splitname def test2(): n = 2 fullname = "testfolder001\\testfile088.png" splitname = splitpath(fullname,n) print splitname if __name__ == '__main__': test1() test2()
devgc/GcHelpers
gchelpers/db/SqliteCustomFunctions.py
Python
apache-2.0
4,308
from rest_framework import serializers as ser from api.base.utils import absolute_reverse from api.base.serializers import JSONAPISerializer, LinksField, RelationshipField, ShowIfVersion, DevOnly class PreprintProviderSerializer(JSONAPISerializer): filterable_fields = frozenset([ 'name', 'description', 'id', 'domain', 'domain_redirect_enabled' ]) name = ser.CharField(required=True) description = ser.CharField(required=False) id = ser.CharField(max_length=200, source='_id') advisory_board = ser.CharField(required=False) example = ser.CharField(required=False, allow_null=True) domain = ser.CharField(required=False, allow_null=False) domain_redirect_enabled = ser.BooleanField(required=True) subjects_acceptable = ser.JSONField(required=False, allow_null=True) footer_links = ser.CharField(required=False) share_source = ser.CharField(read_only=True) allow_submissions = DevOnly(ser.BooleanField(read_only=True)) additional_providers = DevOnly(ser.ListField(child=ser.CharField(), read_only=True)) preprints = RelationshipField( related_view='preprint_providers:preprints-list', related_view_kwargs={'provider_id': '<_id>'} ) taxonomies = RelationshipField( related_view='preprint_providers:taxonomy-list', related_view_kwargs={'provider_id': '<_id>'} ) licenses_acceptable = RelationshipField( related_view='preprint_providers:license-list', related_view_kwargs={'provider_id': '<_id>'} ) links = LinksField({ 'self': 'get_absolute_url', 'preprints': 'get_preprints_url', 'external_url': 'get_external_url' }) # Deprecated fields header_text = ShowIfVersion( ser.CharField(required=False, default=''), min_version='2.0', max_version='2.3' ) banner_path = ShowIfVersion( ser.CharField(required=False, default=''), min_version='2.0', max_version='2.3' ) logo_path = ShowIfVersion( ser.CharField(required=False, default=''), min_version='2.0', max_version='2.3' ) email_contact = ShowIfVersion( ser.CharField(required=False, allow_null=True), min_version='2.0', max_version='2.3' ) email_support = ShowIfVersion( ser.CharField(required=False, allow_null=True), min_version='2.0', max_version='2.3' ) social_twitter = ShowIfVersion( ser.CharField(required=False, allow_null=True), min_version='2.0', max_version='2.3' ) social_facebook = ShowIfVersion( ser.CharField(required=False, allow_null=True), min_version='2.0', max_version='2.3' ) social_instagram = ShowIfVersion( ser.CharField(required=False, allow_null=True), min_version='2.0', max_version='2.3' ) class Meta: type_ = 'preprint_providers' def get_absolute_url(self, obj): return obj.absolute_api_v2_url def get_preprints_url(self, obj): return absolute_reverse('preprint_providers:preprints-list', kwargs={ 'provider_id': obj._id, 'version': self.context['request'].parser_context['kwargs']['version'] }) def get_external_url(self, obj): return obj.external_url
cwisecarver/osf.io
api/preprint_providers/serializers.py
Python
apache-2.0
3,317
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Middleware provided and used by Horizon. """ import json import logging import time from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME # noqa from django.contrib.auth.views import redirect_to_login # noqa from django.contrib import messages as django_messages from django import http from django.http import HttpResponseRedirect # noqa from django import shortcuts from django.utils.encoding import iri_to_uri # noqa from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from horizon.utils import functions as utils LOG = logging.getLogger(__name__) class HorizonMiddleware(object): """The main Horizon middleware class. Required for use of Horizon.""" logout_reason = None def process_request(self, request): """Adds data necessary for Horizon to function to the request.""" request.horizon = {'dashboard': None, 'panel': None, 'async_messages': []} if not hasattr(request, "user") or not request.user.is_authenticated(): # proceed no further if the current request is already known # not to be authenticated # it is CRITICAL to perform this check as early as possible # to avoid creating too many sessions return None # Activate timezone handling tz = request.session.get('django_timezone') if tz: timezone.activate(tz) # Check for session timeout try: timeout = settings.SESSION_TIMEOUT except AttributeError: timeout = 1800 last_activity = request.session.get('last_activity', None) timestamp = int(time.time()) # If we use cookie-based sessions, check that the cookie size does not # reach the max size accepted by common web browsers. if ( settings.SESSION_ENGINE == 'django.contrib.sessions.backends.signed_cookies' ): max_cookie_size = getattr( settings, 'SESSION_COOKIE_MAX_SIZE', None) session_cookie_name = getattr( settings, 'SESSION_COOKIE_NAME', None) session_key = request.COOKIES.get(session_cookie_name) if max_cookie_size is not None and session_key is not None: cookie_size = sum(( len(key) + len(value) for key, value in request.COOKIES.iteritems() )) if cookie_size >= max_cookie_size: LOG.error( 'Total Cookie size for user_id: %(user_id)s is ' '%(cookie_size)sB >= %(max_cookie_size)sB. ' 'You need to configure file-based or database-backed ' 'sessions instead of cookie-based sessions: ' 'http://docs.openstack.org/developer/horizon/topics/' 'deployment.html#session-storage' % { 'user_id': request.session.get( 'user_id', 'Unknown'), 'cookie_size': cookie_size, 'max_cookie_size': max_cookie_size, } ) if (isinstance(last_activity, int) and (timestamp - last_activity) > timeout): request.session.pop('last_activity') response = HttpResponseRedirect( '%s?next=%s' % (settings.LOGOUT_URL, request.path)) self.logout_reason = _("Session timed out.") utils.add_logout_reason(request, response, self.logout_reason) return response request.session['last_activity'] = timestamp def process_exception(self, request, exception): """Catches internal Horizon exception classes such as NotAuthorized, NotFound and Http302 and handles them gracefully. """ if isinstance(exception, (exceptions.NotAuthorized, exceptions.NotAuthenticated)): auth_url = settings.LOGIN_URL next_url = iri_to_uri(request.get_full_path()) if next_url != auth_url: field_name = REDIRECT_FIELD_NAME else: field_name = None login_url = request.build_absolute_uri(auth_url) response = redirect_to_login(next_url, login_url=login_url, redirect_field_name=field_name) if request.is_ajax(): response_401 = http.HttpResponse(status=401) response_401['X-Horizon-Location'] = response['location'] return response_401 return response # If an internal "NotFound" error gets this far, return a real 404. if isinstance(exception, exceptions.NotFound): raise http.Http404(exception) if isinstance(exception, exceptions.Http302): # TODO(gabriel): Find a way to display an appropriate message to # the user *on* the login form... return shortcuts.redirect(exception.location) def process_response(self, request, response): """Convert HttpResponseRedirect to HttpResponse if request is via ajax to allow ajax request to redirect url """ if request.is_ajax() and hasattr(request, 'horizon'): queued_msgs = request.horizon['async_messages'] if type(response) == http.HttpResponseRedirect: # Drop our messages back into the session as per usual so they # don't disappear during the redirect. Not that we explicitly # use django's messages methods here. for tag, message, extra_tags in queued_msgs: getattr(django_messages, tag)(request, message, extra_tags) if response['location'].startswith(settings.LOGOUT_URL): redirect_response = http.HttpResponse(status=401) # This header is used for handling the logout in JS redirect_response['logout'] = True if self.logout_reason is not None: utils.add_logout_reason( request, redirect_response, self.logout_reason) else: redirect_response = http.HttpResponse() # Copy cookies from HttpResponseRedirect towards HttpResponse for cookie_name, cookie in response.cookies.iteritems(): cookie_kwargs = dict(( (key, value) for key, value in cookie.iteritems() if key in ('max_age', 'expires', 'path', 'domain', 'secure', 'httponly') and value )) redirect_response.set_cookie( cookie_name, cookie.value, **cookie_kwargs) redirect_response['X-Horizon-Location'] = response['location'] return redirect_response if queued_msgs: # TODO(gabriel): When we have an async connection to the # client (e.g. websockets) this should be pushed to the # socket queue rather than being sent via a header. # The header method has notable drawbacks (length limits, # etc.) and is not meant as a long-term solution. response['X-Horizon-Messages'] = json.dumps(queued_msgs) return response
yanheven/console
horizon/middleware.py
Python
apache-2.0
8,472
# Copyright 2021 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Covertype Keras WideDeep Classifier. See additional TFX example pipelines, including the Penguin Pipeline Kubeflow GCP example that this pipeline is based upon: https://github.com/tensorflow/tfx/blob/master/tfx/examples. """ import functools import absl import os from typing import List, Text import tensorflow as tf import tensorflow_model_analysis as tfma import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils import kerastuner from tensorflow_cloud import CloudTuner from tfx.components.trainer.executor import TrainerFnArgs from tfx.components.trainer.fn_args_utils import DataAccessor from tfx.components.tuner.component import TunerFnResult from tfx_bsl.tfxio import dataset_options from models import features from models.keras.constants import ( EPOCHS, TRAIN_BATCH_SIZE, EVAL_BATCH_SIZE, LOCAL_LOG_DIR, ) def _gzip_reader_fn(filenames): """Small utility returning a record reader that can read gzip'ed files.""" return tf.data.TFRecordDataset(filenames, compression_type='GZIP') def _get_serve_tf_examples_fn(model, tf_transform_output): """Returns a function that parses a serialized tf.Example and applies TFT.""" model.tft_layer = tf_transform_output.transform_features_layer() @tf.function def serve_tf_examples_fn(serialized_tf_examples): """Returns the output to be used in the serving signature.""" feature_spec = tf_transform_output.raw_feature_spec() feature_spec.pop(features.LABEL_KEY) parsed_features = tf.io.parse_example(serialized_tf_examples, feature_spec) transformed_features = model.tft_layer(parsed_features) return model(transformed_features) return serve_tf_examples_fn def _input_fn(file_pattern: List[Text], data_accessor: DataAccessor, tf_transform_output: tft.TFTransformOutput, batch_size: int = 200) -> tf.data.Dataset: """Generates features and label for tuning/training. Args: file_pattern: List of paths or patterns of input tfrecord files. data_accessor: DataAccessor for converting input to RecordBatch. tf_transform_output: A TFTransformOutput. batch_size: representing the number of consecutive elements of returned dataset to combine in a single batch. Returns: A dataset that contains (features, indices) tuple where features is a dictionary of Tensors, and indices is a single Tensor of label indices. """ dataset = data_accessor.tf_dataset_factory( file_pattern, dataset_options.TensorFlowDatasetOptions( batch_size=batch_size, label_key=features.transformed_name(features.LABEL_KEY)), tf_transform_output.transformed_metadata.schema) return dataset def _get_hyperparameters() -> kerastuner.HyperParameters: """Returns hyperparameters for building Keras model. This function defines a conditional hyperparameter space and default values that are used to build the model. Args: None. Returns: A kerastuner HyperParameters object. """ hp = kerastuner.HyperParameters() # Defines hyperparameter search space. hp.Float('learning_rate', min_value=1e-4, max_value=1e-2, sampling='log', default=1e-3) hp.Int('n_layers', 1, 2, default=1) # Based on n_layers, search for the optimal number of hidden units in each layer. with hp.conditional_scope('n_layers', 1): hp.Int('n_units_1', min_value=8, max_value=128, step=8, default=8) with hp.conditional_scope('n_layers', 2): hp.Int('n_units_1', min_value=8, max_value=128, step=8, default=8) hp.Int('n_units_2', min_value=8, max_value=128, step=8, default=8) return hp def _build_keras_model(hparams: kerastuner.HyperParameters, tf_transform_output: tft.TFTransformOutput) -> tf.keras.Model: """Creates a Keras WideDeep Classifier model. Args: hparams: Holds HyperParameters for tuning. tf_transform_output: A TFTransformOutput. Returns: A keras Model. """ # Defines deep feature columns and input layers. deep_columns = [ tf.feature_column.numeric_column( key=features.transformed_name(key), shape=()) for key in features.NUMERIC_FEATURE_KEYS ] input_layers = { column.key: tf.keras.layers.Input(name=column.key, shape=(), dtype=tf.float32) for column in deep_columns } # Defines wide feature columns and input layers. categorical_columns = [ tf.feature_column.categorical_column_with_identity( key=features.transformed_name(key), num_buckets=tf_transform_output.num_buckets_for_transformed_feature(features.transformed_name(key)), default_value=0) for key in features.CATEGORICAL_FEATURE_KEYS ] wide_columns = [ tf.feature_column.indicator_column(categorical_column) for categorical_column in categorical_columns ] input_layers.update({ column.categorical_column.key: tf.keras.layers.Input(name=column.categorical_column.key, shape=(), dtype=tf.int32) for column in wide_columns }) # Build Keras model using hparams. deep = tf.keras.layers.DenseFeatures(deep_columns)(input_layers) for n in range(int(hparams.get('n_layers'))): deep = tf.keras.layers.Dense(units=hparams.get('n_units_' + str(n + 1)))(deep) wide = tf.keras.layers.DenseFeatures(wide_columns)(input_layers) output = tf.keras.layers.Dense(features.NUM_CLASSES, activation='softmax')( tf.keras.layers.concatenate([deep, wide])) model = tf.keras.Model(input_layers, output) model.compile( loss='sparse_categorical_crossentropy', optimizer=tf.keras.optimizers.Adam(lr=hparams.get('learning_rate')), metrics=[tf.keras.metrics.SparseCategoricalAccuracy()]) model.summary(print_fn=absl.logging.info) return model # TFX Tuner will call this function. def tuner_fn(fn_args: TrainerFnArgs) -> TunerFnResult: """Build the tuner using CloudTuner (KerasTuner instance). Args: fn_args: Holds args used to train and tune the model as name/value pairs. See https://www.tensorflow.org/tfx/api_docs/python/tfx/components/trainer/fn_args_utils/FnArgs. Returns: A namedtuple contains the following: - tuner: A BaseTuner that will be used for tuning. - fit_kwargs: Args to pass to tuner's run_trial function for fitting the model , e.g., the training and validation dataset. Required args depend on the above tuner's implementation. """ transform_graph = tft.TFTransformOutput(fn_args.transform_graph_path) # Construct a build_keras_model_fn that just takes hyperparams from get_hyperparameters as input. build_keras_model_fn = functools.partial( _build_keras_model, tf_transform_output=transform_graph) # CloudTuner is a subclass of kerastuner.Tuner which inherits from BaseTuner. tuner = CloudTuner( build_keras_model_fn, project_id=fn_args.custom_config['ai_platform_training_args']['project'], region=fn_args.custom_config['ai_platform_training_args']['region'], max_trials=50, hyperparameters=_get_hyperparameters(), objective=kerastuner.Objective('val_sparse_categorical_accuracy', 'max'), directory=fn_args.working_dir) train_dataset = _input_fn( fn_args.train_files, fn_args.data_accessor, transform_graph, batch_size=TRAIN_BATCH_SIZE) eval_dataset = _input_fn( fn_args.eval_files, fn_args.data_accessor, transform_graph, batch_size=EVAL_BATCH_SIZE) return TunerFnResult( tuner=tuner, fit_kwargs={ 'x': train_dataset, 'validation_data': eval_dataset, 'steps_per_epoch': fn_args.train_steps, 'validation_steps': fn_args.eval_steps }) def _copy_tensorboard_logs(local_path: str, gcs_path: str): """Copies Tensorboard logs from a local dir to a GCS location. After training, batch copy Tensorboard logs locally to a GCS location. This can result in faster pipeline runtimes over streaming logs per batch to GCS that can get bottlenecked when streaming large volumes. Args: local_path: local filesystem directory uri. gcs_path: cloud filesystem directory uri. Returns: None. """ pattern = '{}/*/events.out.tfevents.*'.format(local_path) local_files = tf.io.gfile.glob(pattern) gcs_log_files = [local_file.replace(local_path, gcs_path) for local_file in local_files] for local_file, gcs_file in zip(local_files, gcs_log_files): tf.io.gfile.copy(local_file, gcs_file) # TFX Trainer will call this function. def run_fn(fn_args: TrainerFnArgs): """Train the model based on given args. Args: fn_args: Holds args used to train and tune the model as name/value pairs. See https://www.tensorflow.org/tfx/api_docs/python/tfx/components/trainer/fn_args_utils/FnArgs. """ tf_transform_output = tft.TFTransformOutput(fn_args.transform_output) train_dataset = _input_fn( fn_args.train_files, fn_args.data_accessor, tf_transform_output, TRAIN_BATCH_SIZE) eval_dataset = _input_fn( fn_args.eval_files, fn_args.data_accessor, tf_transform_output, EVAL_BATCH_SIZE) if fn_args.hyperparameters: hparams = kerastuner.HyperParameters.from_config(fn_args.hyperparameters) else: # This is a shown case when hyperparameters is decided and Tuner is removed # from the pipeline. User can also inline the hyperparameters directly in # _build_keras_model. hparams = _get_hyperparameters() absl.logging.info('HyperParameters for training: %s' % hparams.get_config()) # Distribute training over multiple replicas on the same machine. mirrored_strategy = tf.distribute.MirroredStrategy() with mirrored_strategy.scope(): model = _build_keras_model( hparams=hparams, tf_transform_output=tf_transform_output) tensorboard_callback = tf.keras.callbacks.TensorBoard( log_dir=LOCAL_LOG_DIR, update_freq='batch') model.fit( train_dataset, epochs=EPOCHS, steps_per_epoch=fn_args.train_steps, validation_data=eval_dataset, validation_steps=fn_args.eval_steps, verbose=2, callbacks=[tensorboard_callback]) signatures = { 'serving_default': _get_serve_tf_examples_fn(model, tf_transform_output).get_concrete_function( tf.TensorSpec( shape=[None], dtype=tf.string, name='examples')), } model.save(fn_args.serving_model_dir, save_format='tf', signatures=signatures) _copy_tensorboard_logs(LOCAL_LOG_DIR, fn_args.serving_model_dir + '/logs')
GoogleCloudPlatform/mlops-on-gcp
immersion/guided_projects/guided_project_2_solution/models/keras/model.py
Python
apache-2.0
11,500
# Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from django.utils.translation import ugettext_lazy as _ from horizon_lib import tabs class OverviewTab(tabs.Tab): name = _("Overview") slug = "overview" template_name = ("project/volumes/volumes/_detail_overview.html") def get_context_data(self, request): return {"volume": self.tab_group.kwargs['volume']} class VolumeDetailTabs(tabs.TabGroup): slug = "volume_details" tabs = (OverviewTab,)
mrunge/openstack_horizon
openstack_horizon/dashboards/project/volumes/volumes/tabs.py
Python
apache-2.0
1,035
import pytest from api.base.settings.defaults import API_BASE from osf_tests.factories import ( ProjectFactory, AuthUserFactory, PrivateLinkFactory, ) from osf.utils import permissions @pytest.fixture() def admin(): return AuthUserFactory() @pytest.fixture() def base_url(): return '/{}nodes/'.format(API_BASE) @pytest.fixture() def read_contrib(): return AuthUserFactory() @pytest.fixture() def write_contrib(): return AuthUserFactory() @pytest.fixture() def valid_contributors(admin, read_contrib, write_contrib): return [ admin._id, read_contrib._id, write_contrib._id, ] @pytest.fixture() def private_node_one(admin, read_contrib, write_contrib): private_node_one = ProjectFactory( is_public=False, creator=admin, title='Private One') private_node_one.add_contributor( read_contrib, permissions=[ permissions.READ], save=True) private_node_one.add_contributor( write_contrib, permissions=[ permissions.READ, permissions.WRITE], save=True) return private_node_one @pytest.fixture() def private_node_one_anonymous_link(private_node_one): private_node_one_anonymous_link = PrivateLinkFactory(anonymous=True) private_node_one_anonymous_link.nodes.add(private_node_one) private_node_one_anonymous_link.save() return private_node_one_anonymous_link @pytest.fixture() def private_node_one_private_link(private_node_one): private_node_one_private_link = PrivateLinkFactory(anonymous=False) private_node_one_private_link.nodes.add(private_node_one) private_node_one_private_link.save() return private_node_one_private_link @pytest.fixture() def private_node_one_url(private_node_one): return '/{}nodes/{}/'.format(API_BASE, private_node_one._id) @pytest.fixture() def private_node_two(admin, read_contrib, write_contrib): private_node_two = ProjectFactory( is_public=False, creator=admin, title='Private Two') private_node_two.add_contributor( read_contrib, permissions=[permissions.READ], save=True) private_node_two.add_contributor( write_contrib, permissions=[ permissions.READ, permissions.WRITE], save=True) return private_node_two @pytest.fixture() def private_node_two_url(private_node_two): return '/{}nodes/{}/'.format(API_BASE, private_node_two._id) @pytest.fixture() def public_node_one(admin, read_contrib, write_contrib): public_node_one = ProjectFactory( is_public=True, creator=admin, title='Public One') public_node_one.add_contributor( read_contrib, permissions=[permissions.READ], save=True) public_node_one.add_contributor( write_contrib, permissions=[ permissions.READ, permissions.WRITE], save=True) return public_node_one @pytest.fixture() def public_node_one_anonymous_link(public_node_one): public_node_one_anonymous_link = PrivateLinkFactory(anonymous=True) public_node_one_anonymous_link.nodes.add(public_node_one) public_node_one_anonymous_link.save() return public_node_one_anonymous_link @pytest.fixture() def public_node_one_private_link(public_node_one): public_node_one_private_link = PrivateLinkFactory(anonymous=False) public_node_one_private_link.nodes.add(public_node_one) public_node_one_private_link.save() return public_node_one_private_link @pytest.fixture() def public_node_one_url(public_node_one): return '/{}nodes/{}/'.format(API_BASE, public_node_one._id) @pytest.fixture() def public_node_two(admin, read_contrib, write_contrib): public_node_two = ProjectFactory( is_public=True, creator=admin, title='Public Two') public_node_two.add_contributor( read_contrib, permissions=[permissions.READ], save=True) public_node_two.add_contributor( write_contrib, permissions=[ permissions.READ, permissions.WRITE], save=True) return public_node_two @pytest.fixture() def public_node_two_url(public_node_two): return '/{}nodes/{}/'.format(API_BASE, public_node_two._id) @pytest.mark.django_db @pytest.mark.enable_quickfiles_creation @pytest.mark.usefixtures( 'admin', 'read_contrib', 'write_contrib', 'valid_contributors', 'private_node_one', 'private_node_one_anonymous_link', 'private_node_one_private_link', 'private_node_one_url', 'private_node_two', 'private_node_two_url', 'public_node_one', 'public_node_one_anonymous_link', 'public_node_one_private_link', 'public_node_one_url', 'public_node_two', 'public_node_two_url') class TestNodeDetailViewOnlyLinks: def test_private_node( self, app, admin, read_contrib, valid_contributors, private_node_one, private_node_one_url, private_node_one_private_link, private_node_one_anonymous_link, public_node_one_url, public_node_one_private_link, public_node_one_anonymous_link): # test_private_node_with_link_works_when_using_link res_normal = app.get(private_node_one_url, auth=read_contrib.auth) assert res_normal.status_code == 200 res_linked = app.get( private_node_one_url, {'view_only': private_node_one_private_link.key}) assert res_linked.status_code == 200 assert res_linked.json['data']['attributes']['current_user_permissions'] == [ 'read'] # Remove any keys that will be different for view-only responses res_normal_json = res_normal.json res_linked_json = res_linked.json user_can_comment = res_normal_json['data']['attributes'].pop( 'current_user_can_comment') view_only_can_comment = res_linked_json['data']['attributes'].pop( 'current_user_can_comment') assert user_can_comment assert not view_only_can_comment # test_private_node_with_link_unauthorized_when_not_using_link res = app.get(private_node_one_url, expect_errors=True) assert res.status_code == 401 # test_private_node_with_link_anonymous_does_not_expose_contributor_id res = app.get(private_node_one_url, { 'view_only': private_node_one_anonymous_link.key, 'embed': 'contributors', }) assert res.status_code == 200 embeds = res.json['data'].get('embeds', None) assert embeds is None or 'contributors' not in embeds # test_private_node_with_link_non_anonymous_does_expose_contributor_id res = app.get(private_node_one_url, { 'view_only': private_node_one_private_link.key, 'embed': 'contributors', }) assert res.status_code == 200 contributors = res.json['data']['embeds']['contributors']['data'] for contributor in contributors: assert contributor['id'].split('-')[1] in valid_contributors # test_private_node_logged_in_with_anonymous_link_does_not_expose_contributor_id res = app.get(private_node_one_url, { 'view_only': private_node_one_private_link.key, 'embed': 'contributors', }, auth=admin.auth) assert res.status_code == 200 contributors = res.json['data']['embeds']['contributors']['data'] for contributor in contributors: assert contributor['id'].split('-')[1] in valid_contributors # test_public_node_with_link_anonymous_does_not_expose_user_id res = app.get(public_node_one_url, { 'view_only': public_node_one_anonymous_link.key, 'embed': 'contributors', }) assert res.status_code == 200 embeds = res.json['data'].get('embeds', None) assert embeds is None or 'contributors' not in embeds # test_public_node_with_link_non_anonymous_does_expose_contributor_id res = app.get(public_node_one_url, { 'view_only': public_node_one_private_link.key, 'embed': 'contributors', }) assert res.status_code == 200 contributors = res.json['data']['embeds']['contributors']['data'] for contributor in contributors: assert contributor['id'].split('-')[1] in valid_contributors # test_public_node_with_link_unused_does_expose_contributor_id res = app.get(public_node_one_url, { 'embed': 'contributors', }) assert res.status_code == 200 contributors = res.json['data']['embeds']['contributors']['data'] for contributor in contributors: assert contributor['id'].split('-')[1] in valid_contributors # test_view_only_link_does_not_grant_write_permission payload = { 'data': { 'attributes': { 'title': 'Cannot touch this'}, 'id': private_node_one._id, 'type': 'nodes', } } res = app.patch_json_api(private_node_one_url, payload, { 'view_only': private_node_one_private_link.key, }, expect_errors=True) assert res.status_code == 401 # test_view_only_link_from_anther_project_does_not_grant_view_permission res = app.get(private_node_one_url, { 'view_only': public_node_one_private_link.key, }, expect_errors=True) assert res.status_code == 401 # test_private_project_logs_with_anonymous_link_does_not_expose_user_id res = app.get(private_node_one_url + 'logs/', { 'view_only': str(private_node_one_anonymous_link.key), }) assert res.status_code == 200 body = res.body for id in valid_contributors: assert id not in body # test_private_project_with_anonymous_link_does_not_expose_registrations_or_forks res = app.get(private_node_one_url, { 'view_only': private_node_one_anonymous_link.key, }) assert res.status_code == 200 attributes = res.json['data']['attributes'] relationships = res.json['data']['relationships'] if 'embeds' in res.json['data']: embeds = res.json['data']['embeds'] else: embeds = {} assert 'current_user_can_comment' not in attributes assert 'citation' not in relationships assert 'custom_citation' not in attributes assert 'node_license' not in attributes assert 'registrations' not in relationships assert 'forks' not in relationships assert 'registrations' not in embeds assert 'forks' not in embeds # test_deleted_anonymous_VOL_gives_401_for_unauthorized private_node_one_anonymous_link.is_deleted = True private_node_one_anonymous_link.save() res = app.get(private_node_one_url, { 'view_only': private_node_one_anonymous_link.key, }, expect_errors=True) assert res.status_code == 401 # test_deleted_anonymous_VOL_does_not_anonymize_data_for_authorized res = app.get(private_node_one_url, { 'view_only': private_node_one_anonymous_link.key, }, auth=admin.auth) assert res.status_code == 200 assert 'anonymous' not in res.json['meta'] attributes = res.json['data']['attributes'] relationships = res.json['data']['relationships'] assert 'current_user_can_comment' in attributes assert 'citation' in relationships assert 'custom_citation' in attributes assert 'node_license' in attributes assert 'forks' in relationships # test_bad_view_only_link_does_not_modify_permissions res = app.get(private_node_one_url + 'logs/', { 'view_only': 'thisisnotarealprivatekey', }, expect_errors=True) assert res.status_code == 401 res = app.get(private_node_one_url + 'logs/', { 'view_only': 'thisisnotarealprivatekey', }, auth=admin.auth) assert res.status_code == 200 # test_view_only_key_in_relationships_links res = app.get( private_node_one_url, {'view_only': private_node_one_private_link.key}) assert res.status_code == 200 res_relationships = res.json['data']['relationships'] for key, value in res_relationships.items(): if isinstance(value, list): for relationship in value: links = relationship.get('links', {}) if links.get('related', False): assert private_node_one_private_link.key in links['related']['href'] if links.get('self', False): assert private_node_one_private_link.key in links['self']['href'] else: links = value.get('links', {}) if links.get('related', False): assert private_node_one_private_link.key in links['related']['href'] if links.get('self', False): assert private_node_one_private_link.key in links['self']['href'] # test_view_only_key_in_self_and_html_links res = app.get( private_node_one_url, {'view_only': private_node_one_private_link.key}) assert res.status_code == 200 links = res.json['data']['links'] assert private_node_one_private_link.key in links['self'] assert private_node_one_private_link.key in links['html'] @pytest.mark.django_db @pytest.mark.enable_quickfiles_creation @pytest.mark.usefixtures( 'admin', 'read_contrib', 'write_contrib', 'valid_contributors', 'private_node_one', 'private_node_one_anonymous_link', 'private_node_one_private_link', 'private_node_one_url', 'private_node_two', 'private_node_two_url', 'public_node_one', 'public_node_one_anonymous_link', 'public_node_one_private_link', 'public_node_one_url', 'public_node_two', 'public_node_two_url') class TestNodeListViewOnlyLinks: def test_node_list_view_only_links( self, app, valid_contributors, private_node_one, private_node_one_private_link, private_node_one_anonymous_link, base_url): # test_private_link_does_not_show_node_in_list res = app.get(base_url, { 'view_only': private_node_one_private_link.key, }) assert res.status_code == 200 nodes = res.json['data'] node_ids = [] for node in nodes: node_ids.append(node['id']) assert private_node_one._id not in node_ids # test_anonymous_link_does_not_show_contributor_id_in_node_list res = app.get(base_url, { 'view_only': private_node_one_anonymous_link.key, 'embed': 'contributors', }) assert res.status_code == 200 nodes = res.json['data'] assertions = 0 for node in nodes: embeds = node.get('embeds', None) assert embeds is None or 'contributors' not in embeds assertions += 1 assert assertions != 0 # test_non_anonymous_link_does_show_contributor_id_in_node_list res = app.get(base_url, { 'view_only': private_node_one_private_link.key, 'embed': 'contributors', }) assert res.status_code == 200 nodes = res.json['data'] assertions = 0 for node in nodes: contributors = node['embeds']['contributors']['data'] for contributor in contributors: assertions += 1 assert contributor['id'].split('-')[1] in valid_contributors assert assertions != 0
pattisdr/osf.io
api_tests/nodes/views/test_view_only_query_parameter.py
Python
apache-2.0
15,854
from direct.directnotify import DirectNotifyGlobal from toontown.toonbase import ToontownBattleGlobals from toontown.suit import SuitDNA BattleExperienceAINotify = DirectNotifyGlobal.directNotify.newCategory('BattleExprienceAI') def getSkillGained(toonSkillPtsGained, toonId, track): exp = 0 expList = toonSkillPtsGained.get(toonId, None) if expList != None: exp = expList[track] return int(exp + 0.5) def getBattleExperience(numToons, activeToons, toonExp, toonSkillPtsGained, toonOrigQuests, toonItems, toonOrigMerits, toonMerits, toonParts, suitsKilled, helpfulToonsList = None): if helpfulToonsList == None: BattleExperienceAINotify.warning('=============\nERROR ERROR helpfulToons=None in assignRewards , tell Red') p = [] for k in xrange(numToons): toon = None if k < len(activeToons): toonId = activeToons[k] toon = simbase.air.doId2do.get(toonId) if toon == None: p.append(-1) p.append([0, 0, 0, 0, 0, 0, 0]) p.append([0, 0, 0, 0, 0, 0, 0]) p.append([]) p.append([]) p.append([]) p.append([0, 0, 0, 0]) p.append([0, 0, 0, 0]) p.append([0, 0, 0, 0]) else: p.append(toonId) origExp = toonExp[toonId] earnedExp = [] for i in xrange(len(ToontownBattleGlobals.Tracks)): earnedExp.append(getSkillGained(toonSkillPtsGained, toonId, i)) p.append(origExp) p.append(earnedExp) origQuests = toonOrigQuests.get(toonId, []) p.append(origQuests) items = toonItems.get(toonId, ([], [])) p.append(items[0]) p.append(items[1]) origMerits = toonOrigMerits.get(toonId, []) p.append(origMerits) merits = toonMerits.get(toonId, [0, 0, 0, 0]) p.append(merits) parts = toonParts.get(toonId, [0, 0, 0, 0]) p.append(parts) deathList = [] toonIndices = {} for i in xrange(len(activeToons)): toonIndices[activeToons[i]] = i for deathRecord in suitsKilled: level = deathRecord['level'] type = deathRecord['type'] if deathRecord['isVP'] or deathRecord['isCFO']: level = 0 typeNum = SuitDNA.suitDepts.index(deathRecord['track']) else: typeNum = SuitDNA.suitHeadTypes.index(type) involvedToonIds = deathRecord['activeToons'] toonBits = 0 for toonId in involvedToonIds: if toonId in toonIndices: toonBits |= 1 << toonIndices[toonId] flags = 0 if deathRecord['isSkelecog']: flags |= ToontownBattleGlobals.DLF_SKELECOG if deathRecord['isForeman']: flags |= ToontownBattleGlobals.DLF_FOREMAN if deathRecord['isVP']: flags |= ToontownBattleGlobals.DLF_VP if deathRecord['isCFO']: flags |= ToontownBattleGlobals.DLF_CFO if deathRecord['isSupervisor']: flags |= ToontownBattleGlobals.DLF_SUPERVISOR if deathRecord['isVirtual']: flags |= ToontownBattleGlobals.DLF_VIRTUAL if 'hasRevies' in deathRecord and deathRecord['hasRevives']: flags |= ToontownBattleGlobals.DLF_REVIVES deathList.extend([typeNum, level, toonBits, flags]) p.append(deathList) uberStats = getToonUberStatus(activeToons, numToons) p.append(uberStats) if helpfulToonsList == None: helpfulToonsList = [] p.append(helpfulToonsList) return p def getToonUberStatus(toons, numToons): fieldList = [] uberIndex = ToontownBattleGlobals.LAST_REGULAR_GAG_LEVEL + 1 for toonId in toons: toonList = [] toon = simbase.air.doId2do.get(toonId) if toon == None: fieldList.append(-1) else: for trackIndex in xrange(ToontownBattleGlobals.MAX_TRACK_INDEX + 1): toonList.append(toon.inventory.numItem(trackIndex, uberIndex)) fieldList.append(ToontownBattleGlobals.encodeUber(toonList)) lenDif = numToons - len(toons) if lenDif > 0: for index in xrange(lenDif): fieldList.append(-1) return fieldList def assignRewards(activeToons, toonSkillPtsGained, suitsKilled, zoneId, helpfulToons = None): if helpfulToons == None: BattleExperienceAINotify.warning('=============\nERROR ERROR helpfulToons=None in assignRewards , tell Red') activeToonList = [] for t in activeToons: toon = simbase.air.doId2do.get(t) if toon != None: activeToonList.append(toon) for toon in activeToonList: for i in xrange(len(ToontownBattleGlobals.Tracks)): uberIndex = ToontownBattleGlobals.LAST_REGULAR_GAG_LEVEL + 1 exp = getSkillGained(toonSkillPtsGained, toon.doId, i) needed = ToontownBattleGlobals.Levels[i][ToontownBattleGlobals.LAST_REGULAR_GAG_LEVEL + 1] + ToontownBattleGlobals.UberSkill hasUber = 0 totalExp = exp + toon.experience.getExp(i) if toon.inventory.numItem(i, uberIndex) > 0: hasUber = 1 if totalExp >= needed or totalExp >= ToontownBattleGlobals.MaxSkill: if toon.inventory.totalProps < toon.getMaxCarry() and not hasUber: uberLevel = ToontownBattleGlobals.LAST_REGULAR_GAG_LEVEL + 1 toon.inventory.addItem(i, uberLevel) toon.experience.setExp(i, ToontownBattleGlobals.Levels[i][ToontownBattleGlobals.LAST_REGULAR_GAG_LEVEL + 1]) else: toon.experience.setExp(i, ToontownBattleGlobals.MaxSkill) else: if exp > 0: newGagList = toon.experience.getNewGagIndexList(i, exp) toon.experience.addExp(i, amount=exp) toon.inventory.addItemWithList(i, newGagList) toon.b_setExperience(toon.experience.makeNetString()) toon.d_setInventory(toon.inventory.makeNetString()) toon.b_setAnimState('victory', 1) if simbase.air.config.GetBool('battle-passing-no-credit', True): # Check if the toon was a helpful toon if helpfulToons and toon.doId in helpfulToons: # Notify the AI that the toon killed cogs simbase.air.questManager.toonKilledCogs(toon, suitsKilled, zoneId, activeToonList) simbase.air.cogPageManager.toonKilledCogs(toon, suitsKilled, zoneId) # Looks like the toon wasnt too helpful... else: BattleExperienceAINotify.debug('toon=%d unhelpful not getting killed cog quest credit' % toon.doId)
linktlh/Toontown-journey
toontown/battle/BattleExperienceAI.py
Python
apache-2.0
7,187
import subprocess, os, zipfile, requests ## Function Download def download(url, fichier): pass fileName = fichier req = requests.get(url) file = open(fileName, 'wb') for chunk in req.iter_content(100000): file.write(chunk) file.close() print("The download is finish !") ## Function Unzip def unzip(source , destination): with zipfile.ZipFile(source) as zf: zf.extractall(destination) nameinfo = open("name.info", "r") ServerName = nameinfo.readline().rstrip() Version = nameinfo.readline().rstrip() VersionServer = nameinfo.readline().rstrip() nameinfo.close() subprocess.call(['java', '-jar', ServerName +'.jar']) fichier = open("eula.txt", "w") fichier.write("eula = true") fichier.close() if not os.path.exists("world"): print("Whitch type of Minecraft server you want to create ?") a=input("[1] Pre-Build (Map and Plugin) Spigot Server [2] Blanc Spigot Server [3] Semi-Build (Plugin pre installed, blanc map) : ") if a == '1': print(VersionServer) if VersionServer == '1.9' or VersionServer == '1.8' or VersionServer == '1.7.10': download('https://raw.githubusercontent.com/dinnozap/MinecraftServerMaker/master/world.zip', 'world.zip') unzip('world.zip', '') if not os.path.exists("plugins"): os.mkdir("plugins") download('https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/Essentials/target/Essentials-2.x-SNAPSHOT.jar', 'plugins/essentials.jar') download('https://www.spigotmc.org/resources/sexymotd.2474/download?version=73466', 'plugins/motd.jar') subprocess.call(['java', '-jar', ServerName +'.jar']) elif a=='2': subprocess.call(['java', '-jar', ServerName +'.jar']) elif a=='3': if not os.path.exists("plugins"): os.mkdir("plugins") download('https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/Essentials/target/Essentials-2.x-SNAPSHOT.jar', 'plugins/essentials.jar') download('https://www.spigotmc.org/resources/sexymotd.2474/download?version=73466', 'plugins/motd.jar') subprocess.call(['java', '-jar', ServerName +'.jar'])
dinnozap/MinecraftServerMaker
launch.py
Python
apache-2.0
2,078
#!/usr/bin/python # Copyright (c) 2010 OpenStack, LLC. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import setuptools from glance.openstack.common import setup from glance.version import version_info as version requires = setup.parse_requirements() depend_links = setup.parse_dependency_links() setuptools.setup( name='glance', version=version.canonical_version_string(always=True), description='The Glance project provides services for discovering, ' 'registering, and retrieving virtual machine images', license='Apache License (2.0)', author='OpenStack', author_email='openstack@lists.launchpad.net', url='http://glance.openstack.org/', packages=setuptools.find_packages(exclude=['bin']), test_suite='nose.collector', cmdclass=setup.get_cmdclass(), include_package_data=True, install_requires=requires, dependency_links=depend_links, classifiers=[ 'Development Status :: 4 - Beta', 'License :: OSI Approved :: Apache Software License', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python :: 2.6', 'Environment :: No Input/Output (Daemon)', ], scripts=['bin/glance', 'bin/glance-api', 'bin/glance-cache-prefetcher', 'bin/glance-cache-pruner', 'bin/glance-cache-manage', 'bin/glance-cache-cleaner', 'bin/glance-control', 'bin/glance-manage', 'bin/glance-registry', 'bin/glance-replicator', 'bin/glance-scrubber'], py_modules=[])
tylertian/Openstack
openstack F/glance/setup.py
Python
apache-2.0
2,108
# coding: utf-8 import random from PIL import Image from PIL import ImageDraw from PIL import ImageFont import sys import os # how many pictures to generate num = 10 if len(sys.argv) > 1: num = int(sys.argv[1]) def genline(text, font, filename): ''' generate one line ''' w, h = font.getsize(text) image = Image.new('RGB', (w + 15, h + 15), 'white') brush = ImageDraw.Draw(image) brush.text((8, 5), text, font=font, fill=(0, 0, 0)) image.save(filename + '.jpg') with open(filename + '.txt', 'w') as f: f.write(text) f.close() if __name__ == '__main__': if not os.path.isdir('./lines/'): os.mkdir('./lines/') for i in range(num): fontname = './fonts/simkai.ttf' fontsize = 24 font = ImageFont.truetype(fontname, fontsize) text = str(random.randint(1000000000, 9999999999)) text = text + str(random.randint(1000000000, 9999999999)) #text = str(random.randint(1000, 9999)) filename = './lines/' + str(i + 1) genline(text, font, filename) pass
Halfish/lstm-ctc-ocr
1_generateImage.py
Python
apache-2.0
1,086
# Copyright 2013-2016 DataStax, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from itertools import islice, cycle, groupby, repeat import logging from random import randint from threading import Lock import socket from cassandra import ConsistencyLevel, OperationTimedOut log = logging.getLogger(__name__) class HostDistance(object): """ A measure of how "distant" a node is from the client, which may influence how the load balancer distributes requests and how many connections are opened to the node. """ IGNORED = -1 """ A node with this distance should never be queried or have connections opened to it. """ LOCAL = 0 """ Nodes with ``LOCAL`` distance will be preferred for operations under some load balancing policies (such as :class:`.DCAwareRoundRobinPolicy`) and will have a greater number of connections opened against them by default. This distance is typically used for nodes within the same datacenter as the client. """ REMOTE = 1 """ Nodes with ``REMOTE`` distance will be treated as a last resort by some load balancing policies (such as :class:`.DCAwareRoundRobinPolicy`) and will have a smaller number of connections opened against them by default. This distance is typically used for nodes outside of the datacenter that the client is running in. """ class HostStateListener(object): def on_up(self, host): """ Called when a node is marked up. """ raise NotImplementedError() def on_down(self, host): """ Called when a node is marked down. """ raise NotImplementedError() def on_add(self, host): """ Called when a node is added to the cluster. The newly added node should be considered up. """ raise NotImplementedError() def on_remove(self, host): """ Called when a node is removed from the cluster. """ raise NotImplementedError() class LoadBalancingPolicy(HostStateListener): """ Load balancing policies are used to decide how to distribute requests among all possible coordinator nodes in the cluster. In particular, they may focus on querying "near" nodes (those in a local datacenter) or on querying nodes who happen to be replicas for the requested data. You may also use subclasses of :class:`.LoadBalancingPolicy` for custom behavior. """ _hosts_lock = None def __init__(self): self._hosts_lock = Lock() def distance(self, host): """ Returns a measure of how remote a :class:`~.pool.Host` is in terms of the :class:`.HostDistance` enums. """ raise NotImplementedError() def populate(self, cluster, hosts): """ This method is called to initialize the load balancing policy with a set of :class:`.Host` instances before its first use. The `cluster` parameter is an instance of :class:`.Cluster`. """ raise NotImplementedError() def make_query_plan(self, working_keyspace=None, query=None): """ Given a :class:`~.query.Statement` instance, return a iterable of :class:`.Host` instances which should be queried in that order. A generator may work well for custom implementations of this method. Note that the `query` argument may be :const:`None` when preparing statements. `working_keyspace` should be the string name of the current keyspace, as set through :meth:`.Session.set_keyspace()` or with a ``USE`` statement. """ raise NotImplementedError() def check_supported(self): """ This will be called after the cluster Metadata has been initialized. If the load balancing policy implementation cannot be supported for some reason (such as a missing C extension), this is the point at which it should raise an exception. """ pass class RoundRobinPolicy(LoadBalancingPolicy): """ A subclass of :class:`.LoadBalancingPolicy` which evenly distributes queries across all nodes in the cluster, regardless of what datacenter the nodes may be in. This load balancing policy is used by default. """ _live_hosts = frozenset(()) def populate(self, cluster, hosts): self._live_hosts = frozenset(hosts) if len(hosts) <= 1: self._position = 0 else: self._position = randint(0, len(hosts) - 1) def distance(self, host): return HostDistance.LOCAL def make_query_plan(self, working_keyspace=None, query=None): # not thread-safe, but we don't care much about lost increments # for the purposes of load balancing pos = self._position self._position += 1 hosts = self._live_hosts length = len(hosts) if length: pos %= length return islice(cycle(hosts), pos, pos + length) else: return [] def on_up(self, host): with self._hosts_lock: self._live_hosts = self._live_hosts.union((host, )) def on_down(self, host): with self._hosts_lock: self._live_hosts = self._live_hosts.difference((host, )) def on_add(self, host): with self._hosts_lock: self._live_hosts = self._live_hosts.union((host, )) def on_remove(self, host): with self._hosts_lock: self._live_hosts = self._live_hosts.difference((host, )) class DCAwareRoundRobinPolicy(LoadBalancingPolicy): """ Similar to :class:`.RoundRobinPolicy`, but prefers hosts in the local datacenter and only uses nodes in remote datacenters as a last resort. """ local_dc = None used_hosts_per_remote_dc = 0 def __init__(self, local_dc='', used_hosts_per_remote_dc=0): """ The `local_dc` parameter should be the name of the datacenter (such as is reported by ``nodetool ring``) that should be considered local. If not specified, the driver will choose a local_dc based on the first host among :attr:`.Cluster.contact_points` having a valid DC. If relying on this mechanism, all specified contact points should be nodes in a single, local DC. `used_hosts_per_remote_dc` controls how many nodes in each remote datacenter will have connections opened against them. In other words, `used_hosts_per_remote_dc` hosts will be considered :attr:`~.HostDistance.REMOTE` and the rest will be considered :attr:`~.HostDistance.IGNORED`. By default, all remote hosts are ignored. """ self.local_dc = local_dc self.used_hosts_per_remote_dc = used_hosts_per_remote_dc self._dc_live_hosts = {} self._position = 0 self._contact_points = [] LoadBalancingPolicy.__init__(self) def _dc(self, host): return host.datacenter or self.local_dc def populate(self, cluster, hosts): for dc, dc_hosts in groupby(hosts, lambda h: self._dc(h)): self._dc_live_hosts[dc] = tuple(set(dc_hosts)) if not self.local_dc: self._contact_points = cluster.contact_points_resolved self._position = randint(0, len(hosts) - 1) if hosts else 0 def distance(self, host): dc = self._dc(host) if dc == self.local_dc: return HostDistance.LOCAL if not self.used_hosts_per_remote_dc: return HostDistance.IGNORED else: dc_hosts = self._dc_live_hosts.get(dc) if not dc_hosts: return HostDistance.IGNORED if host in list(dc_hosts)[:self.used_hosts_per_remote_dc]: return HostDistance.REMOTE else: return HostDistance.IGNORED def make_query_plan(self, working_keyspace=None, query=None): # not thread-safe, but we don't care much about lost increments # for the purposes of load balancing pos = self._position self._position += 1 local_live = self._dc_live_hosts.get(self.local_dc, ()) pos = (pos % len(local_live)) if local_live else 0 for host in islice(cycle(local_live), pos, pos + len(local_live)): yield host # the dict can change, so get candidate DCs iterating over keys of a copy other_dcs = [dc for dc in self._dc_live_hosts.copy().keys() if dc != self.local_dc] for dc in other_dcs: remote_live = self._dc_live_hosts.get(dc, ()) for host in remote_live[:self.used_hosts_per_remote_dc]: yield host def on_up(self, host): # not worrying about threads because this will happen during # control connection startup/refresh if not self.local_dc and host.datacenter: if host.address in self._contact_points: self.local_dc = host.datacenter log.info("Using datacenter '%s' for DCAwareRoundRobinPolicy (via host '%s'); " "if incorrect, please specify a local_dc to the constructor, " "or limit contact points to local cluster nodes" % (self.local_dc, host.address)) del self._contact_points dc = self._dc(host) with self._hosts_lock: current_hosts = self._dc_live_hosts.get(dc, ()) if host not in current_hosts: self._dc_live_hosts[dc] = current_hosts + (host, ) def on_down(self, host): dc = self._dc(host) with self._hosts_lock: current_hosts = self._dc_live_hosts.get(dc, ()) if host in current_hosts: hosts = tuple(h for h in current_hosts if h != host) if hosts: self._dc_live_hosts[dc] = hosts else: del self._dc_live_hosts[dc] def on_add(self, host): self.on_up(host) def on_remove(self, host): self.on_down(host) class TokenAwarePolicy(LoadBalancingPolicy): """ A :class:`.LoadBalancingPolicy` wrapper that adds token awareness to a child policy. This alters the child policy's behavior so that it first attempts to send queries to :attr:`~.HostDistance.LOCAL` replicas (as determined by the child policy) based on the :class:`.Statement`'s :attr:`~.Statement.routing_key`. Once those hosts are exhausted, the remaining hosts in the child policy's query plan will be used. If no :attr:`~.Statement.routing_key` is set on the query, the child policy's query plan will be used as is. """ _child_policy = None _cluster_metadata = None def __init__(self, child_policy): self._child_policy = child_policy def populate(self, cluster, hosts): self._cluster_metadata = cluster.metadata self._child_policy.populate(cluster, hosts) def check_supported(self): if not self._cluster_metadata.can_support_partitioner(): raise RuntimeError( '%s cannot be used with the cluster partitioner (%s) because ' 'the relevant C extension for this driver was not compiled. ' 'See the installation instructions for details on building ' 'and installing the C extensions.' % (self.__class__.__name__, self._cluster_metadata.partitioner)) def distance(self, *args, **kwargs): return self._child_policy.distance(*args, **kwargs) def make_query_plan(self, working_keyspace=None, query=None): if query and query.keyspace: keyspace = query.keyspace else: keyspace = working_keyspace child = self._child_policy if query is None: for host in child.make_query_plan(keyspace, query): yield host else: routing_key = query.routing_key if routing_key is None or keyspace is None: for host in child.make_query_plan(keyspace, query): yield host else: replicas = self._cluster_metadata.get_replicas(keyspace, routing_key) for replica in replicas: if replica.is_up and \ child.distance(replica) == HostDistance.LOCAL: yield replica for host in child.make_query_plan(keyspace, query): # skip if we've already listed this host if host not in replicas or \ child.distance(host) == HostDistance.REMOTE: yield host def on_up(self, *args, **kwargs): return self._child_policy.on_up(*args, **kwargs) def on_down(self, *args, **kwargs): return self._child_policy.on_down(*args, **kwargs) def on_add(self, *args, **kwargs): return self._child_policy.on_add(*args, **kwargs) def on_remove(self, *args, **kwargs): return self._child_policy.on_remove(*args, **kwargs) class WhiteListRoundRobinPolicy(RoundRobinPolicy): """ A subclass of :class:`.RoundRobinPolicy` which evenly distributes queries across all nodes in the cluster, regardless of what datacenter the nodes may be in, but only if that node exists in the list of allowed nodes This policy is addresses the issue described in https://datastax-oss.atlassian.net/browse/JAVA-145 Where connection errors occur when connection attempts are made to private IP addresses remotely """ def __init__(self, hosts): """ The `hosts` parameter should be a sequence of hosts to permit connections to. """ self._allowed_hosts = hosts self._allowed_hosts_resolved = [endpoint[4][0] for a in self._allowed_hosts for endpoint in socket.getaddrinfo(a, None, socket.AF_UNSPEC, socket.SOCK_STREAM)] RoundRobinPolicy.__init__(self) def populate(self, cluster, hosts): self._live_hosts = frozenset(h for h in hosts if h.address in self._allowed_hosts_resolved) if len(hosts) <= 1: self._position = 0 else: self._position = randint(0, len(hosts) - 1) def distance(self, host): if host.address in self._allowed_hosts_resolved: return HostDistance.LOCAL else: return HostDistance.IGNORED def on_up(self, host): if host.address in self._allowed_hosts_resolved: RoundRobinPolicy.on_up(self, host) def on_add(self, host): if host.address in self._allowed_hosts_resolved: RoundRobinPolicy.on_add(self, host) class ConvictionPolicy(object): """ A policy which decides when hosts should be considered down based on the types of failures and the number of failures. If custom behavior is needed, this class may be subclassed. """ def __init__(self, host): """ `host` is an instance of :class:`.Host`. """ self.host = host def add_failure(self, connection_exc): """ Implementations should return :const:`True` if the host should be convicted, :const:`False` otherwise. """ raise NotImplementedError() def reset(self): """ Implementations should clear out any convictions or state regarding the host. """ raise NotImplementedError() class SimpleConvictionPolicy(ConvictionPolicy): """ The default implementation of :class:`ConvictionPolicy`, which simply marks a host as down after the first failure of any kind. """ def add_failure(self, connection_exc): return not isinstance(connection_exc, OperationTimedOut) def reset(self): pass class ReconnectionPolicy(object): """ This class and its subclasses govern how frequently an attempt is made to reconnect to nodes that are marked as dead. If custom behavior is needed, this class may be subclassed. """ def new_schedule(self): """ This should return a finite or infinite iterable of delays (each as a floating point number of seconds) inbetween each failed reconnection attempt. Note that if the iterable is finite, reconnection attempts will cease once the iterable is exhausted. """ raise NotImplementedError() class ConstantReconnectionPolicy(ReconnectionPolicy): """ A :class:`.ReconnectionPolicy` subclass which sleeps for a fixed delay inbetween each reconnection attempt. """ def __init__(self, delay, max_attempts=64): """ `delay` should be a floating point number of seconds to wait inbetween each attempt. `max_attempts` should be a total number of attempts to be made before giving up, or :const:`None` to continue reconnection attempts forever. The default is 64. """ if delay < 0: raise ValueError("delay must not be negative") if max_attempts is not None and max_attempts < 0: raise ValueError("max_attempts must not be negative") self.delay = delay self.max_attempts = max_attempts def new_schedule(self): if self.max_attempts: return repeat(self.delay, self.max_attempts) return repeat(self.delay) class ExponentialReconnectionPolicy(ReconnectionPolicy): """ A :class:`.ReconnectionPolicy` subclass which exponentially increases the length of the delay inbetween each reconnection attempt up to a set maximum delay. """ # TODO: max_attempts is 64 to preserve legacy default behavior # consider changing to None in major release to prevent the policy # giving up forever def __init__(self, base_delay, max_delay, max_attempts=64): """ `base_delay` and `max_delay` should be in floating point units of seconds. `max_attempts` should be a total number of attempts to be made before giving up, or :const:`None` to continue reconnection attempts forever. The default is 64. """ if base_delay < 0 or max_delay < 0: raise ValueError("Delays may not be negative") if max_delay < base_delay: raise ValueError("Max delay must be greater than base delay") if max_attempts is not None and max_attempts < 0: raise ValueError("max_attempts must not be negative") self.base_delay = base_delay self.max_delay = max_delay self.max_attempts = max_attempts def new_schedule(self): i = 0 while self.max_attempts is None or i < self.max_attempts: yield min(self.base_delay * (2 ** i), self.max_delay) i += 1 class WriteType(object): """ For usage with :class:`.RetryPolicy`, this describe a type of write operation. """ SIMPLE = 0 """ A write to a single partition key. Such writes are guaranteed to be atomic and isolated. """ BATCH = 1 """ A write to multiple partition keys that used the distributed batch log to ensure atomicity. """ UNLOGGED_BATCH = 2 """ A write to multiple partition keys that did not use the distributed batch log. Atomicity for such writes is not guaranteed. """ COUNTER = 3 """ A counter write (for one or multiple partition keys). Such writes should not be replayed in order to avoid overcount. """ BATCH_LOG = 4 """ The initial write to the distributed batch log that Cassandra performs internally before a BATCH write. """ CAS = 5 """ A lighweight-transaction write, such as "DELETE ... IF EXISTS". """ WriteType.name_to_value = { 'SIMPLE': WriteType.SIMPLE, 'BATCH': WriteType.BATCH, 'UNLOGGED_BATCH': WriteType.UNLOGGED_BATCH, 'COUNTER': WriteType.COUNTER, 'BATCH_LOG': WriteType.BATCH_LOG, 'CAS': WriteType.CAS } class RetryPolicy(object): """ A policy that describes whether to retry, rethrow, or ignore coordinator timeout and unavailable failures. These are failures reported from the server side. Timeouts are configured by `settings in cassandra.yaml <https://github.com/apache/cassandra/blob/cassandra-2.1.4/conf/cassandra.yaml#L568-L584>`_. Unavailable failures occur when the coordinator cannot acheive the consistency level for a request. For further information see the method descriptions below. To specify a default retry policy, set the :attr:`.Cluster.default_retry_policy` attribute to an instance of this class or one of its subclasses. To specify a retry policy per query, set the :attr:`.Statement.retry_policy` attribute to an instance of this class or one of its subclasses. If custom behavior is needed for retrying certain operations, this class may be subclassed. """ RETRY = 0 """ This should be returned from the below methods if the operation should be retried on the same connection. """ RETHROW = 1 """ This should be returned from the below methods if the failure should be propagated and no more retries attempted. """ IGNORE = 2 """ This should be returned from the below methods if the failure should be ignored but no more retries should be attempted. """ RETRY_NEXT_HOST = 3 """ This should be returned from the below methods if the operation should be retried on another connection. """ def on_read_timeout(self, query, consistency, required_responses, received_responses, data_retrieved, retry_num): """ This is called when a read operation times out from the coordinator's perspective (i.e. a replica did not respond to the coordinator in time). It should return a tuple with two items: one of the class enums (such as :attr:`.RETRY`) and a :class:`.ConsistencyLevel` to retry the operation at or :const:`None` to keep the same consistency level. `query` is the :class:`.Statement` that timed out. `consistency` is the :class:`.ConsistencyLevel` that the operation was attempted at. The `required_responses` and `received_responses` parameters describe how many replicas needed to respond to meet the requested consistency level and how many actually did respond before the coordinator timed out the request. `data_retrieved` is a boolean indicating whether any of those responses contained data (as opposed to just a digest). `retry_num` counts how many times the operation has been retried, so the first time this method is called, `retry_num` will be 0. By default, operations will be retried at most once, and only if a sufficient number of replicas responded (with data digests). """ if retry_num != 0: return self.RETHROW, None elif received_responses >= required_responses and not data_retrieved: return self.RETRY, consistency else: return self.RETHROW, None def on_write_timeout(self, query, consistency, write_type, required_responses, received_responses, retry_num): """ This is called when a write operation times out from the coordinator's perspective (i.e. a replica did not respond to the coordinator in time). `query` is the :class:`.Statement` that timed out. `consistency` is the :class:`.ConsistencyLevel` that the operation was attempted at. `write_type` is one of the :class:`.WriteType` enums describing the type of write operation. The `required_responses` and `received_responses` parameters describe how many replicas needed to acknowledge the write to meet the requested consistency level and how many replicas actually did acknowledge the write before the coordinator timed out the request. `retry_num` counts how many times the operation has been retried, so the first time this method is called, `retry_num` will be 0. By default, failed write operations will retried at most once, and they will only be retried if the `write_type` was :attr:`~.WriteType.BATCH_LOG`. """ if retry_num != 0: return self.RETHROW, None elif write_type == WriteType.BATCH_LOG: return self.RETRY, consistency else: return self.RETHROW, None def on_unavailable(self, query, consistency, required_replicas, alive_replicas, retry_num): """ This is called when the coordinator node determines that a read or write operation cannot be successful because the number of live replicas are too low to meet the requested :class:`.ConsistencyLevel`. This means that the read or write operation was never forwared to any replicas. `query` is the :class:`.Statement` that failed. `consistency` is the :class:`.ConsistencyLevel` that the operation was attempted at. `required_replicas` is the number of replicas that would have needed to acknowledge the operation to meet the requested consistency level. `alive_replicas` is the number of replicas that the coordinator considered alive at the time of the request. `retry_num` counts how many times the operation has been retried, so the first time this method is called, `retry_num` will be 0. By default, no retries will be attempted and the error will be re-raised. """ return (self.RETRY_NEXT_HOST, consistency) if retry_num == 0 else (self.RETHROW, None) class FallthroughRetryPolicy(RetryPolicy): """ A retry policy that never retries and always propagates failures to the application. """ def on_read_timeout(self, *args, **kwargs): return self.RETHROW, None def on_write_timeout(self, *args, **kwargs): return self.RETHROW, None def on_unavailable(self, *args, **kwargs): return self.RETHROW, None class DowngradingConsistencyRetryPolicy(RetryPolicy): """ A retry policy that sometimes retries with a lower consistency level than the one initially requested. **BEWARE**: This policy may retry queries using a lower consistency level than the one initially requested. By doing so, it may break consistency guarantees. In other words, if you use this retry policy, there are cases (documented below) where a read at :attr:`~.QUORUM` *may not* see a preceding write at :attr:`~.QUORUM`. Do not use this policy unless you have understood the cases where this can happen and are ok with that. It is also recommended to subclass this class so that queries that required a consistency level downgrade can be recorded (so that repairs can be made later, etc). This policy implements the same retries as :class:`.RetryPolicy`, but on top of that, it also retries in the following cases: * On a read timeout: if the number of replicas that responded is greater than one but lower than is required by the requested consistency level, the operation is retried at a lower consistency level. * On a write timeout: if the operation is an :attr:`~.UNLOGGED_BATCH` and at least one replica acknowledged the write, the operation is retried at a lower consistency level. Furthermore, for other write types, if at least one replica acknowledged the write, the timeout is ignored. * On an unavailable exception: if at least one replica is alive, the operation is retried at a lower consistency level. The reasoning behind this retry policy is as follows: if, based on the information the Cassandra coordinator node returns, retrying the operation with the initially requested consistency has a chance to succeed, do it. Otherwise, if based on that information we know the initially requested consistency level cannot be achieved currently, then: * For writes, ignore the exception (thus silently failing the consistency requirement) if we know the write has been persisted on at least one replica. * For reads, try reading at a lower consistency level (thus silently failing the consistency requirement). In other words, this policy implements the idea that if the requested consistency level cannot be achieved, the next best thing for writes is to make sure the data is persisted, and that reading something is better than reading nothing, even if there is a risk of reading stale data. """ def _pick_consistency(self, num_responses): if num_responses >= 3: return self.RETRY, ConsistencyLevel.THREE elif num_responses >= 2: return self.RETRY, ConsistencyLevel.TWO elif num_responses >= 1: return self.RETRY, ConsistencyLevel.ONE else: return self.RETHROW, None def on_read_timeout(self, query, consistency, required_responses, received_responses, data_retrieved, retry_num): if retry_num != 0: return self.RETHROW, None elif received_responses < required_responses: return self._pick_consistency(received_responses) elif not data_retrieved: return self.RETRY, consistency else: return self.RETHROW, None def on_write_timeout(self, query, consistency, write_type, required_responses, received_responses, retry_num): if retry_num != 0: return self.RETHROW, None if write_type in (WriteType.SIMPLE, WriteType.BATCH, WriteType.COUNTER): if received_responses > 0: # persisted on at least one replica return self.IGNORE, None else: return self.RETHROW, None elif write_type == WriteType.UNLOGGED_BATCH: return self._pick_consistency(received_responses) elif write_type == WriteType.BATCH_LOG: return self.RETRY, consistency return self.RETHROW, None def on_unavailable(self, query, consistency, required_replicas, alive_replicas, retry_num): if retry_num != 0: return self.RETHROW, None else: return self._pick_consistency(alive_replicas) class AddressTranslator(object): """ Interface for translating cluster-defined endpoints. The driver discovers nodes using server metadata and topology change events. Normally, the endpoint defined by the server is the right way to connect to a node. In some environments, these addresses may not be reachable, or not preferred (public vs. private IPs in cloud environments, suboptimal routing, etc). This interface allows for translating from server defined endpoints to preferred addresses for driver connections. *Note:* :attr:`~Cluster.contact_points` provided while creating the :class:`~.Cluster` instance are not translated using this mechanism -- only addresses received from Cassandra nodes are. """ def translate(self, addr): """ Accepts the node ip address, and returns a translated address to be used connecting to this node. """ raise NotImplementedError class IdentityTranslator(AddressTranslator): """ Returns the endpoint with no translation """ def translate(self, addr): return addr
kishkaru/python-driver
cassandra/policies.py
Python
apache-2.0
32,311
# Copyright 2016 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """TF-Slim grouped API. Please see README.md for details and usage.""" # pylint: disable=unused-import # Collapse tf-slim into a single namespace. from inception.slim import inception_model as inception from inception.slim import models as models from inception.slim import losses from inception.slim import ops from inception.slim import scopes from inception.slim import variables from inception.slim.scopes import arg_scope
wenwei202/terngrad
terngrad/inception/slim/slim.py
Python
apache-2.0
1,101
from funkybomb import Template, Text from application.util import route from templates import documentation from templates.util import template @route('/docs/integrations') @template(documentation.tmpl) async def docs_integrations_home(req): tmpl = Template() tmpl.p + 'Coming soon.' return { 'content': tmpl, 'headline': Text('Integrations') } @route('/docs/integrations/flask') @template(documentation.tmpl) async def docs_integrations_flask(req): tmpl = Template() tmpl.p + 'Coming soon.' return { 'content': tmpl, 'headline': Text('Integrating with Flask') }
glennyonemitsu/funkybomb
website/handlers/docs/integrations.py
Python
apache-2.0
634
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import json import sys import unittest from unittest import mock from unittest.mock import patch import kubernetes.client.models as k8s import pendulum import pytest from kubernetes.client.api_client import ApiClient from kubernetes.client.rest import ApiException from airflow.exceptions import AirflowException from airflow.kubernetes import kube_client from airflow.kubernetes.pod import Port from airflow.kubernetes.pod_runtime_info_env import PodRuntimeInfoEnv from airflow.kubernetes.secret import Secret from airflow.kubernetes.volume import Volume from airflow.kubernetes.volume_mount import VolumeMount from airflow.models import DAG, TaskInstance from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator from airflow.providers.cncf.kubernetes.utils.pod_launcher import PodLauncher from airflow.providers.cncf.kubernetes.utils.xcom_sidecar import PodDefaults from airflow.utils import timezone from airflow.utils.state import State from airflow.version import version as airflow_version from kubernetes_tests.test_base import EXECUTOR # noinspection DuplicatedCode def create_context(task): dag = DAG(dag_id="dag") tzinfo = pendulum.timezone("Europe/Amsterdam") execution_date = timezone.datetime(2016, 1, 1, 1, 0, 0, tzinfo=tzinfo) task_instance = TaskInstance(task=task, execution_date=execution_date) task_instance.xcom_push = mock.Mock() return { "dag": dag, "ts": execution_date.isoformat(), "task": task, "ti": task_instance, "task_instance": task_instance, } # noinspection DuplicatedCode,PyUnusedLocal @pytest.mark.skipif(EXECUTOR != 'KubernetesExecutor', reason="Only runs on KubernetesExecutor") class TestKubernetesPodOperatorSystem(unittest.TestCase): def get_current_task_name(self): # reverse test name to make pod name unique (it has limited length) return "_" + unittest.TestCase.id(self).replace(".", "_")[::-1] def setUp(self): self.maxDiff = None self.api_client = ApiClient() self.expected_pod = { 'apiVersion': 'v1', 'kind': 'Pod', 'metadata': { 'namespace': 'default', 'name': mock.ANY, 'annotations': {}, 'labels': { 'foo': 'bar', 'kubernetes_pod_operator': 'True', 'airflow_version': airflow_version.replace('+', '-'), 'execution_date': '2016-01-01T0100000100-a2f50a31f', 'dag_id': 'dag', 'task_id': 'task', 'try_number': '1', }, }, 'spec': { 'affinity': {}, 'containers': [ { 'image': 'ubuntu:16.04', 'args': ["echo 10"], 'command': ["bash", "-cx"], 'env': [], 'envFrom': [], 'resources': {}, 'name': 'base', 'ports': [], 'volumeMounts': [], } ], 'hostNetwork': False, 'imagePullSecrets': [], 'initContainers': [], 'nodeSelector': {}, 'restartPolicy': 'Never', 'securityContext': {}, 'tolerations': [], 'volumes': [], }, } def tearDown(self): client = kube_client.get_kube_client(in_cluster=False) client.delete_collection_namespaced_pod(namespace="default") @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.start_pod") @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.monitor_pod") @mock.patch("airflow.kubernetes.kube_client.get_kube_client") def test_image_pull_secrets_correctly_set(self, mock_client, monitor_mock, start_mock): fake_pull_secrets = "fakeSecret" k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, image_pull_secrets=fake_pull_secrets, cluster_context='default', ) monitor_mock.return_value = (State.SUCCESS, None, None) context = create_context(k) k.execute(context=context) assert start_mock.call_args[0][0].spec.image_pull_secrets == [ k8s.V1LocalObjectReference(name=fake_pull_secrets) ] def test_working_pod(self): k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) assert self.expected_pod['spec'] == actual_pod['spec'] assert self.expected_pod['metadata']['labels'] == actual_pod['metadata']['labels'] def test_pod_node_selectors(self): node_selectors = {'beta.kubernetes.io/os': 'linux'} k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, node_selectors=node_selectors, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['nodeSelector'] = node_selectors assert self.expected_pod == actual_pod def test_pod_resources(self): resources = { 'limit_cpu': 0.25, 'limit_memory': '64Mi', 'limit_ephemeral_storage': '2Gi', 'request_cpu': '250m', 'request_memory': '64Mi', 'request_ephemeral_storage': '1Gi', } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, resources=resources, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['containers'][0]['resources'] = { 'requests': {'memory': '64Mi', 'cpu': '250m', 'ephemeral-storage': '1Gi'}, 'limits': {'memory': '64Mi', 'cpu': 0.25, 'ephemeral-storage': '2Gi'}, } assert self.expected_pod == actual_pod def test_pod_affinity(self): affinity = { 'nodeAffinity': { 'requiredDuringSchedulingIgnoredDuringExecution': { 'nodeSelectorTerms': [ { 'matchExpressions': [ {'key': 'beta.kubernetes.io/os', 'operator': 'In', 'values': ['linux']} ] } ] } } } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, affinity=affinity, ) context = create_context(k) k.execute(context=context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['affinity'] = affinity assert self.expected_pod == actual_pod def test_port(self): port = Port('http', 80) k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ports=[port], ) context = create_context(k) k.execute(context=context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['containers'][0]['ports'] = [{'name': 'http', 'containerPort': 80}] assert self.expected_pod == actual_pod def test_volume_mount(self): with patch.object(PodLauncher, 'log') as mock_logger: volume_mount = VolumeMount( 'test-volume', mount_path='/tmp/test_volume', sub_path=None, read_only=False ) volume_config = {'persistentVolumeClaim': {'claimName': 'test-volume'}} volume = Volume(name='test-volume', configs=volume_config) args = [ "echo \"retrieved from mount\" > /tmp/test_volume/test.txt " "&& cat /tmp/test_volume/test.txt" ] k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=args, labels={"foo": "bar"}, volume_mounts=[volume_mount], volumes=[volume], is_delete_operator_pod=False, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ) context = create_context(k) k.execute(context=context) mock_logger.info.assert_any_call('retrieved from mount') actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['containers'][0]['args'] = args self.expected_pod['spec']['containers'][0]['volumeMounts'] = [ {'name': 'test-volume', 'mountPath': '/tmp/test_volume', 'readOnly': False} ] self.expected_pod['spec']['volumes'] = [ {'name': 'test-volume', 'persistentVolumeClaim': {'claimName': 'test-volume'}} ] assert self.expected_pod == actual_pod def test_run_as_user_root(self): security_context = { 'securityContext': { 'runAsUser': 0, } } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, security_context=security_context, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['securityContext'] = security_context assert self.expected_pod == actual_pod def test_run_as_user_non_root(self): security_context = { 'securityContext': { 'runAsUser': 1000, } } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, security_context=security_context, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['securityContext'] = security_context assert self.expected_pod == actual_pod def test_fs_group(self): security_context = { 'securityContext': { 'fsGroup': 1000, } } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, security_context=security_context, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['securityContext'] = security_context assert self.expected_pod == actual_pod def test_faulty_service_account(self): bad_service_account_name = "foobar" k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, startup_timeout_seconds=5, service_account_name=bad_service_account_name, ) with pytest.raises(ApiException): context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['serviceAccountName'] = bad_service_account_name assert self.expected_pod == actual_pod def test_pod_failure(self): """ Tests that the task fails when a pod reports a failure """ bad_internal_command = ["foobar 10 "] k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=bad_internal_command, labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ) with pytest.raises(AirflowException): context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['containers'][0]['args'] = bad_internal_command assert self.expected_pod == actual_pod def test_xcom_push(self): return_value = '{"foo": "bar"\n, "buzz": 2}' args = [f'echo \'{return_value}\' > /airflow/xcom/return.json'] k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=args, labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=True, ) context = create_context(k) assert k.execute(context) == json.loads(return_value) actual_pod = self.api_client.sanitize_for_serialization(k.pod) volume = self.api_client.sanitize_for_serialization(PodDefaults.VOLUME) volume_mount = self.api_client.sanitize_for_serialization(PodDefaults.VOLUME_MOUNT) container = self.api_client.sanitize_for_serialization(PodDefaults.SIDECAR_CONTAINER) self.expected_pod['spec']['containers'][0]['args'] = args self.expected_pod['spec']['containers'][0]['volumeMounts'].insert(0, volume_mount) self.expected_pod['spec']['volumes'].insert(0, volume) self.expected_pod['spec']['containers'].append(container) assert self.expected_pod == actual_pod @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.start_pod") @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.monitor_pod") @mock.patch("airflow.kubernetes.kube_client.get_kube_client") def test_envs_from_configmaps(self, mock_client, mock_monitor, mock_start): # GIVEN configmap = 'test-configmap' # WHEN k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, configmaps=[configmap], ) # THEN mock_monitor.return_value = (State.SUCCESS, None, None) context = create_context(k) k.execute(context) assert mock_start.call_args[0][0].spec.containers[0].env_from == [ k8s.V1EnvFromSource(config_map_ref=k8s.V1ConfigMapEnvSource(name=configmap)) ] @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.start_pod") @mock.patch("airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher.monitor_pod") @mock.patch("airflow.kubernetes.kube_client.get_kube_client") def test_envs_from_secrets(self, mock_client, monitor_mock, start_mock): # GIVEN secret_ref = 'secret_name' secrets = [Secret('env', None, secret_ref)] # WHEN k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], secrets=secrets, labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ) # THEN monitor_mock.return_value = (State.SUCCESS, None, None) context = create_context(k) k.execute(context) assert start_mock.call_args[0][0].spec.containers[0].env_from == [ k8s.V1EnvFromSource(secret_ref=k8s.V1SecretEnvSource(name=secret_ref)) ] def test_env_vars(self): # WHEN k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], env_vars={ "ENV1": "val1", "ENV2": "val2", }, pod_runtime_info_envs=[PodRuntimeInfoEnv("ENV3", "status.podIP")], labels={"foo": "bar"}, name="test", task_id="task", in_cluster=False, do_xcom_push=False, ) context = create_context(k) k.execute(context) # THEN actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['containers'][0]['env'] = [ {'name': 'ENV1', 'value': 'val1'}, {'name': 'ENV2', 'value': 'val2'}, {'name': 'ENV3', 'valueFrom': {'fieldRef': {'fieldPath': 'status.podIP'}}}, ] assert self.expected_pod == actual_pod def test_pod_template_file_with_overrides_system(self): fixture = sys.path[0] + '/tests/kubernetes/basic_pod.yaml' k = KubernetesPodOperator( task_id="task" + self.get_current_task_name(), labels={"foo": "bar", "fizz": "buzz"}, env_vars={"env_name": "value"}, in_cluster=False, pod_template_file=fixture, do_xcom_push=True, ) context = create_context(k) result = k.execute(context) assert result is not None assert k.pod.metadata.labels == { 'fizz': 'buzz', 'foo': 'bar', 'airflow_version': mock.ANY, 'dag_id': 'dag', 'execution_date': mock.ANY, 'kubernetes_pod_operator': 'True', 'task_id': mock.ANY, 'try_number': '1', } assert k.pod.spec.containers[0].env == [k8s.V1EnvVar(name="env_name", value="value")] assert result == {"hello": "world"} def test_init_container(self): # GIVEN volume_mounts = [ k8s.V1VolumeMount(mount_path='/etc/foo', name='test-volume', sub_path=None, read_only=True) ] init_environments = [ k8s.V1EnvVar(name='key1', value='value1'), k8s.V1EnvVar(name='key2', value='value2'), ] init_container = k8s.V1Container( name="init-container", image="ubuntu:16.04", env=init_environments, volume_mounts=volume_mounts, command=["bash", "-cx"], args=["echo 10"], ) volume_config = {'persistentVolumeClaim': {'claimName': 'test-volume'}} volume = Volume(name='test-volume', configs=volume_config) expected_init_container = { 'name': 'init-container', 'image': 'ubuntu:16.04', 'command': ['bash', '-cx'], 'args': ['echo 10'], 'env': [{'name': 'key1', 'value': 'value1'}, {'name': 'key2', 'value': 'value2'}], 'volumeMounts': [{'mountPath': '/etc/foo', 'name': 'test-volume', 'readOnly': True}], } k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, name="test", task_id="task", volumes=[volume], init_containers=[init_container], in_cluster=False, do_xcom_push=False, ) context = create_context(k) k.execute(context) actual_pod = self.api_client.sanitize_for_serialization(k.pod) self.expected_pod['spec']['initContainers'] = [expected_init_container] self.expected_pod['spec']['volumes'] = [ {'name': 'test-volume', 'persistentVolumeClaim': {'claimName': 'test-volume'}} ] assert self.expected_pod == actual_pod
dhuang/incubator-airflow
kubernetes_tests/test_kubernetes_pod_operator_backcompat.py
Python
apache-2.0
23,072
# coding=utf-8 # Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Classes for building distributions.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from absl import logging import attr import numpy as np from typing import Sequence @attr.s class Distribution(object): """Base distribution class. Inheriting classes should fill in the sample method and initialize dim. """ dim = attr.ib(init=False) def sample(self, rng): raise NotImplementedError def _check_sum_to_one(instance, attribute, value): """Raises ValueError if the value does not sum to one.""" del instance, attribute # Unused. value = np.array(value) if not np.isclose(np.sum(value), 1): raise ValueError("Array must sum to one. Got %s." % np.sum(value)) def _check_nonnegative(instance, attribute, value): """Raises ValueError if the value elements are negative.""" del instance, attribute # Unused. value = np.array(value) if np.any(value < 0): raise ValueError("Array must be nonnegative. Got %s." % value) def _check_in_zero_one_range(instance, attribute, value): """Raises ValueError if value is not in [0, 1].""" del instance, attribute # Unused. value = np.array(value) if np.any(value < 0) or np.any(value > 1): raise ValueError("Value must be in [0, 1]. Got %s." % value) @attr.s class Mixture(Distribution): """A mixture distribution.""" components = attr.ib(factory=list) # type: Sequence[Distribution] weights = attr.ib( factory=list, validator=[_check_sum_to_one, _check_nonnegative]) # type: Sequence[float] def sample(self, rng): logging.debug("Sampling from a mixture with %d components. Weights: %s", len(self.components), self.weights) component = rng.choice(self.components, p=self.weights) return component.sample(rng) def __attrs_post_init__(self): for component in self.components: if component.dim != self.components[0].dim: raise ValueError("Components do not have the same dimensionality.") self.dim = self.components[0].dim @attr.s class Gaussian(Distribution): """A Gaussian Distribution.""" mean = attr.ib() std = attr.ib() def __attrs_post_init__(self): self.dim = len(self.mean) def sample(self, rng): return rng.normal(self.mean, self.std) @attr.s class Bernoulli(Distribution): """A Bernoulli Distribution.""" p = attr.ib(validator=[_check_in_zero_one_range]) def __attrs_post_init__(self): self.dim = 1 def sample(self, rng): return rng.rand() < self.p @attr.s class Constant(Distribution): """A Constant Distribution.""" mean = attr.ib() def __attrs_post_init__(self): self.dim = len(self.mean) def sample(self, rng): del rng # Unused. return self.mean
google/ml-fairness-gym
distributions.py
Python
apache-2.0
3,400
# -*- coding: utf-8 -*- # Copyright 2014 Michael Malocha <michael@knockrentals.com> # # Expanded from the work by Julien Duponchelle <julien@duponchelle.info>. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Elastic Search Pipeline for scrappy expanded with support for multiple items""" from pyes import ES import hashlib import types import json class ElasticSearchPipeline(object): settings = None es = None @classmethod def from_crawler(cls, crawler): ext = cls() ext.settings = crawler.settings basic_auth = {} if ext.settings['ELASTICSEARCH_USERNAME']: basic_auth['username'] = ext.settings['ELASTICSEARCH_USERNAME'] if ext.settings['ELASTICSEARCH_PASSWORD']: basic_auth['password'] = ext.settings['ELASTICSEARCH_PASSWORD'] if ext.settings['ELASTICSEARCH_PORT']: uri = "%s:%d" % (ext.settings['ELASTICSEARCH_SERVER'], ext.settings['ELASTICSEARCH_PORT']) else: uri = "%s" % (ext.settings['ELASTICSEARCH_SERVER']) if ext.settings['ELASTICSEARCH_MAPPING']: mapping = json.loads(ext.settings['ELASTICSEARCH_MAPPING']) ext.es = ES([uri], basic_auth=basic_auth) return ext def open_spider(self, spider): def index_item(self, item, spider): if self.settings.get('ELASTICSEARCH_UNIQ_KEY'): uniq_key = self.settings.get('ELASTICSEARCH_UNIQ_KEY') local_id = hashlib.sha1(item[uniq_key]).hexdigest() spider.logger.info("Generated unique key %s", local_id) op_type = 'index' else: op_type = 'create' local_id = item['id'] self.es.index(dict(item), self.settings.get('ELASTICSEARCH_INDEX'), self.settings.get('ELASTICSEARCH_TYPE'), id=local_id, op_type=op_type) def process_item(self, item, spider): if isinstance(item, types.GeneratorType) or isinstance(item, types.ListType): for each in item: self.process_item(each, spider) else: self.index_item(item, spider) spider.logger.info("Item sent to Elastic Search %s" % (self.settings.get('ELASTICSEARCH_INDEX'))) return item
bergonzzi/eracareers
era_scraper/eracareers/middlewares/elasticsearch_new.py
Python
apache-2.0
2,816
import asyncio from unittest import mock import pytest from multidict import CIMultiDict from aiohttp.signals import Signal from aiohttp.test_utils import make_mocked_request from aiohttp.web import Application, Response @pytest.fixture def app(): return Application() @pytest.fixture def debug_app(): return Application(debug=True) def make_request(app, method, path, headers=CIMultiDict()): return make_mocked_request(method, path, headers, app=app) async def test_add_signal_handler_not_a_callable(app): callback = True app.on_response_prepare.append(callback) with pytest.raises(TypeError): await app.on_response_prepare(None, None) async def test_function_signal_dispatch(app): signal = Signal(app) kwargs = {'foo': 1, 'bar': 2} callback_mock = mock.Mock() @asyncio.coroutine def callback(**kwargs): callback_mock(**kwargs) signal.append(callback) await signal.send(**kwargs) callback_mock.assert_called_once_with(**kwargs) async def test_function_signal_dispatch2(app): signal = Signal(app) args = {'a', 'b'} kwargs = {'foo': 1, 'bar': 2} callback_mock = mock.Mock() @asyncio.coroutine def callback(*args, **kwargs): callback_mock(*args, **kwargs) signal.append(callback) await signal.send(*args, **kwargs) callback_mock.assert_called_once_with(*args, **kwargs) async def test_response_prepare(app): callback = mock.Mock() @asyncio.coroutine def cb(*args, **kwargs): callback(*args, **kwargs) app.on_response_prepare.append(cb) request = make_request(app, 'GET', '/') response = Response(body=b'') await response.prepare(request) callback.assert_called_once_with(request, response) async def test_non_coroutine(app): signal = Signal(app) kwargs = {'foo': 1, 'bar': 2} callback = mock.Mock() signal.append(callback) await signal.send(**kwargs) callback.assert_called_once_with(**kwargs) async def test_debug_signal(debug_app): assert debug_app.debug, "Should be True" signal = Signal(debug_app) callback = mock.Mock() pre = mock.Mock() post = mock.Mock() signal.append(callback) debug_app.on_pre_signal.append(pre) debug_app.on_post_signal.append(post) await signal.send(1, a=2) callback.assert_called_once_with(1, a=2) pre.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2) post.assert_called_once_with(1, 'aiohttp.signals:Signal', 1, a=2) def test_setitem(app): signal = Signal(app) m1 = mock.Mock() signal.append(m1) assert signal[0] is m1 m2 = mock.Mock() signal[0] = m2 assert signal[0] is m2 def test_delitem(app): signal = Signal(app) m1 = mock.Mock() signal.append(m1) assert len(signal) == 1 del signal[0] assert len(signal) == 0 def test_cannot_append_to_frozen_signal(app): signal = Signal(app) m1 = mock.Mock() m2 = mock.Mock() signal.append(m1) signal.freeze() with pytest.raises(RuntimeError): signal.append(m2) assert list(signal) == [m1] def test_cannot_setitem_in_frozen_signal(app): signal = Signal(app) m1 = mock.Mock() m2 = mock.Mock() signal.append(m1) signal.freeze() with pytest.raises(RuntimeError): signal[0] = m2 assert list(signal) == [m1] def test_cannot_delitem_in_frozen_signal(app): signal = Signal(app) m1 = mock.Mock() signal.append(m1) signal.freeze() with pytest.raises(RuntimeError): del signal[0] assert list(signal) == [m1]
playpauseandstop/aiohttp
tests/test_signals.py
Python
apache-2.0
3,612
#!/usr/bin/env python # encoding: utf-8 """ n_queens.py Created by Shengwei on 2014-07-23. """ # https://oj.leetcode.com/problems/n-queens/ # tags: medim / hard, matrix, bit manipulation, generator, dfs, edge cases, bitmap """ The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively. For example, There exist two distinct solutions to the 4-queens puzzle: [ [".Q..", // Solution 1 "...Q", "Q...", "..Q."], ["..Q.", // Solution 2 "Q...", "...Q", ".Q.."] ] """ # https://oj.leetcode.com/discuss/3861/solved-with-backtracing # https://oj.leetcode.com/discuss/743/whats-your-solution class Solution: # @return a list of lists of string def solveNQueens(self, n): positions = (1 << n) - 1 def search(board, depth, vertical_taken, left_taken, right_taken): if depth == 0: yield board return line = ['.'] * n # it must be & with positions, otherwise it's a negative number # with all 1's extending to the leftmost bit availables = positions & ~(vertical_taken | left_taken | right_taken) # loop through all the availables at this depth while availables: pos = availables & (-availables) # get the rightmost bit that is 1 availables -= pos # remove current pos from availables index = int(math.log(pos, 2)) # comput the index where to put queen # note: remember the recursive call is an iterater and yield again line[index] = 'Q' for each in search( board + [''.join(line)], depth - 1, vertical_taken + pos, left_taken + pos << 1, right_taken + pos >> 1): yield each line[index] = '.' return list(search([], n, 0, 0, 0))
CodingVault/LeetCodeInPython
n_queens.py
Python
apache-2.0
2,232
#!/usr/bin/python # -*- coding: utf-8 -*- """ ------------------------------------------------------------------------------- Function: 【整理】Python中:self和init__的含义 + 为何要有self和__init__ http://www.crifan.com/summary_the_meaning_of_self_and___init___in_python_and_why_need_them Author: Crifan Verison: 2012-11-27 ------------------------------------------------------------------------------- """ #注:此处全局的变量名,写成name,只是为了演示而用 #实际上,好的编程风格,应该写成gName之类的名字,以表示该变量是Global的变量 name = "whole global name"; class Person: name = "class global name" def __init__(self, newPersionName): #self.name = newPersionName; #此处,没有使用self.name #而使得此处的name,实际上仍是局部变量name #虽然此处赋值了,但是后面没有被利用到,属于被浪费了的局部变量name self.name = newPersionName; def sayYourName(self): #此处,之所以没有像之前一样出现: #AttributeError: Person instance has no attribute 'name' #那是因为,虽然当前的实例self中,没有在__init__中初始化对应的name变量,实例self中没有对应的name变量 #但是由于实例所对应的类Person,有对应的name变量,所以也是可以正常执行代码的 #对应的,此处的self.name,实际上是Person.name print 'My name is %s'%(self.name); # -> class global name print 'name within class Person is actually the global name: %s'%(name); #-> whole global name print "only access Person's name via Person.name=%s"%(Person.name); # -> class global name def changeGlobalName(self,newName): global name name = "new class global name" class Child(Person): def say(self): #此处,之所以没有像之前一样出现: #AttributeError: Person instance has no attribute 'name' #那是因为,虽然当前的实例self中,没有在__init__中初始化对应的name变量,实例self中没有对应的name变量 #但是由于实例所对应的类Person,有对应的name变量,所以也是可以正常执行代码的 #对应的,此处的self.name,实际上是Person.name print 'My name is %s'%(self.name); # -> class global name print 'name within class Person is actually the global name: %s'%(name); #-> whole global name print "only access Person's name via Person.name=%s"%(Person.name); # -> class global name #def __init__(self): def selfAndInitDemo(): persionInstance = Person("crifan"); persionInstance.sayYourName(); personInstance2 = Person("michael") personInstance2.sayYourName() personInstance2.changeGlobalName("newName") personInstance2.sayYourName() print "whole global name is %s"%(name); # -> whole global name child = Child('child') child.say() ############################################################################### if __name__=="__main__": selfAndInitDemo();
onehao/opensource
pyml/basic/extension/selfkeyword.py
Python
apache-2.0
3,171
#!/usr/bin/env python # # Copyright 2008 the V8 project authors. All rights reserved. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import imp import optparse import os import platform import re import signal import subprocess import sys import tempfile import time import threading import utils from os.path import join, dirname, abspath, basename, isdir, exists from datetime import datetime from Queue import Queue, Empty VERBOSE = False # --------------------------------------------- # --- P r o g r e s s I n d i c a t o r s --- # --------------------------------------------- class ProgressIndicator(object): def __init__(self, cases): self.cases = cases self.queue = Queue(len(cases)) for case in cases: self.queue.put_nowait(case) self.succeeded = 0 self.remaining = len(cases) self.total = len(cases) self.failed = [ ] self.crashed = 0 self.terminate = False self.lock = threading.Lock() def PrintFailureHeader(self, test): if test.IsNegative(): negative_marker = '[negative] ' else: negative_marker = '' print "=== %(label)s %(negative)s===" % { 'label': test.GetLabel(), 'negative': negative_marker } print "Path: %s" % "/".join(test.path) def Run(self, tasks): self.Starting() threads = [] # Spawn N-1 threads and then use this thread as the last one. # That way -j1 avoids threading altogether which is a nice fallback # in case of threading problems. for i in xrange(tasks - 1): thread = threading.Thread(target=self.RunSingle, args=[]) threads.append(thread) thread.start() try: self.RunSingle() # Wait for the remaining threads for thread in threads: # Use a timeout so that signals (ctrl-c) will be processed. thread.join(timeout=10000000) except Exception, e: # If there's an exception we schedule an interruption for any # remaining threads. self.terminate = True # ...and then reraise the exception to bail out raise self.Done() return not self.failed def RunSingle(self): while not self.terminate: try: test = self.queue.get_nowait() except Empty: return case = test.case self.lock.acquire() self.AboutToRun(case) self.lock.release() try: start = datetime.now() output = case.Run() case.duration = (datetime.now() - start) except IOError, e: assert self.terminate return if self.terminate: return self.lock.acquire() if output.UnexpectedOutput(): self.failed.append(output) if output.HasCrashed(): self.crashed += 1 else: self.succeeded += 1 self.remaining -= 1 self.HasRun(output) self.lock.release() def EscapeCommand(command): parts = [] for part in command: if ' ' in part: # Escape spaces. We may need to escape more characters for this # to work properly. parts.append('"%s"' % part) else: parts.append(part) return " ".join(parts) class SimpleProgressIndicator(ProgressIndicator): def Starting(self): print 'Running %i tests' % len(self.cases) def Done(self): print for failed in self.failed: self.PrintFailureHeader(failed.test) if failed.output.stderr: print "--- stderr ---" print failed.output.stderr.strip() if failed.output.stdout: print "--- stdout ---" print failed.output.stdout.strip() print "Command: %s" % EscapeCommand(failed.command) if failed.HasCrashed(): print "--- CRASHED ---" if failed.HasTimedOut(): print "--- TIMEOUT ---" if len(self.failed) == 0: print "===" print "=== All tests succeeded" print "===" else: print print "===" print "=== %i tests failed" % len(self.failed) if self.crashed > 0: print "=== %i tests CRASHED" % self.crashed print "===" class VerboseProgressIndicator(SimpleProgressIndicator): def AboutToRun(self, case): print 'Starting %s...' % case.GetLabel() sys.stdout.flush() def HasRun(self, output): if output.UnexpectedOutput(): if output.HasCrashed(): outcome = 'CRASH' else: outcome = 'FAIL' else: outcome = 'pass' print 'Done running %s: %s' % (output.test.GetLabel(), outcome) class DotsProgressIndicator(SimpleProgressIndicator): def AboutToRun(self, case): pass def HasRun(self, output): total = self.succeeded + len(self.failed) if (total > 1) and (total % 50 == 1): sys.stdout.write('\n') if output.UnexpectedOutput(): if output.HasCrashed(): sys.stdout.write('C') sys.stdout.flush() elif output.HasTimedOut(): sys.stdout.write('T') sys.stdout.flush() else: sys.stdout.write('F') sys.stdout.flush() else: sys.stdout.write('.') sys.stdout.flush() class TapProgressIndicator(SimpleProgressIndicator): def Starting(self): print '1..%i' % len(self.cases) self._done = 0 def AboutToRun(self, case): pass def HasRun(self, output): self._done += 1 command = basename(output.command[-1]) if output.UnexpectedOutput(): print 'not ok %i - %s' % (self._done, command) for l in output.output.stderr.splitlines(): print '#' + l for l in output.output.stdout.splitlines(): print '#' + l else: print 'ok %i - %s' % (self._done, command) duration = output.test.duration # total_seconds() was added in 2.7 total_seconds = (duration.microseconds + (duration.seconds + duration.days * 24 * 3600) * 10**6) / 10**6 print ' ---' print ' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000) print ' ...' def Done(self): pass class CompactProgressIndicator(ProgressIndicator): def __init__(self, cases, templates): super(CompactProgressIndicator, self).__init__(cases) self.templates = templates self.last_status_length = 0 self.start_time = time.time() def Starting(self): pass def Done(self): self.PrintProgress('Done') def AboutToRun(self, case): self.PrintProgress(case.GetLabel()) def HasRun(self, output): if output.UnexpectedOutput(): self.ClearLine(self.last_status_length) self.PrintFailureHeader(output.test) stdout = output.output.stdout.strip() if len(stdout): print self.templates['stdout'] % stdout stderr = output.output.stderr.strip() if len(stderr): print self.templates['stderr'] % stderr print "Command: %s" % EscapeCommand(output.command) if output.HasCrashed(): print "--- CRASHED ---" if output.HasTimedOut(): print "--- TIMEOUT ---" def Truncate(self, str, length): if length and (len(str) > (length - 3)): return str[:(length-3)] + "..." else: return str def PrintProgress(self, name): self.ClearLine(self.last_status_length) elapsed = time.time() - self.start_time status = self.templates['status_line'] % { 'passed': self.succeeded, 'remaining': (((self.total - self.remaining) * 100) // self.total), 'failed': len(self.failed), 'test': name, 'mins': int(elapsed) / 60, 'secs': int(elapsed) % 60 } status = self.Truncate(status, 78) self.last_status_length = len(status) print status, sys.stdout.flush() class ColorProgressIndicator(CompactProgressIndicator): def __init__(self, cases): templates = { 'status_line': "[%(mins)02i:%(secs)02i|\033[34m%%%(remaining) 4d\033[0m|\033[32m+%(passed) 4d\033[0m|\033[31m-%(failed) 4d\033[0m]: %(test)s", 'stdout': "\033[1m%s\033[0m", 'stderr': "\033[31m%s\033[0m", } super(ColorProgressIndicator, self).__init__(cases, templates) def ClearLine(self, last_line_length): print "\033[1K\r", class MonochromeProgressIndicator(CompactProgressIndicator): def __init__(self, cases): templates = { 'status_line': "[%(mins)02i:%(secs)02i|%%%(remaining) 4d|+%(passed) 4d|-%(failed) 4d]: %(test)s", 'stdout': '%s', 'stderr': '%s', 'clear': lambda last_line_length: ("\r" + (" " * last_line_length) + "\r"), 'max_length': 78 } super(MonochromeProgressIndicator, self).__init__(cases, templates) def ClearLine(self, last_line_length): print ("\r" + (" " * last_line_length) + "\r"), PROGRESS_INDICATORS = { 'verbose': VerboseProgressIndicator, 'dots': DotsProgressIndicator, 'color': ColorProgressIndicator, 'tap': TapProgressIndicator, 'mono': MonochromeProgressIndicator } # ------------------------- # --- F r a m e w o r k --- # ------------------------- class CommandOutput(object): def __init__(self, exit_code, timed_out, stdout, stderr): self.exit_code = exit_code self.timed_out = timed_out self.stdout = stdout self.stderr = stderr self.failed = None class TestCase(object): def __init__(self, context, path, mode): self.path = path self.context = context self.duration = None self.mode = mode def IsNegative(self): return False def CompareTime(self, other): return cmp(other.duration, self.duration) def DidFail(self, output): if output.failed is None: output.failed = self.IsFailureOutput(output) return output.failed def IsFailureOutput(self, output): return output.exit_code != 0 def GetSource(self): return "(no source available)" def RunCommand(self, command): full_command = self.context.processor(command) output = Execute(full_command, self.context, self.context.GetTimeout(self.mode)) self.Cleanup() return TestOutput(self, full_command, output, self.context.store_unexpected_output) def BeforeRun(self): pass def AfterRun(self, result): pass def Run(self): self.BeforeRun() try: result = self.RunCommand(self.GetCommand()) finally: # Tests can leave the tty in non-blocking mode. If the test runner # tries to print to stdout/stderr after that and the tty buffer is # full, it'll die with a EAGAIN OSError. Ergo, put the tty back in # blocking mode before proceeding. if sys.platform != 'win32': from fcntl import fcntl, F_GETFL, F_SETFL from os import O_NONBLOCK for fd in 0,1,2: fcntl(fd, F_SETFL, ~O_NONBLOCK & fcntl(fd, F_GETFL)) self.AfterRun(result) return result def Cleanup(self): return class TestOutput(object): def __init__(self, test, command, output, store_unexpected_output): self.test = test self.command = command self.output = output self.store_unexpected_output = store_unexpected_output def UnexpectedOutput(self): if self.HasCrashed(): outcome = CRASH elif self.HasTimedOut(): outcome = TIMEOUT elif self.HasFailed(): outcome = FAIL else: outcome = PASS return not outcome in self.test.outcomes def HasPreciousOutput(self): return self.UnexpectedOutput() and self.store_unexpected_output def HasCrashed(self): if utils.IsWindows(): return 0x80000000 & self.output.exit_code and not (0x3FFFFF00 & self.output.exit_code) else: # Timed out tests will have exit_code -signal.SIGTERM. if self.output.timed_out: return False return self.output.exit_code < 0 and \ self.output.exit_code != -signal.SIGABRT def HasTimedOut(self): return self.output.timed_out; def HasFailed(self): execution_failed = self.test.DidFail(self.output) if self.test.IsNegative(): return not execution_failed else: return execution_failed def KillProcessWithID(pid): if utils.IsWindows(): os.popen('taskkill /T /F /PID %d' % pid) else: os.kill(pid, signal.SIGTERM) MAX_SLEEP_TIME = 0.1 INITIAL_SLEEP_TIME = 0.0001 SLEEP_TIME_FACTOR = 1.25 SEM_INVALID_VALUE = -1 SEM_NOGPFAULTERRORBOX = 0x0002 # Microsoft Platform SDK WinBase.h def Win32SetErrorMode(mode): prev_error_mode = SEM_INVALID_VALUE try: import ctypes prev_error_mode = ctypes.windll.kernel32.SetErrorMode(mode); except ImportError: pass return prev_error_mode def RunProcess(context, timeout, args, **rest): if context.verbose: print "#", " ".join(args) popen_args = args prev_error_mode = SEM_INVALID_VALUE; if utils.IsWindows(): if context.suppress_dialogs: # Try to change the error mode to avoid dialogs on fatal errors. Don't # touch any existing error mode flags by merging the existing error mode. # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx. error_mode = SEM_NOGPFAULTERRORBOX; prev_error_mode = Win32SetErrorMode(error_mode); Win32SetErrorMode(error_mode | prev_error_mode); process = subprocess.Popen( shell = utils.IsWindows(), args = popen_args, **rest ) if utils.IsWindows() and context.suppress_dialogs and prev_error_mode != SEM_INVALID_VALUE: Win32SetErrorMode(prev_error_mode) # Compute the end time - if the process crosses this limit we # consider it timed out. if timeout is None: end_time = None else: end_time = time.time() + timeout timed_out = False # Repeatedly check the exit code from the process in a # loop and keep track of whether or not it times out. exit_code = None sleep_time = INITIAL_SLEEP_TIME while exit_code is None: if (not end_time is None) and (time.time() >= end_time): # Kill the process and wait for it to exit. KillProcessWithID(process.pid) exit_code = process.wait() timed_out = True else: exit_code = process.poll() time.sleep(sleep_time) sleep_time = sleep_time * SLEEP_TIME_FACTOR if sleep_time > MAX_SLEEP_TIME: sleep_time = MAX_SLEEP_TIME return (process, exit_code, timed_out) def PrintError(str): sys.stderr.write(str) sys.stderr.write('\n') def CheckedUnlink(name): try: os.unlink(name) except OSError, e: PrintError("os.unlink() " + str(e)) def Execute(args, context, timeout=None): (fd_out, outname) = tempfile.mkstemp() (fd_err, errname) = tempfile.mkstemp() (process, exit_code, timed_out) = RunProcess( context, timeout, args = args, stdout = fd_out, stderr = fd_err, ) os.close(fd_out) os.close(fd_err) output = file(outname).read() errors = file(errname).read() CheckedUnlink(outname) CheckedUnlink(errname) return CommandOutput(exit_code, timed_out, output, errors) def ExecuteNoCapture(args, context, timeout=None): (process, exit_code, timed_out) = RunProcess( context, timeout, args = args, ) return CommandOutput(exit_code, False, "", "") def CarCdr(path): if len(path) == 0: return (None, [ ]) else: return (path[0], path[1:]) class TestConfiguration(object): def __init__(self, context, root): self.context = context self.root = root def Contains(self, path, file): if len(path) > len(file): return False for i in xrange(len(path)): if not path[i].match(file[i]): return False return True def GetTestStatus(self, sections, defs): pass class TestSuite(object): def __init__(self, name): self.name = name def GetName(self): return self.name # Use this to run several variants of the tests, e.g.: # VARIANT_FLAGS = [[], ['--always_compact', '--noflush_code']] VARIANT_FLAGS = [[]] class TestRepository(TestSuite): def __init__(self, path): normalized_path = abspath(path) super(TestRepository, self).__init__(basename(normalized_path)) self.path = normalized_path self.is_loaded = False self.config = None def GetConfiguration(self, context): if self.is_loaded: return self.config self.is_loaded = True file = None try: (file, pathname, description) = imp.find_module('testcfg', [ self.path ]) module = imp.load_module('testcfg', file, pathname, description) self.config = module.GetConfiguration(context, self.path) finally: if file: file.close() return self.config def GetBuildRequirements(self, path, context): return self.GetConfiguration(context).GetBuildRequirements() def AddTestsToList(self, result, current_path, path, context, mode): for v in VARIANT_FLAGS: tests = self.GetConfiguration(context).ListTests(current_path, path, mode) for t in tests: t.variant_flags = v result += tests def GetTestStatus(self, context, sections, defs): self.GetConfiguration(context).GetTestStatus(sections, defs) class LiteralTestSuite(TestSuite): def __init__(self, tests): super(LiteralTestSuite, self).__init__('root') self.tests = tests def GetBuildRequirements(self, path, context): (name, rest) = CarCdr(path) result = [ ] for test in self.tests: if not name or name.match(test.GetName()): result += test.GetBuildRequirements(rest, context) return result def ListTests(self, current_path, path, context, mode): (name, rest) = CarCdr(path) result = [ ] for test in self.tests: test_name = test.GetName() if not name or name.match(test_name): full_path = current_path + [test_name] test.AddTestsToList(result, full_path, path, context, mode) result.sort(cmp=lambda a, b: cmp(a.GetName(), b.GetName())) return result def GetTestStatus(self, context, sections, defs): for test in self.tests: test.GetTestStatus(context, sections, defs) SUFFIX = { 'debug' : '_g', 'release' : '' } FLAGS = { 'debug' : ['--enable-slow-asserts', '--debug-code', '--verify-heap'], 'release' : []} TIMEOUT_SCALEFACTOR = { 'debug' : 4, 'release' : 1 } class Context(object): def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, suppress_dialogs, store_unexpected_output): self.workspace = workspace self.buildspace = buildspace self.verbose = verbose self.vm_root = vm self.timeout = timeout self.processor = processor self.suppress_dialogs = suppress_dialogs self.store_unexpected_output = store_unexpected_output def GetVm(self, mode): if mode == 'debug': name = './ONode' else: name = './ONode' # Currently GYP does not support output_dir for MSVS. # http://code.google.com/p/gyp/issues/detail?id=40 # It will put the builds into Release/node.exe or Debug/node.exe if utils.IsWindows(): out_dir = os.path.join(dirname(__file__), "..", "out") if not exists(out_dir): if mode == 'debug': name = os.path.abspath('Debug/node.exe') else: name = os.path.abspath('Release/node.exe') else: name = os.path.abspath(name + '.exe') return name def GetVmCommand(self, testcase, mode): return [self.GetVm(mode)] + self.GetVmFlags(testcase, mode) def GetVmFlags(self, testcase, mode): return testcase.variant_flags + FLAGS[mode] def GetTimeout(self, mode): return self.timeout * TIMEOUT_SCALEFACTOR[mode] def RunTestCases(cases_to_run, progress, tasks): progress = PROGRESS_INDICATORS[progress](cases_to_run) return progress.Run(tasks) def BuildRequirements(context, requirements, mode, scons_flags): command_line = (['scons', '-Y', context.workspace, 'mode=' + ",".join(mode)] + requirements + scons_flags) output = ExecuteNoCapture(command_line, context) return output.exit_code == 0 # ------------------------------------------- # --- T e s t C o n f i g u r a t i o n --- # ------------------------------------------- SKIP = 'skip' FAIL = 'fail' PASS = 'pass' OKAY = 'okay' TIMEOUT = 'timeout' CRASH = 'crash' SLOW = 'slow' class Expression(object): pass class Constant(Expression): def __init__(self, value): self.value = value def Evaluate(self, env, defs): return self.value class Variable(Expression): def __init__(self, name): self.name = name def GetOutcomes(self, env, defs): if self.name in env: return ListSet([env[self.name]]) else: return Nothing() class Outcome(Expression): def __init__(self, name): self.name = name def GetOutcomes(self, env, defs): if self.name in defs: return defs[self.name].GetOutcomes(env, defs) else: return ListSet([self.name]) class Set(object): pass class ListSet(Set): def __init__(self, elms): self.elms = elms def __str__(self): return "ListSet%s" % str(self.elms) def Intersect(self, that): if not isinstance(that, ListSet): return that.Intersect(self) return ListSet([ x for x in self.elms if x in that.elms ]) def Union(self, that): if not isinstance(that, ListSet): return that.Union(self) return ListSet(self.elms + [ x for x in that.elms if x not in self.elms ]) def IsEmpty(self): return len(self.elms) == 0 class Everything(Set): def Intersect(self, that): return that def Union(self, that): return self def IsEmpty(self): return False class Nothing(Set): def Intersect(self, that): return self def Union(self, that): return that def IsEmpty(self): return True class Operation(Expression): def __init__(self, left, op, right): self.left = left self.op = op self.right = right def Evaluate(self, env, defs): if self.op == '||' or self.op == ',': return self.left.Evaluate(env, defs) or self.right.Evaluate(env, defs) elif self.op == 'if': return False elif self.op == '==': inter = self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs)) return not inter.IsEmpty() else: assert self.op == '&&' return self.left.Evaluate(env, defs) and self.right.Evaluate(env, defs) def GetOutcomes(self, env, defs): if self.op == '||' or self.op == ',': return self.left.GetOutcomes(env, defs).Union(self.right.GetOutcomes(env, defs)) elif self.op == 'if': if self.right.Evaluate(env, defs): return self.left.GetOutcomes(env, defs) else: return Nothing() else: assert self.op == '&&' return self.left.GetOutcomes(env, defs).Intersect(self.right.GetOutcomes(env, defs)) def IsAlpha(str): for char in str: if not (char.isalpha() or char.isdigit() or char == '_'): return False return True class Tokenizer(object): """A simple string tokenizer that chops expressions into variables, parens and operators""" def __init__(self, expr): self.index = 0 self.expr = expr self.length = len(expr) self.tokens = None def Current(self, length = 1): if not self.HasMore(length): return "" return self.expr[self.index:self.index+length] def HasMore(self, length = 1): return self.index < self.length + (length - 1) def Advance(self, count = 1): self.index = self.index + count def AddToken(self, token): self.tokens.append(token) def SkipSpaces(self): while self.HasMore() and self.Current().isspace(): self.Advance() def Tokenize(self): self.tokens = [ ] while self.HasMore(): self.SkipSpaces() if not self.HasMore(): return None if self.Current() == '(': self.AddToken('(') self.Advance() elif self.Current() == ')': self.AddToken(')') self.Advance() elif self.Current() == '$': self.AddToken('$') self.Advance() elif self.Current() == ',': self.AddToken(',') self.Advance() elif IsAlpha(self.Current()): buf = "" while self.HasMore() and IsAlpha(self.Current()): buf += self.Current() self.Advance() self.AddToken(buf) elif self.Current(2) == '&&': self.AddToken('&&') self.Advance(2) elif self.Current(2) == '||': self.AddToken('||') self.Advance(2) elif self.Current(2) == '==': self.AddToken('==') self.Advance(2) else: return None return self.tokens class Scanner(object): """A simple scanner that can serve out tokens from a given list""" def __init__(self, tokens): self.tokens = tokens self.length = len(tokens) self.index = 0 def HasMore(self): return self.index < self.length def Current(self): return self.tokens[self.index] def Advance(self): self.index = self.index + 1 def ParseAtomicExpression(scan): if scan.Current() == "true": scan.Advance() return Constant(True) elif scan.Current() == "false": scan.Advance() return Constant(False) elif IsAlpha(scan.Current()): name = scan.Current() scan.Advance() return Outcome(name.lower()) elif scan.Current() == '$': scan.Advance() if not IsAlpha(scan.Current()): return None name = scan.Current() scan.Advance() return Variable(name.lower()) elif scan.Current() == '(': scan.Advance() result = ParseLogicalExpression(scan) if (not result) or (scan.Current() != ')'): return None scan.Advance() return result else: return None BINARIES = ['=='] def ParseOperatorExpression(scan): left = ParseAtomicExpression(scan) if not left: return None while scan.HasMore() and (scan.Current() in BINARIES): op = scan.Current() scan.Advance() right = ParseOperatorExpression(scan) if not right: return None left = Operation(left, op, right) return left def ParseConditionalExpression(scan): left = ParseOperatorExpression(scan) if not left: return None while scan.HasMore() and (scan.Current() == 'if'): scan.Advance() right = ParseOperatorExpression(scan) if not right: return None left= Operation(left, 'if', right) return left LOGICALS = ["&&", "||", ","] def ParseLogicalExpression(scan): left = ParseConditionalExpression(scan) if not left: return None while scan.HasMore() and (scan.Current() in LOGICALS): op = scan.Current() scan.Advance() right = ParseConditionalExpression(scan) if not right: return None left = Operation(left, op, right) return left def ParseCondition(expr): """Parses a logical expression into an Expression object""" tokens = Tokenizer(expr).Tokenize() if not tokens: print "Malformed expression: '%s'" % expr return None scan = Scanner(tokens) ast = ParseLogicalExpression(scan) if not ast: print "Malformed expression: '%s'" % expr return None if scan.HasMore(): print "Malformed expression: '%s'" % expr return None return ast class ClassifiedTest(object): def __init__(self, case, outcomes): self.case = case self.outcomes = outcomes class Configuration(object): """The parsed contents of a configuration file""" def __init__(self, sections, defs): self.sections = sections self.defs = defs def ClassifyTests(self, cases, env): sections = [s for s in self.sections if s.condition.Evaluate(env, self.defs)] all_rules = reduce(list.__add__, [s.rules for s in sections], []) unused_rules = set(all_rules) result = [ ] all_outcomes = set([]) for case in cases: matches = [ r for r in all_rules if r.Contains(case.path) ] outcomes = set([]) for rule in matches: outcomes = outcomes.union(rule.GetOutcomes(env, self.defs)) unused_rules.discard(rule) if not outcomes: outcomes = [PASS] case.outcomes = outcomes all_outcomes = all_outcomes.union(outcomes) result.append(ClassifiedTest(case, outcomes)) return (result, list(unused_rules), all_outcomes) class Section(object): """A section of the configuration file. Sections are enabled or disabled prior to running the tests, based on their conditions""" def __init__(self, condition): self.condition = condition self.rules = [ ] def AddRule(self, rule): self.rules.append(rule) class Rule(object): """A single rule that specifies the expected outcome for a single test.""" def __init__(self, raw_path, path, value): self.raw_path = raw_path self.path = path self.value = value def GetOutcomes(self, env, defs): set = self.value.GetOutcomes(env, defs) assert isinstance(set, ListSet) return set.elms def Contains(self, path): if len(self.path) > len(path): return False for i in xrange(len(self.path)): if not self.path[i].match(path[i]): return False return True HEADER_PATTERN = re.compile(r'\[([^]]+)\]') RULE_PATTERN = re.compile(r'\s*([^: ]*)\s*:(.*)') DEF_PATTERN = re.compile(r'^def\s*(\w+)\s*=(.*)$') PREFIX_PATTERN = re.compile(r'^\s*prefix\s+([\w\_\.\-\/]+)$') def ReadConfigurationInto(path, sections, defs): current_section = Section(Constant(True)) sections.append(current_section) prefix = [] for line in utils.ReadLinesFrom(path): header_match = HEADER_PATTERN.match(line) if header_match: condition_str = header_match.group(1).strip() condition = ParseCondition(condition_str) new_section = Section(condition) sections.append(new_section) current_section = new_section continue rule_match = RULE_PATTERN.match(line) if rule_match: path = prefix + SplitPath(rule_match.group(1).strip()) value_str = rule_match.group(2).strip() value = ParseCondition(value_str) if not value: return False current_section.AddRule(Rule(rule_match.group(1), path, value)) continue def_match = DEF_PATTERN.match(line) if def_match: name = def_match.group(1).lower() value = ParseCondition(def_match.group(2).strip()) if not value: return False defs[name] = value continue prefix_match = PREFIX_PATTERN.match(line) if prefix_match: prefix = SplitPath(prefix_match.group(1).strip()) continue print "Malformed line: '%s'." % line return False return True # --------------- # --- M a i n --- # --------------- ARCH_GUESS = utils.GuessArchitecture() def BuildOptions(): result = optparse.OptionParser() result.add_option("-m", "--mode", help="The test modes in which to run (comma-separated)", default='release') result.add_option("-v", "--verbose", help="Verbose output", default=False, action="store_true") result.add_option("-S", dest="scons_flags", help="Flag to pass through to scons", default=[], action="append") result.add_option("-p", "--progress", help="The style of progress indicator (verbose, dots, color, mono, tap)", choices=PROGRESS_INDICATORS.keys(), default="mono") result.add_option("--no-build", help="Don't build requirements", default=True, action="store_true") result.add_option("--build-only", help="Only build requirements, don't run the tests", default=False, action="store_true") result.add_option("--report", help="Print a summary of the tests to be run", default=False, action="store_true") result.add_option("-s", "--suite", help="A test suite", default=[], action="append") result.add_option("-t", "--timeout", help="Timeout in seconds", default=60, type="int") result.add_option("--arch", help='The architecture to run tests for', default='none') result.add_option("--snapshot", help="Run the tests with snapshot turned on", default=False, action="store_true") result.add_option("--simulator", help="Run tests with architecture simulator", default='none') result.add_option("--special-command", default=None) result.add_option("--use-http1", help="Pass --use-http1 switch to node", default=False, action="store_true") result.add_option("--valgrind", help="Run tests through valgrind", default=False, action="store_true") result.add_option("--cat", help="Print the source of the tests", default=False, action="store_true") result.add_option("--warn-unused", help="Report unused rules", default=False, action="store_true") result.add_option("-j", help="The number of parallel tasks to run", default=1, type="int") result.add_option("--time", help="Print timing information after running", default=False, action="store_true") result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for crashing tests", dest="suppress_dialogs", default=True, action="store_true") result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for crashing tests", dest="suppress_dialogs", action="store_false") result.add_option("--shell", help="Path to V8 shell", default="shell") result.add_option("--store-unexpected-output", help="Store the temporary JS files from tests that fails", dest="store_unexpected_output", default=True, action="store_true") result.add_option("--no-store-unexpected-output", help="Deletes the temporary JS files from tests that fails", dest="store_unexpected_output", action="store_false") return result def ProcessOptions(options): global VERBOSE VERBOSE = options.verbose options.mode = options.mode.split(',') for mode in options.mode: if not mode in ['debug', 'release']: print "Unknown mode %s" % mode return False if options.simulator != 'none': # Simulator argument was set. Make sure arch and simulator agree. if options.simulator != options.arch: if options.arch == 'none': options.arch = options.simulator else: print "Architecture %s does not match sim %s" %(options.arch, options.simulator) return False # Ensure that the simulator argument is handed down to scons. options.scons_flags.append("simulator=" + options.simulator) else: # If options.arch is not set by the command line and no simulator setting # was found, set the arch to the guess. if options.arch == 'none': options.arch = ARCH_GUESS options.scons_flags.append("arch=" + options.arch) if options.snapshot: options.scons_flags.append("snapshot=on") return True REPORT_TEMPLATE = """\ Total: %(total)i tests * %(skipped)4d tests will be skipped * %(nocrash)4d tests are expected to be flaky but not crash * %(pass)4d tests are expected to pass * %(fail_ok)4d tests are expected to fail that we won't fix * %(fail)4d tests are expected to fail that we should fix\ """ def PrintReport(cases): def IsFlaky(o): return (PASS in o) and (FAIL in o) and (not CRASH in o) and (not OKAY in o) def IsFailOk(o): return (len(o) == 2) and (FAIL in o) and (OKAY in o) unskipped = [c for c in cases if not SKIP in c.outcomes] print REPORT_TEMPLATE % { 'total': len(cases), 'skipped': len(cases) - len(unskipped), 'nocrash': len([t for t in unskipped if IsFlaky(t.outcomes)]), 'pass': len([t for t in unskipped if list(t.outcomes) == [PASS]]), 'fail_ok': len([t for t in unskipped if IsFailOk(t.outcomes)]), 'fail': len([t for t in unskipped if list(t.outcomes) == [FAIL]]) } class Pattern(object): def __init__(self, pattern): self.pattern = pattern self.compiled = None def match(self, str): if not self.compiled: pattern = "^" + self.pattern.replace('*', '.*') + "$" self.compiled = re.compile(pattern) return self.compiled.match(str) def __str__(self): return self.pattern def SplitPath(s): stripped = [ c.strip() for c in s.split('/') ] return [ Pattern(s) for s in stripped if len(s) > 0 ] def GetSpecialCommandProcessor(value): if (not value) or (value.find('@') == -1): def ExpandCommand(args): return args return ExpandCommand else: pos = value.find('@') import urllib prefix = urllib.unquote(value[:pos]).split() suffix = urllib.unquote(value[pos+1:]).split() def ExpandCommand(args): return prefix + args + suffix return ExpandCommand BUILT_IN_TESTS = [ 'simple', 'pummel', 'message', 'internet', 'gc', 'debugger', ] def GetSuites(test_root): def IsSuite(path): return isdir(path) and exists(join(path, 'testcfg.py')) return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ] def FormatTime(d): millis = round(d * 1000) % 1000 return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis) def Main(): parser = BuildOptions() (options, args) = parser.parse_args() if not ProcessOptions(options): parser.print_help() return 1 workspace = abspath(join(dirname(sys.argv[0]), '..')) suites = GetSuites(join(workspace, 'Tests')) repositories = [TestRepository(join(workspace, 'Tests', name)) for name in suites] repositories += [TestRepository(a) for a in options.suite] root = LiteralTestSuite(repositories) if len(args) == 0: paths = [SplitPath(t) for t in BUILT_IN_TESTS] else: paths = [ ] for arg in args: path = SplitPath(arg) paths.append(path) # Check for --valgrind option. If enabled, we overwrite the special # command flag with a command that uses the run-valgrind.py script. if options.valgrind: run_valgrind = join(workspace, "tools", "run-valgrind.py") options.special_command = "python -u " + run_valgrind + " @" shell = abspath(options.shell) buildspace = dirname(shell) processor = GetSpecialCommandProcessor(options.special_command) if options.use_http1: def wrap(processor): return lambda args: processor(args[:1] + ['--use-http1'] + args[1:]) processor = wrap(processor) context = Context(workspace, buildspace, VERBOSE, shell, options.timeout, processor, options.suppress_dialogs, options.store_unexpected_output) # First build the required targets if not options.no_build: reqs = [ ] for path in paths: reqs += root.GetBuildRequirements(path, context) reqs = list(set(reqs)) if len(reqs) > 0: if options.j != 1: options.scons_flags += ['-j', str(options.j)] if not BuildRequirements(context, reqs, options.mode, options.scons_flags): return 1 # Just return if we are only building the targets for running the tests. if options.build_only: return 0 # Get status for tests sections = [ ] defs = { } root.GetTestStatus(context, sections, defs) config = Configuration(sections, defs) # List the tests all_cases = [ ] all_unused = [ ] unclassified_tests = [ ] globally_unused_rules = None for path in paths: for mode in options.mode: if not exists(context.GetVm(mode)): print "Can't find shell executable: '%s'" % context.GetVm(mode) continue env = { 'mode': mode, 'system': utils.GuessOS(), 'arch': options.arch, 'simulator': options.simulator } test_list = root.ListTests([], path, context, mode) unclassified_tests += test_list (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env) if globally_unused_rules is None: globally_unused_rules = set(unused_rules) else: globally_unused_rules = globally_unused_rules.intersection(unused_rules) all_cases += cases all_unused.append(unused_rules) if options.cat: visited = set() for test in unclassified_tests: key = tuple(test.path) if key in visited: continue visited.add(key) print "--- begin source: %s ---" % test.GetLabel() source = test.GetSource().strip() print source print "--- end source: %s ---" % test.GetLabel() return 0 if options.warn_unused: for rule in globally_unused_rules: print "Rule for '%s' was not used." % '/'.join([str(s) for s in rule.path]) if options.report: PrintReport(all_cases) result = None def DoSkip(case): return SKIP in case.outcomes or SLOW in case.outcomes cases_to_run = [ c for c in all_cases if not DoSkip(c) ] if len(cases_to_run) == 0: print "No tests to run." return 0 else: try: start = time.time() if RunTestCases(cases_to_run, options.progress, options.j): result = 0 else: result = 1 duration = time.time() - start except KeyboardInterrupt: print "Interrupted" return 1 if options.time: # Write the times to stderr to make it easy to separate from the # test output. print sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration)) timed_tests = [ t.case for t in cases_to_run if not t.case.duration is None ] timed_tests.sort(lambda a, b: a.CompareTime(b)) index = 1 for entry in timed_tests[:20]: t = FormatTime(entry.duration) sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) index += 1 return result if __name__ == '__main__': sys.exit(Main())
sultan99/online
ONode/Tools/test.py
Python
apache-2.0
42,584
# -*- coding: utf-8 -*- import os, io from setuptools import setup from SVNOnline.SVNOnline import __version__ here = os.path.abspath(os.path.dirname(__file__)) README = io.open(os.path.join(here, 'README.rst'), encoding='UTF-8').read() CHANGES = io.open(os.path.join(here, 'CHANGES.rst'), encoding='UTF-8').read() setup(name='SVNOnline', version=__version__, description='A svn online client.', keywords=('svn', 'svn client', 'svn online'), long_description=README + '\n\n\n' + CHANGES, url='https://github.com/sintrb/SVNOnline', classifiers=[ 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2.7', ], author='sintrb', author_email='sintrb@gmail.com', license='Apache', packages=['SVNOnline'], scripts=['SVNOnline/SVNOnline', 'SVNOnline/SVNOnline.bat'], include_package_data=True, install_requires=['svn==0.3.36'], zip_safe=False)
sintrb/SVNOnline
setup.py
Python
apache-2.0
1,012
# Copyright 2016 Nokia. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """add gateway port mapping Revision ID: c4fb5a76b195 Revises: 13cf8b5dfd05 Create Date: 2016-04-12 11:35:51.542465 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = 'c4fb5a76b195' down_revision = '13cf8b5dfd05' def upgrade(): op.create_table('nuage_switchport_mapping', sa.Column('id', sa.String(36), nullable=False), sa.Column('switch_info', sa.String(255), nullable=False), sa.Column('switch_id', sa.String(36), nullable=False), sa.Column('redundant', sa.Boolean(), nullable=False), sa.Column('port_id', sa.String(255), nullable=False), sa.Column('port_uuid', sa.String(36), nullable=False), sa.Column('pci_slot', sa.String(36), nullable=False), sa.Column('host_id', sa.String(255), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('pci_slot', 'host_id')) op.create_table('nuage_switchport_binding', sa.Column('id', sa.String(36), nullable=False), sa.Column('neutron_port_id', sa.String(36), nullable=False), sa.Column('nuage_vport_id', sa.String(36), nullable=False), sa.Column('switchport_uuid', sa.String(36), nullable=False), sa.Column('segmentation_id', sa.Integer, nullable=False), sa.ForeignKeyConstraint( ['neutron_port_id'], ['ports.id'], ondelete='CASCADE'))
nuagenetworks/nuage-openstack-neutron
nuage_neutron/db/migration/alembic_migrations/versions/newton/expand/c4fb5a76b195_add_switchport_mapping.py
Python
apache-2.0
2,371
# Copyright 2012-2015 MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Discover environment and server configuration, initialize PyMongo client.""" import os import socket import sys from functools import wraps from test.utils import create_user from test.version import Version from unittest import SkipTest import pymongo.errors HAVE_SSL = True try: import ssl except ImportError: HAVE_SSL = False ssl = None HAVE_TORNADO = True try: import tornado except ImportError: HAVE_TORNADO = False tornado = None HAVE_ASYNCIO = True try: import asyncio except ImportError: HAVE_ASYNCIO = False asyncio = None HAVE_AIOHTTP = True try: import aiohttp except ImportError: HAVE_AIOHTTP = False aiohttp = None # Copied from PyMongo. def partition_node(node): """Split a host:port string into (host, int(port)) pair.""" host = node port = 27017 idx = node.rfind(":") if idx != -1: host, port = node[:idx], int(node[idx + 1 :]) if host.startswith("["): host = host[1:-1] return host, port def connected(client): """Convenience, wait for a new PyMongo MongoClient to connect.""" client.admin.command("ping") # Force connection. return client # If these are set to the empty string, substitute None. db_user = os.environ.get("DB_USER") or None db_password = os.environ.get("DB_PASSWORD") or None CERT_PATH = os.environ.get( "CERT_DIR", os.path.join(os.path.dirname(os.path.realpath(__file__)), "certificates") ) CLIENT_PEM = os.path.join(CERT_PATH, "client.pem") CA_PEM = os.path.join(CERT_PATH, "ca.pem") MONGODB_X509_USERNAME = "CN=client,OU=kerneluser,O=10Gen,L=New York City,ST=New York,C=US" def is_server_resolvable(): """Returns True if 'server' is resolvable.""" socket_timeout = socket.getdefaulttimeout() socket.setdefaulttimeout(1) try: socket.gethostbyname("server") return True except socket.error: return False finally: socket.setdefaulttimeout(socket_timeout) class TestEnvironment(object): def __init__(self): self.initialized = False self.host = None self.port = None self.mongod_started_with_ssl = False self.mongod_validates_client_cert = False self.server_is_resolvable = is_server_resolvable() self.sync_cx = None self.is_standalone = False self.is_mongos = False self.is_replica_set = False self.rs_name = None self.w = 1 self.hosts = None self.arbiters = None self.primary = None self.secondaries = None self.v8 = False self.auth = False self.uri = None self.rs_uri = None self.version = None self.sessions_enabled = False self.fake_hostname_uri = None self.server_status = None def setup(self): assert not self.initialized self.setup_sync_cx() self.setup_auth_and_uri() self.setup_version() self.setup_v8() self.server_status = self.sync_cx.admin.command("serverStatus") self.initialized = True def setup_sync_cx(self): """Get a synchronous PyMongo MongoClient and determine SSL config.""" host = os.environ.get("DB_IP", "localhost") port = int(os.environ.get("DB_PORT", 27017)) connectTimeoutMS = 100 serverSelectionTimeoutMS = 100 socketTimeoutMS = 10000 try: client = connected( pymongo.MongoClient( host, port, username=db_user, password=db_password, directConnection=True, connectTimeoutMS=connectTimeoutMS, socketTimeoutMS=socketTimeoutMS, serverSelectionTimeoutMS=serverSelectionTimeoutMS, tlsCAFile=CA_PEM, ssl=True, ) ) self.mongod_started_with_ssl = True except pymongo.errors.ServerSelectionTimeoutError: try: client = connected( pymongo.MongoClient( host, port, username=db_user, password=db_password, directConnection=True, connectTimeoutMS=connectTimeoutMS, socketTimeoutMS=socketTimeoutMS, serverSelectionTimeoutMS=serverSelectionTimeoutMS, tlsCAFile=CA_PEM, tlsCertificateKeyFile=CLIENT_PEM, ) ) self.mongod_started_with_ssl = True self.mongod_validates_client_cert = True except pymongo.errors.ServerSelectionTimeoutError: client = connected( pymongo.MongoClient( host, port, username=db_user, password=db_password, directConnection=True, connectTimeoutMS=connectTimeoutMS, socketTimeoutMS=socketTimeoutMS, serverSelectionTimeoutMS=serverSelectionTimeoutMS, ) ) response = client.admin.command("ismaster") self.sessions_enabled = "logicalSessionTimeoutMinutes" in response self.is_mongos = response.get("msg") == "isdbgrid" if "setName" in response: self.is_replica_set = True self.rs_name = str(response["setName"]) self.w = len(response["hosts"]) self.hosts = set([partition_node(h) for h in response["hosts"]]) host, port = self.primary = partition_node(response["primary"]) self.arbiters = set([partition_node(h) for h in response.get("arbiters", [])]) self.secondaries = [ partition_node(m) for m in response["hosts"] if m != self.primary and m not in self.arbiters ] elif not self.is_mongos: self.is_standalone = True # Reconnect to found primary, without short timeouts. if self.mongod_started_with_ssl: client = connected( pymongo.MongoClient( host, port, username=db_user, password=db_password, directConnection=True, tlsCAFile=CA_PEM, tlsCertificateKeyFile=CLIENT_PEM, ) ) else: client = connected( pymongo.MongoClient( host, port, username=db_user, password=db_password, directConnection=True, ssl=False, ) ) self.sync_cx = client self.host = host self.port = port def setup_auth_and_uri(self): """Set self.auth and self.uri.""" if db_user or db_password: if not (db_user and db_password): sys.stderr.write("You must set both DB_USER and DB_PASSWORD, or neither\n") sys.exit(1) self.auth = True uri_template = "mongodb://%s:%s@%s:%s/admin" self.uri = uri_template % (db_user, db_password, self.host, self.port) # If the hostname 'server' is resolvable, this URI lets us use it # to test SSL hostname validation with auth. self.fake_hostname_uri = uri_template % (db_user, db_password, "server", self.port) else: self.uri = "mongodb://%s:%s/admin" % (self.host, self.port) self.fake_hostname_uri = "mongodb://%s:%s/admin" % ("server", self.port) if self.rs_name: self.rs_uri = self.uri + "?replicaSet=" + self.rs_name def setup_version(self): """Set self.version to the server's version.""" self.version = Version.from_client(self.sync_cx) def setup_v8(self): """Determine if server is running SpiderMonkey or V8.""" if self.sync_cx.server_info().get("javascriptEngine") == "V8": self.v8 = True @property def storage_engine(self): try: return self.server_status.get("storageEngine", {}).get("name") except AttributeError: # Raised if self.server_status is None. return None def supports_transactions(self): if self.storage_engine == "mmapv1": return False if self.version.at_least(4, 1, 8): return self.is_mongos or self.is_replica_set if self.version.at_least(4, 0): return self.is_replica_set return False def require(self, condition, msg, func=None): def make_wrapper(f): @wraps(f) def wrap(*args, **kwargs): if condition(): return f(*args, **kwargs) raise SkipTest(msg) return wrap if func is None: def decorate(f): return make_wrapper(f) return decorate return make_wrapper(func) def require_auth(self, func): """Run a test only if the server is started with auth.""" return self.require(lambda: self.auth, "Server must be start with auth", func=func) def require_version_min(self, *ver): """Run a test only if the server version is at least ``version``.""" other_version = Version(*ver) return self.require( lambda: self.version >= other_version, "Server version must be at least %s" % str(other_version), ) def require_version_max(self, *ver): """Run a test only if the server version is at most ``version``.""" other_version = Version(*ver) return self.require( lambda: self.version <= other_version, "Server version must be at most %s" % str(other_version), ) def require_replica_set(self, func): """Run a test only if the client is connected to a replica set.""" return self.require( lambda: self.is_replica_set, "Not connected to a replica set", func=func ) def require_transactions(self, func): """Run a test only if the deployment might support transactions. *Might* because this does not test the FCV. """ return self.require(self.supports_transactions, "Transactions are not supported", func=func) def create_user(self, dbname, user, pwd=None, roles=None, **kwargs): kwargs["writeConcern"] = {"w": self.w} return create_user(self.sync_cx[dbname], user, pwd, roles, **kwargs) def drop_user(self, dbname, user): self.sync_cx[dbname].command("dropUser", user, writeConcern={"w": self.w}) env = TestEnvironment()
mongodb/motor
test/test_environment.py
Python
apache-2.0
11,605
#!/usr/bin/python # -*- coding: utf-8 -*- """Tests for the EWF image path specification implementation.""" import unittest from dfvfs.path import ewf_path_spec from tests.path import test_lib class EwfPathSpecTest(test_lib.PathSpecTestCase): """Tests for the EWF image path specification implementation.""" def testInitialize(self): """Tests the path specification initialization.""" path_spec = ewf_path_spec.EwfPathSpec(parent=self._path_spec) self.assertNotEqual(path_spec, None) with self.assertRaises(ValueError): _ = ewf_path_spec.EwfPathSpec(parent=None) with self.assertRaises(ValueError): _ = ewf_path_spec.EwfPathSpec(parent=self._path_spec, bogus=u'BOGUS') def testComparable(self): """Tests the path specification comparable property.""" path_spec = ewf_path_spec.EwfPathSpec(parent=self._path_spec) self.assertNotEqual(path_spec, None) expected_comparable = u'\n'.join([ u'type: TEST', u'type: EWF', u'']) self.assertEqual(path_spec.comparable, expected_comparable) if __name__ == '__main__': unittest.main()
manashmndl/dfvfs
tests/path/ewf_path_spec.py
Python
apache-2.0
1,121
import sys import urllib2 import HTMLParser import xml.etree.ElementTree as ET from logging import getLogger class Rss(object): """A class for handling RSS feeds""" def __init__(self,url=None): if not url: self.url = '' self.articles = '' else: self.url = url self.articles = [] self.logger = getLogger(__name__) def get_rss_into_articles(self): self.xml = urllib2.urlopen(self.url.encode('utf-8')).read() root = ET.fromstring(self.xml) for item in root.findall(".//item"): try: title = item.find("title") link = item.find("link") descr = item.find("description") pubDate = item.find("pubDate") strgDate = str(pubDate.text) article = Article(title.text,link.text,descr.text, strgDate) self.articles.append(article) except Exception as e: self.logger.error("Error in get_rss routine! Error report: " + e) return self.articles class Article(object): """A class for handling the details of an article""" def __init__(self): self.title = '' self.link = '' self.descr = '' self.pubDate = '' self.pic_links = [] self.logger = getLogger(__name__) def __init__(self, title,link,descr,pubDate): self.title = title self.link = link self.descr = descr self.pubDate = pubDate self.full_txt = "" self.pic_links = [] self.pics = [] def get_full_txt(self): try: response = urllib2.urlopen(self.link).read().decode('utf-8', 'ignore') parser = RssHTMLParser() parser.feed(response) self.pic_links = parser.img_links self.full_txt = parser.data except Exception as e: self.logger.error("Error in get_full_txt() of RssClass.Article Error: " + e) def get_photos(self, pic_links=None): pics = [] if pic_links == None: try: for link in self.pic_links: img = urllib2.urlopen(link).read() #f = open('/home/parallels/Desktop/pic.jpg', 'wb') #f.write(img) #f.close() self.pics.append(img) except Exception as e: self.logger.error("Error in RssClass.get_photos() using self.pic_links. Error: " + e) else: try: for link in pic_links: image = urllib2.urlopen(self.link).read() pics.append(image) except Exception as e: self.logger.error("Error in RssClass.get_photos() using pic_links. Error: " + e) return pics class RssHTMLParser(HTMLParser.HTMLParser): def __init__(self): HTMLParser.HTMLParser.__init__(self) self.is_start_p = False self.is_end_p = False self.is_start_sp = False self.data = "" self.img_links = [] def handle_starttag(self, tag, attrs): if tag == 'p': self.is_start_p = True elif tag == 'span': self.is_start_sp = True elif self.is_start_p and tag == 'a': self.is_start_p = True elif self.is_start_p and tag == 'img' or self.is_start_sp and tag == 'img': for attr in attrs: if attr[0] == 'src': self.img_links.append(attr[1]) else: self.is_start_p = False self.is_start_sp = False def handle_endtag(self, tag): if tag == 'p': self.is_start_p = False self.is_end_p = True elif tag == 'a' and self.is_start_p: self.is_start_p = True else: self.is_end_p = False def handle_data(self, data): if self.is_start_p: self.data += data elif self.is_end_p: self.data += ' '
rad08d/rssreader_flask
flask_rss/rssapp/rss.py
Python
apache-2.0
4,065
# Suite B tests # Copyright (c) 2014-2015, Jouni Malinen <j@w1.fi> # # This software may be distributed under the terms of the BSD license. # See README for more details. import time import logging logger = logging.getLogger() import hostapd from utils import HwsimSkip def test_suite_b(dev, apdev): """WPA2-PSK/GCMP connection at Suite B 128-bit level""" if "GCMP" not in dev[0].get_capability("pairwise"): raise HwsimSkip("GCMP not supported") if "BIP-GMAC-128" not in dev[0].get_capability("group_mgmt"): raise HwsimSkip("BIP-GMAC-128 not supported") if "WPA-EAP-SUITE-B" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("WPA-EAP-SUITE-B not supported") tls = dev[0].request("GET tls_library") if not tls.startswith("OpenSSL"): raise HwsimSkip("TLS library not supported for Suite B: " + tls); if "build=OpenSSL 1.0.2" not in tls or "run=OpenSSL 1.0.2" not in tls: raise HwsimSkip("OpenSSL version not supported for Suite B: " + tls) dev[0].flush_scan_cache() params = { "ssid": "test-suite-b", "wpa": "2", "wpa_key_mgmt": "WPA-EAP-SUITE-B", "rsn_pairwise": "GCMP", "group_mgmt_cipher": "BIP-GMAC-128", "ieee80211w": "2", "ieee8021x": "1", "openssl_ciphers": "SUITEB128", #"dh_file": "auth_serv/dh.conf", "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", "ca_cert": "auth_serv/ec-ca.pem", "server_cert": "auth_serv/ec-server.pem", "private_key": "auth_serv/ec-server.key" } hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B", ieee80211w="2", openssl_ciphers="SUITEB128", eap="TLS", identity="tls user", ca_cert="auth_serv/ec-ca.pem", client_cert="auth_serv/ec-user.pem", private_key="auth_serv/ec-user.key", pairwise="GCMP", group="GCMP", scan_freq="2412") tls_cipher = dev[0].get_status_field("EAP TLS cipher") if tls_cipher != "ECDHE-ECDSA-AES128-GCM-SHA256": raise Exception("Unexpected TLS cipher: " + tls_cipher) bss = dev[0].get_bss(apdev[0]['bssid']) if 'flags' not in bss: raise Exception("Could not get BSS flags from BSS table") if "[WPA2-EAP-SUITE-B-GCMP]" not in bss['flags']: raise Exception("Unexpected BSS flags: " + bss['flags']) dev[0].request("DISCONNECT") dev[0].wait_disconnected(timeout=20) dev[0].dump_monitor() dev[0].request("RECONNECT") ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"], timeout=20) if ev is None: raise Exception("Roaming with the AP timed out") if "CTRL-EVENT-EAP-STARTED" in ev: raise Exception("Unexpected EAP exchange") def test_suite_b_192(dev, apdev): """WPA2-PSK/GCMP-256 connection at Suite B 192-bit level""" if "GCMP-256" not in dev[0].get_capability("pairwise"): raise HwsimSkip("GCMP-256 not supported") if "BIP-GMAC-256" not in dev[0].get_capability("group_mgmt"): raise HwsimSkip("BIP-GMAC-256 not supported") if "WPA-EAP-SUITE-B-192" not in dev[0].get_capability("key_mgmt"): raise HwsimSkip("WPA-EAP-SUITE-B-192 not supported") tls = dev[0].request("GET tls_library") if not tls.startswith("OpenSSL"): raise HwsimSkip("TLS library not supported for Suite B: " + tls); if "build=OpenSSL 1.0.2" not in tls or "run=OpenSSL 1.0.2" not in tls: raise HwsimSkip("OpenSSL version not supported for Suite B: " + tls) dev[0].flush_scan_cache() params = { "ssid": "test-suite-b", "wpa": "2", "wpa_key_mgmt": "WPA-EAP-SUITE-B-192", "rsn_pairwise": "GCMP-256", "group_mgmt_cipher": "BIP-GMAC-256", "ieee80211w": "2", "ieee8021x": "1", "openssl_ciphers": "SUITEB192", "eap_server": "1", "eap_user_file": "auth_serv/eap_user.conf", "ca_cert": "auth_serv/ec2-ca.pem", "server_cert": "auth_serv/ec2-server.pem", "private_key": "auth_serv/ec2-server.key" } hapd = hostapd.add_ap(apdev[0]['ifname'], params) dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192", ieee80211w="2", openssl_ciphers="SUITEB192", eap="TLS", identity="tls user", ca_cert="auth_serv/ec2-ca.pem", client_cert="auth_serv/ec2-user.pem", private_key="auth_serv/ec2-user.key", pairwise="GCMP-256", group="GCMP-256", scan_freq="2412") tls_cipher = dev[0].get_status_field("EAP TLS cipher") if tls_cipher != "ECDHE-ECDSA-AES256-GCM-SHA384": raise Exception("Unexpected TLS cipher: " + tls_cipher) bss = dev[0].get_bss(apdev[0]['bssid']) if 'flags' not in bss: raise Exception("Could not get BSS flags from BSS table") if "[WPA2-EAP-SUITE-B-192-GCMP-256]" not in bss['flags']: raise Exception("Unexpected BSS flags: " + bss['flags']) dev[0].request("DISCONNECT") dev[0].wait_disconnected(timeout=20) dev[0].dump_monitor() dev[0].request("RECONNECT") ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED", "CTRL-EVENT-CONNECTED"], timeout=20) if ev is None: raise Exception("Roaming with the AP timed out") if "CTRL-EVENT-EAP-STARTED" in ev: raise Exception("Unexpected EAP exchange")
wangybgit/Chameleon
hostapd-OpenWrt/tests/hwsim/test_suite_b.py
Python
apache-2.0
5,735
import os import boto3 from chalice import Chalice from chalicelib import db from chalicelib import rekognition app = Chalice(app_name='media-query') _MEDIA_DB = None _REKOGNITION_CLIENT = None _SUPPORTED_IMAGE_EXTENSIONS = ( '.jpg', '.png', ) def get_media_db(): global _MEDIA_DB if _MEDIA_DB is None: _MEDIA_DB = db.DynamoMediaDB( boto3.resource('dynamodb').Table( os.environ['MEDIA_TABLE_NAME'])) return _MEDIA_DB def get_rekognition_client(): global _REKOGNITION_CLIENT if _REKOGNITION_CLIENT is None: _REKOGNITION_CLIENT = rekognition.RekognitonClient( boto3.client('rekognition')) return _REKOGNITION_CLIENT @app.on_s3_event(bucket=os.environ['MEDIA_BUCKET_NAME'], events=['s3:ObjectCreated:*']) def handle_object_created(event): if _is_image(event.key): _handle_created_image(bucket=event.bucket, key=event.key) @app.on_s3_event(bucket=os.environ['MEDIA_BUCKET_NAME'], events=['s3:ObjectRemoved:*']) def handle_object_removed(event): if _is_image(event.key): get_media_db().delete_media_file(event.key) def _is_image(key): return key.endswith(_SUPPORTED_IMAGE_EXTENSIONS) def _handle_created_image(bucket, key): labels = get_rekognition_client().get_image_labels(bucket=bucket, key=key) get_media_db().add_media_file(key, media_type=db.IMAGE_TYPE, labels=labels)
aws-samples/chalice-workshop
code/media-query/06-web-api/app.py
Python
apache-2.0
1,443
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """IoT Docker RPC handler.""" from docker import errors from oslo.config import cfg from iot.common import docker_utils from iot.openstack.common import log as logging LOG = logging.getLogger(__name__) CONF = cfg.CONF class Handler(object): def __init__(self): super(Handler, self).__init__() self._docker = None def _encode_utf8(self, value): return unicode(value).encode('utf-8') # Device operations def device_create(self, ctxt, name, device_uuid, device): LOG.debug('Creating device name %s' % (name)) def device_list(self, ctxt): LOG.debug("device_list") def device_delete(self, ctxt, device_uuid): LOG.debug("device_delete %s" % device_uuid) def device_show(self, ctxt, device_uuid): LOG.debug("device_show %s" % device_uuid)
digambar15/openstack-iot
iot/conductor/handlers/driver.py
Python
apache-2.0
1,411
# coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Fine-tunes an ELECTRA model on a downstream task.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import collections import json import tensorflow.compat.v1 as tf import configure_finetuning from finetune import preprocessing from finetune import task_builder from model import modeling from model import optimization from util import training_utils from util import utils class FinetuningModel(object): """Finetuning model with support for multi-task training.""" def __init__(self, config: configure_finetuning.FinetuningConfig, tasks, is_training, features, num_train_steps): # Create a shared transformer encoder bert_config = training_utils.get_bert_config(config) self.bert_config = bert_config if config.debug: bert_config.num_hidden_layers = 3 bert_config.hidden_size = 144 bert_config.intermediate_size = 144 * 4 bert_config.num_attention_heads = 4 assert config.max_seq_length <= bert_config.max_position_embeddings bert_model = modeling.BertModel( bert_config=bert_config, is_training=is_training, input_ids=features["input_ids"], input_mask=features["input_mask"], token_type_ids=features["segment_ids"], use_one_hot_embeddings=config.use_tpu, embedding_size=config.embedding_size) percent_done = (tf.cast(tf.train.get_or_create_global_step(), tf.float32) / tf.cast(num_train_steps, tf.float32)) # Add specific tasks self.outputs = {"task_id": features["task_id"]} losses = [] for task in tasks: with tf.variable_scope("task_specific/" + task.name): task_losses, task_outputs = task.get_prediction_module( bert_model, features, is_training, percent_done) losses.append(task_losses) self.outputs[task.name] = task_outputs self.loss = tf.reduce_sum( tf.stack(losses, -1) * tf.one_hot(features["task_id"], len(config.task_names))) def model_fn_builder(config: configure_finetuning.FinetuningConfig, tasks, num_train_steps, pretraining_config=None): """Returns `model_fn` closure for TPUEstimator.""" def model_fn(features, labels, mode, params): """The `model_fn` for TPUEstimator.""" utils.log("Building model...") is_training = (mode == tf.estimator.ModeKeys.TRAIN) model = FinetuningModel( config, tasks, is_training, features, num_train_steps) # Load pre-trained weights from checkpoint init_checkpoint = config.init_checkpoint if pretraining_config is not None: init_checkpoint = tf.train.latest_checkpoint(pretraining_config.model_dir) utils.log("Using checkpoint", init_checkpoint) tvars = tf.trainable_variables() scaffold_fn = None if init_checkpoint: assignment_map, _ = modeling.get_assignment_map_from_checkpoint( tvars, init_checkpoint) if config.use_tpu: def tpu_scaffold(): tf.train.init_from_checkpoint(init_checkpoint, assignment_map) return tf.train.Scaffold() scaffold_fn = tpu_scaffold else: tf.train.init_from_checkpoint(init_checkpoint, assignment_map) # Build model for training or prediction if mode == tf.estimator.ModeKeys.TRAIN: train_op = optimization.create_optimizer( model.loss, config.learning_rate, num_train_steps, weight_decay_rate=config.weight_decay_rate, use_tpu=config.use_tpu, warmup_proportion=config.warmup_proportion, layerwise_lr_decay_power=config.layerwise_lr_decay, n_transformer_layers=model.bert_config.num_hidden_layers ) output_spec = tf.estimator.tpu.TPUEstimatorSpec( mode=mode, loss=model.loss, train_op=train_op, scaffold_fn=scaffold_fn, training_hooks=[training_utils.ETAHook( {} if config.use_tpu else dict(loss=model.loss), num_train_steps, config.iterations_per_loop, config.use_tpu, 10)]) else: assert mode == tf.estimator.ModeKeys.PREDICT output_spec = tf.estimator.tpu.TPUEstimatorSpec( mode=mode, predictions=utils.flatten_dict(model.outputs), scaffold_fn=scaffold_fn) utils.log("Building complete") return output_spec return model_fn class ModelRunner(object): """Fine-tunes a model on a supervised task.""" def __init__(self, config: configure_finetuning.FinetuningConfig, tasks, pretraining_config=None): self._config = config self._tasks = tasks self._preprocessor = preprocessing.Preprocessor(config, self._tasks) is_per_host = tf.estimator.tpu.InputPipelineConfig.PER_HOST_V2 tpu_cluster_resolver = None if config.use_tpu and config.tpu_name: tpu_cluster_resolver = tf.distribute.cluster_resolver.TPUClusterResolver( config.tpu_name, zone=config.tpu_zone, project=config.gcp_project) tpu_config = tf.estimator.tpu.TPUConfig( iterations_per_loop=config.iterations_per_loop, num_shards=config.num_tpu_cores, per_host_input_for_training=is_per_host, tpu_job_name=config.tpu_job_name) run_config = tf.estimator.tpu.RunConfig( cluster=tpu_cluster_resolver, model_dir=config.model_dir, save_checkpoints_steps=config.save_checkpoints_steps, save_checkpoints_secs=None, tpu_config=tpu_config) if self._config.do_train: (self._train_input_fn, self.train_steps) = self._preprocessor.prepare_train() else: self._train_input_fn, self.train_steps = None, 0 model_fn = model_fn_builder( config=config, tasks=self._tasks, num_train_steps=self.train_steps, pretraining_config=pretraining_config) self._estimator = tf.estimator.tpu.TPUEstimator( use_tpu=config.use_tpu, model_fn=model_fn, config=run_config, train_batch_size=config.train_batch_size, eval_batch_size=config.eval_batch_size, predict_batch_size=config.predict_batch_size) def train(self): utils.log("Training for {:} steps".format(self.train_steps)) self._estimator.train( input_fn=self._train_input_fn, max_steps=self.train_steps) def evaluate(self): return {task.name: self.evaluate_task(task) for task in self._tasks} def evaluate_task(self, task, split="dev", return_results=True): """Evaluate the current model.""" utils.log("Evaluating", task.name) eval_input_fn, _ = self._preprocessor.prepare_predict([task], split) results = self._estimator.predict(input_fn=eval_input_fn, yield_single_examples=True) scorer = task.get_scorer() for r in results: if r["task_id"] != len(self._tasks): # ignore padding examples r = utils.nest_dict(r, self._config.task_names) scorer.update(r[task.name]) if return_results: utils.log(task.name + ": " + scorer.results_str()) utils.log() return dict(scorer.get_results()) else: return scorer def write_classification_outputs(self, tasks, trial, split): """Write classification predictions to disk.""" utils.log("Writing out predictions for", tasks, split) predict_input_fn, _ = self._preprocessor.prepare_predict(tasks, split) results = self._estimator.predict(input_fn=predict_input_fn, yield_single_examples=True) # task name -> eid -> model-logits logits = collections.defaultdict(dict) for r in results: if r["task_id"] != len(self._tasks): r = utils.nest_dict(r, self._config.task_names) task_name = self._config.task_names[r["task_id"]] logits[task_name][r[task_name]["eid"]] = ( r[task_name]["logits"] if "logits" in r[task_name] else r[task_name]["predictions"]) for task_name in logits: utils.log("Pickling predictions for {:} {:} examples ({:})".format( len(logits[task_name]), task_name, split)) if trial <= self._config.n_writes_test: utils.write_pickle(logits[task_name], self._config.test_predictions( task_name, split, trial)) def write_results(config: configure_finetuning.FinetuningConfig, results): """Write evaluation metrics to disk.""" utils.log("Writing results to", config.results_txt) utils.mkdir(config.results_txt.rsplit("/", 1)[0]) utils.write_pickle(results, config.results_pkl) with tf.io.gfile.GFile(config.results_txt, "w") as f: results_str = "" for trial_results in results: for task_name, task_results in trial_results.items(): if task_name == "time" or task_name == "global_step": continue results_str += task_name + ": " + " - ".join( ["{:}: {:.2f}".format(k, v) for k, v in task_results.items()]) + "\n" f.write(results_str) utils.write_pickle(results, config.results_pkl) def run_finetuning(config: configure_finetuning.FinetuningConfig): """Run finetuning.""" # Setup for training results = [] trial = 1 heading_info = "model={:}, trial {:}/{:}".format( config.model_name, trial, config.num_trials) heading = lambda msg: utils.heading(msg + ": " + heading_info) heading("Config") utils.log_config(config) generic_model_dir = config.model_dir tasks = task_builder.get_tasks(config) # Train and evaluate num_trials models with different random seeds while config.num_trials < 0 or trial <= config.num_trials: config.model_dir = generic_model_dir + "_" + str(trial) if config.do_train: utils.rmkdir(config.model_dir) model_runner = ModelRunner(config, tasks) if config.do_train: heading("Start training") model_runner.train() utils.log() if config.do_eval: heading("Run dev set evaluation") results.append(model_runner.evaluate()) write_results(config, results) if config.write_test_outputs and trial <= config.n_writes_test: heading("Running on the test set and writing the predictions") for task in tasks: # Currently only writing preds for GLUE and SQuAD 2.0 is supported if task.name in ["cola", "mrpc", "mnli", "sst", "rte", "qnli", "qqp", "sts"]: for split in task.get_test_splits(): model_runner.write_classification_outputs([task], trial, split) elif task.name == "squad": scorer = model_runner.evaluate_task(task, "test", False) scorer.write_predictions() preds = utils.load_json(config.qa_preds_file("squad")) null_odds = utils.load_json(config.qa_na_file("squad")) for q, _ in preds.items(): if null_odds[q] > config.qa_na_threshold: preds[q] = "" utils.write_json(preds, config.test_predictions( task.name, "test", trial)) else: utils.log("Skipping task", task.name, "- writing predictions is not supported for this task") if trial != config.num_trials and (not config.keep_all_models): utils.rmrf(config.model_dir) trial += 1 def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--data-dir", required=True, help="Location of data files (model weights, etc).") parser.add_argument("--model-name", required=True, help="The name of the model being fine-tuned.") parser.add_argument("--hparams", default="{}", help="JSON dict of model hyperparameters.") args = parser.parse_args() if args.hparams.endswith(".json"): hparams = utils.load_json(args.hparams) else: hparams = json.loads(args.hparams) tf.logging.set_verbosity(tf.logging.ERROR) run_finetuning(configure_finetuning.FinetuningConfig( args.model_name, args.data_dir, **hparams)) if __name__ == "__main__": main()
google-research/electra
run_finetuning.py
Python
apache-2.0
12,663
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Various classes representing distributed values.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import copy from tensorflow.python.distribute import device_util from tensorflow.python.distribute import distribute_lib from tensorflow.python.distribute import distribution_strategy_context as ds_context from tensorflow.python.distribute import packed_distributed_variable as packed from tensorflow.python.distribute import reduce_util from tensorflow.python.distribute import values_util from tensorflow.python.eager import context from tensorflow.python.framework import composite_tensor from tensorflow.python.framework import ops from tensorflow.python.framework import type_spec from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import variable_scope as vs from tensorflow.python.ops import variables as variables_lib from tensorflow.python.saved_model import save_context from tensorflow.python.training.saving import saveable_object from tensorflow.python.training.tracking import base as trackable from tensorflow.python.types import core from tensorflow.python.util.tf_export import tf_export def _on_write_update_replica(var, update_fn, value, **kwargs): """Updates variables with ON_WRITE synchronization in replica context.""" if var.aggregation == vs.VariableAggregation.NONE: return update_fn(var._get_on_device_or_primary(), value, **kwargs) # pylint: disable=protected-access def merge_fn(strategy, value, **kwargs): """Aggregate values and update all variables in cross replica context.""" # Don't allow MEAN with non float dtype, since it may cause unexpected # precision loss. Python3 and NumPy automatically upcast integers to # float in division, but we should always preserve the type. # # Note that to be backward compatible we allow the case when the value # is *always* the same on each replica. I.E. value is not a # PerReplica. Refer to regroup() to see how values are grouped. if var.aggregation == vs.VariableAggregation.MEAN and ( not var.dtype.is_floating) and isinstance(value, PerReplica): raise ValueError( "Cannot update non-float variables with " "tf.VariableAggregation.MEAN aggregation in replica context. " "Either change the variable dtype to float or update it in " "cross-replica context.") assert strategy == var.distribute_strategy v = values_util.apply_aggregation(strategy, value, var.aggregation, var) return var._update_cross_replica(update_fn, v, **kwargs) # pylint: disable=protected-access return ds_context.get_replica_context().merge_call( merge_fn, args=(value,), kwargs=kwargs) @tf_export("distribute.DistributedValues", v1=[]) class DistributedValues(object): """Base class for representing distributed values. A subclass instance of `tf.distribute.DistributedValues` is created when creating variables within a distribution strategy, iterating a `tf.distribute.DistributedDataset` or through `tf.distribute.Strategy.run`. This base class should never be instantiated directly. `tf.distribute.DistributedValues` contains a value per replica. Depending on the subclass, the values could either be synced on update, synced on demand, or never synced. `tf.distribute.DistributedValues` can be reduced to obtain single value across replicas, as input into `tf.distribute.Strategy.run` or the per-replica values inspected using `tf.distribute.Strategy.experimental_local_results`. Example usage: 1. Created from a `tf.distribute.DistributedDataset`: >>> strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"]) >>> dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2) >>> dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset)) >>> distributed_values = next(dataset_iterator) 2. Returned by `run`: >>> strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"]) >>> @tf.function ... def run(): ... ctx = tf.distribute.get_replica_context() ... return ctx.replica_id_in_sync_group >>> distributed_values = strategy.run(run) 3. As input into `run`: >>> strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"]) >>> dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2) >>> dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset)) >>> distributed_values = next(dataset_iterator) >>> @tf.function ... def run(input): ... return input + 1.0 >>> updated_value = strategy.run(run, args=(distributed_values,)) 4. Reduce value: >>> strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"]) >>> dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2) >>> dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset)) >>> distributed_values = next(dataset_iterator) >>> reduced_value = strategy.reduce(tf.distribute.ReduceOp.SUM, ... distributed_values, ... axis = 0) 5. Inspect local replica values: >>> strategy = tf.distribute.MirroredStrategy(["GPU:0", "GPU:1"]) >>> dataset = tf.data.Dataset.from_tensor_slices([5., 6., 7., 8.]).batch(2) >>> dataset_iterator = iter(strategy.experimental_distribute_dataset(dataset)) >>> per_replica_values = strategy.experimental_local_results( ... distributed_values) >>> per_replica_values (<tf.Tensor: shape=(1,), dtype=float32, numpy=array([5.], dtype=float32)>, <tf.Tensor: shape=(1,), dtype=float32, numpy=array([6.], dtype=float32)>) """ def __init__(self, values): """Should only be called by subclass __init__.""" self._values = tuple(values) def _get(self): """Returns the value for the current device or raises a ValueError.""" replica_id = values_util.get_current_replica_id_as_int() if replica_id is None: return self._get_cross_replica() else: return self._values[replica_id] def _get_cross_replica(self): raise NotImplementedError( "This method should be overridden by sub-classes which support cross-" "replica accesses.") def _get_on_device_or_primary(self): """Returns value in same replica or device if possible, else the _primary.""" replica_id = values_util.get_current_replica_id_as_int() if replica_id is None: # Try to find a value on the current device. current_device = device_util.canonicalize(device_util.current()) for value in self._values: if device_util.canonicalize(value.device) == current_device: return value return self._primary else: return self._values[replica_id] @property def _primary(self): """Returns a representative component.""" return self._values[0] @property def _devices(self): return tuple(v.device for v in self._values) def __str__(self): debug_str = ",\n".join( " %d: %s" % (i, v) for i, v in enumerate(self._values)) return "%s:{\n%s\n}" % (self.__class__.__name__, debug_str) def __repr__(self): debug_repr = ",\n".join( " %d: %r" % (i, v) for i, v in enumerate(self._values)) return "%s:{\n%s\n}" % (self.__class__.__name__, debug_repr) # NOTE(josh11b,apassos): It would be great if we could inspect the values this was # initialized with and use that to generate the overloaded operators here. # Unfortunately, Python's rules for special methods don't allow this, see # https://docs.python.org/3/reference/datamodel.html#special-method-names # "if a class defines a method named __getitem__(), and x is an instance of # this class, then x[i] is roughly equivalent to type(x).__getitem__(x, i)." # In particular, these special methods don't go through __getattr__, and # it will only use those methods if they are defined in the class, not the # object. class DistributedDelegate(DistributedValues): """A map from device to values; acts as the same type as the values.""" def __getattr__(self, name): # The '_use_resource_variables' and the attrs starts with '_self' are used # for restoring the saved_model proto, and '_attribute_sentinel' is used for # Layer tracking. At the point these attrs are queried, the variable has not # been initialized. Thus it should not query those of the underlying # components. if name.startswith("_self_") or name in ("_use_resource_variables", "_attribute_sentinel", "_distributed_container"): return super(DistributedDelegate, self).__getattr__(name) # This allows copy.copy(DistributedDelegate). When copying an object, # copy.copy doesn't invoke its __init__ method, instead it makes a new # empty object, then copies the attributes over. copy.copy looks for # attributes like "__getstate__" in case the object implements its custom # copying. Since DistributedDelegate doesn't have those attributes defined, # __getattr__ will be invoked, which tries to access "_values" attributes, # but that doesn't exist either because this is an empty object, and again # __getattr__ is invoked, leading to an infinite recursion. if name == "_values": raise AttributeError() # TODO(priyag): This needs to be made robust against pitfalls from mix use # __getattr__ and @property. See b/120402273. return getattr(self._get(), name) @property def values(self): """Returns the per replica values.""" return self._values def _get_as_operand(self): """Returns the value for operations for the current device. Some implementations, e.g. `TPUMirroredVariable`, are not able to return the value type within a replica context. They can, however, return a value that can be used by the operations below. """ return self._get() # pylint: disable=multiple-statements def __add__(self, o): return self._get_as_operand() + o def __radd__(self, o): return o + self._get_as_operand() def __sub__(self, o): return self._get_as_operand() - o def __rsub__(self, o): return o - self._get_as_operand() def __mul__(self, o): return self._get_as_operand() * o def __rmul__(self, o): return o * self._get_as_operand() def __truediv__(self, o): return self._get_as_operand() / o def __rtruediv__(self, o): return o / self._get_as_operand() def __floordiv__(self, o): return self._get_as_operand() // o def __rfloordiv__(self, o): return o // self._get_as_operand() def __mod__(self, o): return self._get_as_operand() % o def __rmod__(self, o): return o % self._get_as_operand() def __lt__(self, o): return self._get_as_operand() < o def __le__(self, o): return self._get_as_operand() <= o def __gt__(self, o): return self._get_as_operand() > o def __ge__(self, o): return self._get_as_operand() >= o def __and__(self, o): return self._get_as_operand() & o def __rand__(self, o): return o & self._get_as_operand() def __or__(self, o): return self._get_as_operand() | o def __ror__(self, o): return o | self._get_as_operand() def __xor__(self, o): return self._get_as_operand() ^ o def __rxor__(self, o): return o ^ self._get_as_operand() def __getitem__(self, o): return self._get_as_operand()[o] def __pow__(self, o, modulo=None): return pow(self._get_as_operand(), o, modulo) def __rpow__(self, o): return pow(o, self._get_as_operand()) def __invert__(self): return ~self._get_as_operand() def __neg__(self): return -self._get_as_operand() def __abs__(self): return abs(self._get_as_operand()) def __div__(self, o): try: return self._get_as_operand().__div__(o) except AttributeError: # See https://docs.python.org/3/library/constants.html#NotImplemented return NotImplemented def __rdiv__(self, o): try: return self._get_as_operand().__rdiv__(o) except AttributeError: # See https://docs.python.org/3/library/constants.html#NotImplemented return NotImplemented def __matmul__(self, o): try: return self._get_as_operand().__matmul__(o) except AttributeError: # See https://docs.python.org/3/library/constants.html#NotImplemented return NotImplemented def __rmatmul__(self, o): try: return self._get_as_operand().__rmatmul__(o) except AttributeError: # See https://docs.python.org/3/library/constants.html#NotImplemented return NotImplemented # TODO(josh11b): Even more operator overloads. class PerReplica(DistributedValues, composite_tensor.CompositeTensor): """Holds a map from replica to unsynchronized values.""" @property def _type_spec(self): return PerReplicaSpec( *(type_spec.type_spec_from_value(v) for v in self._values)) @property def values(self): """Returns the per replica values.""" return self._values class PerReplicaSpec(type_spec.TypeSpec): """Type specification for a `PerReplica`.""" __slots__ = ["_value_specs"] value_type = property(lambda self: PerReplica) def __init__(self, *value_specs): self._value_specs = tuple(value_specs) def _serialize(self): return self._value_specs @property def _component_specs(self): return self._value_specs def _to_components(self, value): replica_context = ds_context.get_replica_context() if replica_context is not None and replica_context.num_replicas_in_sync > 1: raise ValueError( "Flattening a PerReplica to components is not supported in replica " "context.") return value._values # pylint: disable=protected-access def _from_components(self, tensor_list): return PerReplica(tensor_list) # Note that unlike PerReplica, Mirrored values inherit from # DistributedDelegate and so can be used directly in cross-replica mode. # TODO(tomhennigan) Should this extend CompositeTensor? class Mirrored(DistributedDelegate): """Holds a map from replica to values which are kept in sync.""" def _get_cross_replica(self): return self._get_on_device_or_primary() def _as_graph_element(self): obj = self._get() conv_fn = getattr(obj, "_as_graph_element", None) if conv_fn and callable(conv_fn): return conv_fn() return obj class DistributedVarOp(object): """A class that looks like `tf.Operation`.""" def __init__(self, name, graph, traceback, typ): self.name = name self.graph = graph self.traceback = traceback self.type = typ def __eq__(self, o): if not isinstance(o, self.__class__): raise NotImplementedError return (self.name == o.name and self.graph == o.graph and self.traceback == o.traceback and self.type == o.type) def __hash__(self): return hash((self.name, self.graph, tuple(self.traceback), self.type)) class DistributedVariable(DistributedDelegate, variables_lib.Variable, core.Tensor): """Holds a map from replica to variables.""" def __init__(self, strategy, values, aggregation, var_policy=None): self._distribute_strategy = strategy self._aggregation = aggregation super(DistributedVariable, self).__init__(values) self._common_name = self._primary.name.split(":")[0] # Packed variable is used to reduce the overhead of function execution. # For a DistributedVariable, only one variable handle is captured into a # function graph. It's only supported in eager mode. if ops.executing_eagerly_outside_functions() and getattr( strategy, "_enable_packed_variable_in_eager_mode", False): name = "%s/packed/" % self._common_name self._packed_var = packed.PackedDistributedVariable(values, name=name) else: self._packed_var = None # tf.keras keeps track of variables initialized using this attribute. When # tf.keras gets the default session, it initializes all uninitialized vars. # We need to make _keras_initialized a member of DistributedVariable because # without this it will use `__getattr__` which will delegate to a component # variable. self._keras_initialized = False # Typically, a `DistributedVariable`'s initializer is composed of the # initializers of the components variables. However, in some cases, such as # when restoring from a checkpoint, we may set the _initializer_op # property on the entire `DistributedVariable`. self._initializer_op = None # Set a VariablePolicy which decides how we replicate/aggregate the given # variable. self._policy = var_policy def __deepcopy__(self, memo): """Perform a deepcopy of the `DistributedVariable`. Unlike the deepcopy of a regular tf.Variable, this keeps the original strategy and devices of the `DistributedVariable`. To avoid confusion with the behavior of deepcopy on a regular `Variable` (which does copy into new devices), we only allow a deepcopy of a `DistributedVariable` within its originating strategy scope. Args: memo: The memoization object for `deepcopy`. Returns: A deep copy of the current `DistributedVariable`. Raises: RuntimeError: If trying to deepcopy into a different strategy. """ with ds_context.enter_or_assert_strategy(self._distribute_strategy): new_values = [] for value in self._values: with ops.device(value.device): new_values.append(copy.deepcopy(value, memo)) copied_variable = type(self)( strategy=self._distribute_strategy, values=new_values, aggregation=self._aggregation, var_policy=copy.deepcopy(self._policy, memo)) memo[id(self)] = copied_variable return copied_variable def _use_packed_variable(self): # Don't use packed variable when under a SaveContext to avoid explicit # device placement on variable consuming ops. return self._packed_var is not None and not save_context.in_save_context() def is_initialized(self, name=None): """Identifies if all the component variables are initialized. Args: name: Name of the final `logical_and` op. Returns: The op that evaluates to True or False depending on if all the component variables are initialized. """ if values_util.is_saving_non_distributed(): return self._primary.is_initialized() if self._use_packed_variable(): return self._packed_var.is_initialized() result = self._primary.is_initialized() # We iterate through the list of values except the last one to allow us to # name the final `logical_and` op the same name that is passed by the user # to the `is_initialized` op. For distributed variables, the # `is_initialized` op is a `logical_and` op. for v in self._values[1:-1]: result = math_ops.logical_and(result, v.is_initialized()) result = math_ops.logical_and( result, self._values[-1].is_initialized(), name=name) return result @property def initializer(self): if values_util.is_saving_non_distributed(): return self._primary.initializer if self._initializer_op: init_op = self._initializer_op else: # return grouped ops of all the var initializations of component values of # the mirrored variable init_op = control_flow_ops.group( tuple(v.initializer for v in self._values)) return init_op def initialized_value(self): return self._get_on_device_or_primary().initialized_value() @property def initial_value(self): return self._get_on_device_or_primary().initial_value @property def constraint(self): return self._primary.constraint @property def graph(self): return self._primary.graph @property def _shared_name(self): return self._common_name @property def _unique_id(self): return self._primary._unique_id # pylint: disable=protected-access @property def _graph_key(self): """Lets Optimizers know which graph this variable is from.""" return self._primary._graph_key # pylint: disable=protected-access @property def name(self): return self._primary.name @property def dtype(self): return self._primary.dtype @property def shape(self): return self._primary.shape @property def synchronization(self): return self._primary.synchronization @property def aggregation(self): return self._aggregation @property def _packed_variable(self): if self._use_packed_variable(): return self._packed_var return None @property def handle(self): if values_util.is_saving_non_distributed(): return self._primary.handle replica_id = values_util.get_current_replica_id_as_int() if replica_id is None: raise ValueError("`handle` is not available outside the replica context" " or a `tf.distribute.Strategy.update()` call.") else: if self._use_packed_variable(): return self._packed_var.handle return self._values[replica_id].handle def eval(self, session=None): return self._get_on_device_or_primary().eval(session) @property def _save_slice_info(self): return self._primary._save_slice_info # pylint: disable=protected-access def _get_save_slice_info(self): return self._primary._get_save_slice_info() # pylint: disable=protected-access def _set_save_slice_info(self, save_slice_info): for v in self._values: v._set_save_slice_info(save_slice_info) # pylint: disable=protected-access @property def device(self): return self._get_on_device_or_primary().device @property def trainable(self): return self._primary.trainable @property def distribute_strategy(self): return self._distribute_strategy def get_shape(self): return self._primary.get_shape() def to_proto(self, export_scope=None): return self._primary.to_proto(export_scope=export_scope) @property def op(self): if values_util.is_saving_non_distributed(): return self._primary.op # We want cross-replica code that does some var.op.X calls # to work (even if the current device isn't in self._devices), but # other uses of var.op in a cross-replica context to fail. if ds_context.in_cross_replica_context(): return DistributedVarOp(self._primary.op.name, self._primary.op.graph, self._primary.op.traceback, self._primary.op.type) return self._get().op @property def _in_graph_mode(self): return self._primary._in_graph_mode # pylint: disable=protected-access def _get_replica(self, replica_id): """Returns the value on a device with the given replica_id.""" if self._use_packed_variable(): return self._packed_var.on_device(self._devices[replica_id]) return self._values[replica_id] def _get(self): """Returns the value for the current device or raises a ValueError.""" if values_util.is_saving_non_distributed(): return self._primary replica_id = values_util.get_current_replica_id_as_int() if replica_id is None: return self._get_cross_replica() else: return self._get_replica(replica_id) def _get_on_device_or_primary(self): """Returns value in same replica or device if possible, else the _primary.""" if values_util.is_saving_non_distributed(): return self._primary replica_id = values_util.get_current_replica_id_as_int() if replica_id is None: # Try to find a value on the current device. current_device = device_util.canonicalize(device_util.current()) for i, value in enumerate(self._values): if device_util.canonicalize(value.device) == current_device: return self._get_replica(i) return self._get_replica(0) else: return self._get_replica(replica_id) def read_value(self): if values_util.is_saving_non_distributed(): return self._primary.read_value() with ds_context.enter_or_assert_strategy(self._distribute_strategy): return array_ops.identity(self._get()) def value(self): if values_util.is_saving_non_distributed(): return self._primary.value() if self._policy: return self._policy.value(self) return self._get_on_device_or_primary().value() def numpy(self): if context.executing_eagerly(): return self.read_value().numpy() else: raise NotImplementedError( "numpy() is only available when eager execution is enabled.") def assign_sub(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign_sub(value, use_locking, name, read_value) if self._policy: return self._policy.assign_sub( self, value, use_locking=use_locking, name=name, read_value=read_value) return values_util.on_write_assign_sub( self, value, use_locking=use_locking, name=name, read_value=read_value) def assign_add(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign_add(value, use_locking, name, read_value) if self._policy: return self._policy.assign_add( self, value, use_locking=use_locking, name=name, read_value=read_value) return values_util.on_write_assign_add( self, value, use_locking=use_locking, name=name, read_value=read_value) def assign(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign(value, use_locking, name, read_value) if self._policy: return self._policy.assign( self, value, use_locking=use_locking, name=name, read_value=read_value) return values_util.on_write_assign( self, value, use_locking=use_locking, name=name, read_value=read_value) def scatter_sub(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_sub(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_sub( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_sub( self, sparse_delta, use_locking=use_locking, name=name) def scatter_add(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_add(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_add( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_add( self, sparse_delta, use_locking=use_locking, name=name) def scatter_mul(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_mul(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_mul( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_mul( self, sparse_delta, use_locking=use_locking, name=name) def scatter_div(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_div(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_div( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_div( self, sparse_delta, use_locking=use_locking, name=name) def scatter_min(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_min(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_min( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_min( self, sparse_delta, use_locking=use_locking, name=name) def scatter_max(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_max(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_max( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_max( self, sparse_delta, use_locking=use_locking, name=name) def scatter_update(self, sparse_delta, use_locking=False, name=None): if values_util.is_saving_non_distributed(): return self._primary.scatter_update(sparse_delta, use_locking, name) if self._policy: return self._policy.scatter_update( self, sparse_delta, use_locking=use_locking, name=name) return values_util.scatter_update( self, sparse_delta, use_locking=use_locking, name=name) def _gather_saveables_for_checkpoint(self): """Overrides Trackable method. This allows both name-based and object-based save and restore of DistributedVariables. Returns: A dictionary mapping attribute names to `SaveableObject` factories. """ def _saveable_factory(name=self._common_name): return _DistributedVariableSaveable(self, self._primary, name) return {trackable.VARIABLE_VALUE_KEY: _saveable_factory} def _as_graph_element(self): if values_util.is_saving_non_distributed(): return self._primary._as_graph_element() # pylint: disable=protected-access if self._policy: return self._policy._as_graph_element(self) # pylint: disable=protected-access raise NotImplementedError("No policy set for calling _as_graph_element.") def _get_cross_replica(self): if values_util.is_saving_non_distributed(): return self._primary if self._policy: return self._policy._get_cross_replica(self) # pylint: disable=protected-access raise NotImplementedError( "This method should be overridden by sub-classes which support cross-" "replica accesses.") def _update_cross_replica(self, update_fn, value, **kwargs): """Applies updates across replicas. Args: update_fn: A callable to pass to `strategy.extended.update` to update the variable. It should has the same signature as `Variable.assign()`. value: value to be passed to `update_fn`. **kwargs: remaining arguments to `update_fn`. Returns: Updated variable or `tf.Operation`. """ return self.distribute_strategy.extended.update( self, update_fn, args=(value,), kwargs=kwargs, group=True) def _update_replica(self, update_fn, value, **kwargs): """Applies updates in one replica. Args: update_fn: A callable to update the variable. It should has the same signature as `Variable.assign()`. value: value to be passed to `update_fn`. **kwargs: remaining arguments to `update_fn`. Returns: Updated variable or `tf.Operation`. """ if self._policy: return self._policy._update_replica(self, update_fn, value, **kwargs) # pylint: disable=protected-access raise NotImplementedError("should be implemented by subclass.") def _update(self, update_fn, value, **kwargs): """Applies updates depending on the context. The method calls `_update_replica` in replica context, `_update_cross_replica` in cross replica context, and `update_fn` in update context. If `read_value` is True, the method returns the updated Variable. If `read_value` is False, the method returns the update `tf.Operation`. Args: update_fn: A callable to pass to `strategy.extended.update` to update the variable. It should have the same signature as `Variable.assign()`. value: value to be passed to `update_fn`. **kwargs: keyword arguments to `update_fn`. Returns: Updated variable or `tf.Operation`. """ if values_util.is_saving_non_distributed(): return update_fn(self._primary, value, **kwargs) with ds_context.enter_or_assert_strategy(self.distribute_strategy): if ds_context.in_cross_replica_context(): update_replica_id = distribute_lib.get_update_replica_id() if update_replica_id is not None: replica_value = self._get_replica(update_replica_id) return update_fn(replica_value, value, **kwargs) return self._update_cross_replica(update_fn, value, **kwargs) else: values_util.assert_replica_context(self.distribute_strategy) return self._update_replica(update_fn, value, **kwargs) def _should_act_as_resource_variable(self): """Pass resource_variable_ops.is_resource_variable check.""" pass def _dense_var_to_tensor(self, dtype=None, name=None, as_ref=False): """Converts a variable to a tensor.""" if values_util.is_saving_non_distributed(): return ops.convert_to_tensor( self._primary, dtype=dtype, name=name, as_ref=as_ref) with ds_context.enter_or_assert_strategy(self._distribute_strategy): return ops.convert_to_tensor( self._get(), dtype=dtype, name=name, as_ref=as_ref) def _map_resources(self, save_options): """For implementing `Trackable`.""" # Initialize for self._primary first, so that obj_map[self._primary] and # resource_map[self._primary.handle] contain mapped values. obj_map, resource_map = self._primary._map_resources(save_options) # pylint:disable=protected-access for v in [v for v in self._values if v != self._primary]: if (save_options.experimental_variable_policy # pylint:disable=protected-access ._expand_distributed_variables()): v_obj_map, v_resource_map = v._map_resources(save_options) # pylint:disable=protected-access obj_map.update(v_obj_map) resource_map.update(v_resource_map) else: obj_map[v] = obj_map[self._primary] resource_map[v.handle] = resource_map[self._primary.handle] obj_map[self] = obj_map[self._primary] resource_map[self] = resource_map[self._primary.handle] if self._packed_var is not None: resource_map[self._packed_var.packed_handle] = resource_map[ self._primary.handle] return obj_map, resource_map # We extend from `saveable_object.SaveableObject` instead of # `saveable_object_util.ResourceVariableSaveable` since we need to read the # value of ONREAD variables when saving. `SaveableObject` provides a way to # specify the function to run to get the value of the variable or tensor at # saving time. We can use this for both ON_READ and ON_WRITE variables. # TODO(b/164586507): Consolidate ON_WRITE and ON_READ saving/restoring logic # if possible. class _DistributedVariableSaveable(saveable_object.SaveableObject): """Class for defining how to restore a DistributedVariable.""" def __init__(self, distributed_variable, primary_variable, name): self._distributed_variable = distributed_variable if not self._distributed_variable._policy: raise ValueError("VariablePolicy has not been set for the distributed " "variable.") tensor, spec = distributed_variable._policy.get_saveable( distributed_variable, primary_variable, name) super(_DistributedVariableSaveable, self).__init__(tensor, spec, name) def restore(self, restored_tensors, restored_shapes): """Restore the same value into all variables.""" tensor, = restored_tensors return self._distributed_variable._policy.get_restore_ops( # pylint: disable=protected-access self._distributed_variable, tensor) class _MirroredSaveable(saveable_object.SaveableObject): """Class for defining how to restore a MirroredVariable.""" def __init__(self, mirrored_variable, primary_variable, name): self._mirrored_variable = mirrored_variable tensor, spec = values_util.get_on_write_saveable(self._mirrored_variable, primary_variable, name) super(_MirroredSaveable, self).__init__(tensor, spec, name) def restore(self, restored_tensors, restored_shapes): """Restore the same value into all variables.""" tensor, = restored_tensors return values_util.get_on_write_restore_ops(self._mirrored_variable, tensor) class MirroredVariable(DistributedVariable, Mirrored): """Holds a map from replica to variables whose values are kept in sync.""" def _update_replica(self, update_fn, value, **kwargs): return _on_write_update_replica(self, update_fn, value, **kwargs) def scatter_min(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_min(*args, **kwargs) if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_min", aggregation=self._aggregation)) return super(MirroredVariable, self).scatter_min(*args, **kwargs) def scatter_max(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_max(*args, **kwargs) if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_max", aggregation=self._aggregation)) return super(MirroredVariable, self).scatter_max(*args, **kwargs) def scatter_update(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_update(*args, **kwargs) if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_update", aggregation=self._aggregation)) return super(MirroredVariable, self).scatter_update(*args, **kwargs) def _get_cross_replica(self): # Return identity, to avoid directly exposing the variable to the user and # allowing it to be modified by mistake. return array_ops.identity(Mirrored._get_cross_replica(self)) def _as_graph_element(self): return self._get_on_device_or_primary()._as_graph_element() # pylint: disable=protected-access def _gather_saveables_for_checkpoint(self): """Overrides Trackable method. This allows both name-based and object-based save and restore of MirroredVariables. Returns: A dictionary mapping attribute names to `SaveableObject` factories. """ def _saveable_factory(name=self._common_name): return _MirroredSaveable(self, self._primary, name) return {trackable.VARIABLE_VALUE_KEY: _saveable_factory} def _dense_var_to_tensor(self, dtype=None, name=None, as_ref=False): """Converts a variable to a tensor.""" # TODO(b/154017756): Make _dense_var_to_tensor consistent between ON_READ # and ON_WRITE. # Try to avoid assignments to and other mutations of MirroredVariable # state except through a DistributionStrategy.extended.update() or any of # the `assign*` and `scatter*` calls. if as_ref: # A TF 1.x case where the variable is a boolean variable and used like: # tf.cond(v, true_fn, false_fn). raise ValueError( "You may be using variable created under distribute strategy in TF " "1.x control flows. Try explicitly converting the variable to Tensor " "using variable.read_value(), or switch to TF 2.x.") return ops.convert_to_tensor( self._get(), dtype=dtype, name=name, as_ref=as_ref) class _SyncOnReadSaveable(saveable_object.SaveableObject): """Class for defining how to restore a SyncOnReadVariable.""" def __init__(self, sync_on_read_variable, name): self._sync_on_read_variable = sync_on_read_variable tensor, spec = values_util.get_on_read_saveable( sync_on_read_variable, sync_on_read_variable._primary, name) super(_SyncOnReadSaveable, self).__init__(tensor, spec, name) def restore(self, restored_tensors, restored_shapes): """Restore the same value into all variables.""" tensor, = restored_tensors return values_util.get_on_read_restore_ops( self._sync_on_read_variable, tensor, self._sync_on_read_variable.aggregation) class SyncOnReadVariable(DistributedVariable): """Holds a map from replica to variables whose values are reduced on save.""" def _update_replica(self, update_fn, value, **kwargs): return update_fn(self._get_on_device_or_primary(), value, **kwargs) # TODO(b/154017756): Make assign behaivor in cross replica context consistent # with MirroredVariable. def assign_sub(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign_sub(value, use_locking, name, read_value) with ds_context.enter_or_assert_strategy(self._distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_sub_cross_replica( self, value, read_value=read_value) else: return super(SyncOnReadVariable, self).assign_sub(value, use_locking, name, read_value) def assign_add(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign_add(value, use_locking, name, read_value) with ds_context.enter_or_assert_strategy(self._distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_add_cross_replica( self, value, read_value=read_value) else: return super(SyncOnReadVariable, self).assign_add(value, use_locking, name, read_value) def assign(self, value, use_locking=False, name=None, read_value=True): if values_util.is_saving_non_distributed(): return self._primary.assign(value, use_locking, name, read_value) with ds_context.enter_or_assert_strategy(self._distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_cross_replica( self, value, read_value=read_value) else: return super(SyncOnReadVariable, self).assign(value, use_locking, name, read_value) def _scatter_not_implemented(self, method): raise NotImplementedError( "Variables with `synchronization=ON_READ` doesn't support `%s`" % method) def scatter_sub(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_sub(*args, **kwargs) self._scatter_not_implemented("scatter_sub") def scatter_add(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_add(*args, **kwargs) self._scatter_not_implemented("scatter_add") def scatter_mul(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_mul(*args, **kwargs) self._scatter_not_implemented("scatter_mul") def scatter_div(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_div(*args, **kwargs) self._scatter_not_implemented("scatter_div") def scatter_min(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_min(*args, **kwargs) self._scatter_not_implemented("scatter_min") def scatter_max(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_max(*args, **kwargs) self._scatter_not_implemented("scatter_max") def scatter_update(self, *args, **kwargs): if values_util.is_saving_non_distributed(): return self._primary.scatter_update(*args, **kwargs) self._scatter_not_implemented("scatter_update") def value(self): if values_util.is_saving_non_distributed(): return self._primary.value() with ds_context.enter_or_assert_strategy(self._distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): if self._aggregation == vs.VariableAggregation.ONLY_FIRST_REPLICA: return self._get_replica(0).value() return self._get_cross_replica() else: # _get_on_device_or_primary() returns a Variable. return self._get_on_device_or_primary().value() def _get_cross_replica(self): if self._aggregation == vs.VariableAggregation.ONLY_FIRST_REPLICA: # Consider returning a tensor value here to make the return value of # _get_cross_replica consistent. return self._get_replica(0) with ds_context.enter_or_assert_strategy(self._distribute_strategy): return self._distribute_strategy.reduce( reduce_util.ReduceOp.from_variable_aggregation(self._aggregation), self, axis=None) def _as_graph_element(self): if values_util.is_saving_non_distributed(): return self._primary._as_graph_element() # pylint: disable=protected-access # pylint: disable=protected-access with ds_context.enter_or_assert_strategy(self._distribute_strategy): if ds_context.in_cross_replica_context(): return ops.convert_to_tensor(self._get_cross_replica()) return self._get()._as_graph_element() def _gather_saveables_for_checkpoint(self): """Overrides Trackable method. This allows both name-based and object-based save and restore of `SyncOnReadVariable`s. Returns: A dictionary mapping attribute names to `SaveableObject` factories. """ def _saveable_factory(name=self._common_name): return _SyncOnReadSaveable(self, name) return {trackable.VARIABLE_VALUE_KEY: _saveable_factory} # Register a conversion functions which reads the value of the variable, # allowing instances of the class to be used as tensors. # DistributedVariable def _tensor_conversion_distributed_var(var, dtype=None, name=None, as_ref=False): return var._dense_var_to_tensor(dtype=dtype, name=name, as_ref=as_ref) # pylint: disable=protected-access ops.register_tensor_conversion_function(DistributedVariable, _tensor_conversion_distributed_var) # MirroredVariables def _tensor_conversion_mirrored(var, dtype=None, name=None, as_ref=False): return var._dense_var_to_tensor(dtype=dtype, name=name, as_ref=as_ref) # pylint: disable=protected-access ops.register_tensor_conversion_function(MirroredVariable, _tensor_conversion_mirrored) # Mirrored Values def _tensor_conversion_mirrored_val(value, dtype=None, name=None, as_ref=False): return ops.convert_to_tensor( value._get(), dtype=dtype, name=name, as_ref=as_ref) # pylint: disable=protected-access ops.register_tensor_conversion_function(Mirrored, _tensor_conversion_mirrored_val) # SyncOnReadVariables def _tensor_conversion_sync_on_read(var, dtype=None, name=None, as_ref=False): return var._dense_var_to_tensor(dtype=dtype, name=name, as_ref=as_ref) # pylint: disable=protected-access ops.register_tensor_conversion_function(SyncOnReadVariable, _tensor_conversion_sync_on_read) class VariablePolicy(object): """Policy defining synchronization and aggregation of a distributed variable. Given `synchronization` and `aggregation` parameters set on a `tf.Variable` during variable creation within `tf.distribute` scope, `tf.distribute` creates an appropriate policy object and assigns it to the distributed variable. All variable operations are delegated to the respective policy object. """ def __init__(self, aggregation): self._aggregation = aggregation def value(self): raise NotImplementedError( "This method should be overridden by sub-classes.") def _is_mirrored(self): raise NotImplementedError( "This method should be overridden by sub-classes.") def _as_graph_element(self, _): raise NotImplementedError( "This method should be overridden by sub-classes.") def _get_cross_replica(self, var): raise NotImplementedError( "This method should be overridden by sub-classes.") def _update_replica(self, var, update_fn, value, **kwargs): raise NotImplementedError( "This method should be overridden by sub-classes.") class OnReadPolicy(VariablePolicy): """Policy defined for `tf.VariableSynchronization.ON_READ` synchronization. This policy is created when `synchronization` is set to `tf.VariableSynchronization.ON_READ` and `aggregation` is set to any of the values allowed by the `tf.VariableAggregation` enum such as `NONE`, `SUM`, `MEAN` or `ONLY_FIRST_REPLICA`when creating a `tf.Variable` in `tf.distribute` scope. """ def _is_mirrored(self): return False def value(self, var): with ds_context.enter_or_assert_strategy(var.distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): if self._aggregation == vs.VariableAggregation.ONLY_FIRST_REPLICA: return var._get_replica(0).value() # pylint: disable=protected-access return var._get_cross_replica() # pylint: disable=protected-access else: return var._get_on_device_or_primary().value() # pylint: disable=protected-access def _as_graph_element(self, var): with ds_context.enter_or_assert_strategy(var.distribute_strategy): if ds_context.in_cross_replica_context(): return ops.convert_to_tensor(var._get_cross_replica()) # pylint: disable=protected-access return var._get()._as_graph_element() # pylint: disable=protected-access def _get_cross_replica(self, var): if self._aggregation == vs.VariableAggregation.ONLY_FIRST_REPLICA: return var._get_replica(0) # pylint: disable=protected-access with ds_context.enter_or_assert_strategy(var.distribute_strategy): return var.distribute_strategy.reduce( reduce_util.ReduceOp.from_variable_aggregation(self._aggregation), var, axis=None) def _update_replica(self, var, update_fn, value, **kwargs): return update_fn(var._get_on_device_or_primary(), value, **kwargs) # pylint: disable=protected-access def _scatter_not_implemented(self, method): raise NotImplementedError( "ON_READ variables doesn't support `%s` in cross replica context" % method) def assign_sub(self, var, value, use_locking=False, name=None, read_value=True): """Subtracts a value from this variable.""" with ds_context.enter_or_assert_strategy(var.distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_sub_cross_replica( var, value, read_value=read_value) else: return values_util.on_write_assign_sub( var, value, use_locking=use_locking, name=name, read_value=read_value) def assign_add(self, var, value, use_locking=False, name=None, read_value=True): """Adds a value to this variable.""" with ds_context.enter_or_assert_strategy(var.distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_add_cross_replica( var, value, read_value=read_value) else: return values_util.on_write_assign_add( var, value, use_locking=use_locking, name=name, read_value=read_value) def assign(self, var, value, use_locking=False, name=None, read_value=True): with ds_context.enter_or_assert_strategy(var.distribute_strategy): if (ds_context.in_cross_replica_context() and not values_util.in_replica_update_context()): return values_util.on_read_assign_cross_replica(var, value, read_value=read_value) else: return values_util.on_write_assign(var, value, use_locking=use_locking, name=name, read_value=read_value) def scatter_sub(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_sub") def scatter_add(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_add") def scatter_mul(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_mul") def scatter_div(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_div") def scatter_min(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_min") def scatter_max(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_max") def scatter_update(self, *args, **kwargs): del args, kwargs self._scatter_not_implemented("scatter_update") def get_saveable(self, var, primary_var, name): """Create a saveable object for the given variable.""" return values_util.get_on_read_saveable(var, primary_var, name) def get_restore_ops(self, var, tensor): """Restore the same value into all variables.""" return values_util.get_on_read_restore_ops(var, tensor, self._aggregation) class AutoPolicy(VariablePolicy): """Policy defined for `tf.VariableSynchronization.AUTO` synchronization. This policy is created when `synchronization` is set to `tf.VariableSynchronization.AUTO` and `aggregation` is set to `tf.VariableAggregation.NONE` when creating a `tf.Variable` in `tf.distribute` scope. """ def _is_mirrored(self): return True def value(self, var): return var._get_on_device_or_primary().value() # pylint: disable=protected-access def _as_graph_element(self, var): return var._get_on_device_or_primary()._as_graph_element() # pylint: disable=protected-access def _get_cross_replica(self, var): # Return identity, to avoid directly exposing the variable to the user and # allowing it to be modified by mistake. return array_ops.identity(var._get_on_device_or_primary()) # pylint: disable=protected-access def _update_replica(self, var, update_fn, value, **kwargs): return update_fn(var._get_on_device_or_primary(), value, **kwargs) # pylint: disable=protected-access def assign(self, var, value, use_locking=False, name=None, read_value=True): return values_util.on_write_assign(var, value, use_locking=use_locking, name=name, read_value=read_value) def assign_add(self, var, value, use_locking=False, name=None, read_value=True): return values_util.on_write_assign_add(var, value, use_locking=use_locking, name=name, read_value=read_value) def assign_sub(self, var, value, use_locking=False, name=None, read_value=True): return values_util.on_write_assign_sub(var, value, use_locking=use_locking, name=name, read_value=read_value) def scatter_sub(self, var, sparse_delta, use_locking=False, name=None): return values_util.scatter_sub(var, sparse_delta, use_locking=use_locking, name=name) def scatter_add(self, var, sparse_delta, use_locking=False, name=None): return values_util.scatter_add(var, sparse_delta, use_locking=use_locking, name=name) def scatter_mul(self, var, sparse_delta, use_locking=False, name=None): return values_util.scatter_mul(var, sparse_delta, use_locking=use_locking, name=name) def scatter_div(self, var, sparse_delta, use_locking=False, name=None): return values_util.scatter_div(var, sparse_delta, use_locking=use_locking, name=name) def scatter_min(self, var, sparse_delta, use_locking=False, name=None): if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_min", aggregation=self._aggregation)) return values_util.scatter_min(var, sparse_delta, use_locking=use_locking, name=name) def scatter_max(self, var, sparse_delta, use_locking=False, name=None): if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_max", aggregation=self._aggregation)) return values_util.scatter_max(var, sparse_delta, use_locking=use_locking, name=name) def scatter_update(self, var, sparse_delta, use_locking=False, name=None): if (self._aggregation != vs.VariableAggregation.ONLY_FIRST_REPLICA and self._aggregation != vs.VariableAggregation.NONE): raise NotImplementedError(values_util.scatter_error_msg.format( op_name="scatter_update", aggregation=self._aggregation)) return values_util.scatter_update(var, sparse_delta, use_locking=use_locking, name=name) def get_saveable(self, var, primary_var, name): """Saveable ops for AUTO variables.""" return values_util.get_on_write_saveable(var, primary_var, name) def get_restore_ops(self, var, tensor): return values_util.get_on_write_restore_ops(var, tensor) class OnWritePolicy(AutoPolicy): """Policy defined for `tf.VariableSynchronization.ON_WRITE` synchronization. This policy is created when the following `synchronization` and `aggregation` parameters are specified when creating a `tf.Variable` in `tf.distribute` scope: * `synchronization` is equal to `tf.VariableSynchronization.AUTO` and aggregation can be any of the following `tf.VariableAggregation` enum values such as `SUM`, `MEAN` or `ONLY_FIRST_REPLICA`. * `synchronization` is equal to `tf.VariableSynchronization.ON_WRITE` and aggregation can be any of the following `tf.VariableAggregation` enum values such as `NONE`, `SUM`, `MEAN` or `ONLY_FIRST_REPLICA`. """ def _update_replica(self, var, update_fn, value, **kwargs): return _on_write_update_replica(var, update_fn, value, **kwargs)
aldian/tensorflow
tensorflow/python/distribute/values.py
Python
apache-2.0
60,015
def action_comment_load_more(context, action, entity_type, entity_id, last_id, parent_id, **args): try: entity = IN.entitier.load_single(entity_type, int(entity_id)) if not entity: return output = Object() db = IN.db connection = db.connection container_id = IN.commenter.get_container_id(entity) # TODO: paging # get total total = 0 limit = 10 cursor = db.select({ 'table' : 'entity.comment', 'columns' : ['count(id)'], 'where' : [ ['container_id', container_id], ['id', '<', int(last_id)], # load previous ['parent_id', parent_id], ['status', 1], ], }).execute() if cursor.rowcount >= 0: total = int(cursor.fetchone()[0]) more_id = '_'.join(('more-commens', entity_type, str(entity_id), str(parent_id))) if total > 0: cursor = db.select({ 'table' : 'entity.comment', 'columns' : ['id'], 'where' : [ ['container_id', container_id], ['id', '<', int(last_id)], ['parent_id', parent_id], # add main level comments only ['status', 1], ], 'order' : {'created' : 'DESC'}, 'limit' : limit, }).execute() ids = [] last_id = 0 if cursor.rowcount >= 0: for row in cursor: ids.append(row['id']) last_id = ids[-1] # last id comments = IN.entitier.load_multiple('Comment', ids) for id, comment in comments.items(): comment.weight = id # keep asc order output.add(comment) remaining = total - limit if remaining > 0 and last_id > 0: output.add('TextDiv', { 'id' : more_id, 'value' : str(remaining) + ' more comments', 'css' : ['ajax i-text-center i-text-danger pointer'], 'attributes' : { 'data-href' : ''.join(('/comment/more/!Content/', str(entity_id), '/', str(last_id), '/', str(parent_id))) }, 'weight' : -1, }) #if not output: #output.add(type = 'TextDiv', data = {}) output = {more_id : output} context.response = In.core.response.PartialResponse(output = output) except: IN.logger.debug()
vinoth3v/In
In/comment/page/load_more.py
Python
apache-2.0
2,050
import unittest, sys sys.path.extend(['.','..','../..','py']) import h2o2 as h2o import h2o_cmd, h2o_import as h2i, h2o_browse as h2b from h2o_test import find_file, dump_json, verboseprint expectedZeros = [0, 4914, 656, 24603, 38665, 124, 13, 5, 1338, 51, 320216, 551128, 327648, 544044, 577981, 573487, 576189, 568616, 579415, 574437, 580907, 580833, 579865, 548378, 568602, 551041, 563581, 580413, 581009, 578167, 577590, 579113, 576991, 571753, 580174, 547639, 523260, 559734, 580538, 578423, 579926, 580066, 465765, 550842, 555346, 528493, 535858, 579401, 579121, 580893, 580714, 565439, 567206, 572262, 0] def assertEqualMsg(a, b): assert a == b, "%s %s" % (a, b) def parseKeyIndexedCheck(frames_result, multiplyExpected): # get the name of the frame? print "" frame = frames_result['frames'][0] rows = frame['rows'] columns = frame['columns'] for i,c in enumerate(columns): label = c['label'] stype = c['type'] missing = c['missing'] zeros = c['zeros'] domain = c['domain'] print "column: %s label: %s type: %s missing: %s zeros: %s domain: %s" %\ (i,label,stype,missing,zeros,domain) # files are concats of covtype. so multiply expected assertEqualMsg(zeros, expectedZeros[i] * multiplyExpected) assertEqualMsg(label,"C%s" % (i+1)) assertEqualMsg(stype,"int") assertEqualMsg(missing, 0) assertEqualMsg(domain, None) class Basic(unittest.TestCase): def tearDown(self): h2o.check_sandbox_for_errors() @classmethod def setUpClass(cls): h2o.init() @classmethod def tearDownClass(cls): h2o.tear_down_cloud() def test_parse_covtype_2(self): tryList = [ ('covtype.data', 1, 30), ('covtype20x.data', 20, 120), ] for (csvFilename, multiplyExpected, timeoutSecs) in tryList: # import_result = a_node.import_files(path=find_file("smalldata/logreg/prostate.csv")) importFolderPath = "standard" hex_key = 'covtype.hex' csvPathname = importFolderPath + "/" + csvFilename parseResult = h2i.import_parse(bucket='home-0xdiag-datasets', path=csvPathname, schema='local', timeoutSecs=timeoutSecs, hex_key=hex_key, chunk_size=4194304*2, doSummary=False) pA = h2o_cmd.ParseObj(parseResult) iA = h2o_cmd.InspectObj(pA.parse_key) print iA.missingList, iA.labelList, iA.numRows, iA.numCols for i in range(1): print "Summary on column", i co = h2o_cmd.runSummary(key=hex_key, column=i) k = parseResult['frames'][0]['key']['name'] # print "parseResult:", dump_json(parseResult) a_node = h2o.nodes[0] frames_result = a_node.frames(key=k, row_count=5) # print "frames_result from the first parseResult key", dump_json(frames_result) parseKeyIndexedCheck(frames_result, multiplyExpected) if __name__ == '__main__': h2o.unit_main()
bikash/h2o-dev
py2/testdir_single_jvm/test_parse_covtype_2.py
Python
apache-2.0
3,121
import pprint as pp import pandas as pd from sklearn.linear_model import Ridge, Lasso from sklearn.metrics import mean_absolute_error from sklearn.model_selection import GridSearchCV, KFold, cross_val_score from sklearn.svm import LinearSVR from ionyx.contrib import AveragingRegressor from ionyx.datasets import DataSetLoader print('Beginning averaging regressor test...') data, X, y = DataSetLoader.load_property_inspection() data = data.iloc[:1000, :] X = X[:1000, :] y = y[:1000] estimators = [('ridge', Ridge()), ('lasso', Lasso()), ('svm', LinearSVR())] ensemble = AveragingRegressor(estimators, weights=[1.0, 1.5, 2.0]) ensemble.fit(X, y) print('Estimators list:') pp.pprint(ensemble.estimators_) print('Named estimators dict:') pp.pprint(ensemble.named_estimators_) print('Model 1 score = {0}'.format(mean_absolute_error(y, ensemble.estimators_[0].predict(X)))) print('Model 2 score = {0}'.format(mean_absolute_error(y, ensemble.estimators_[1].predict(X)))) print('Model 3 score = {0}'.format(mean_absolute_error(y, ensemble.estimators_[2].predict(X)))) print('Ensemble score = {0}'.format(mean_absolute_error(y, ensemble.predict(X)))) cv = KFold() print('Cross-validation score = {0}'.format(cross_val_score(ensemble, X, y, cv=cv))) param_grid = [ { 'ridge__alpha': [0.01, 0.1] } ] grid = GridSearchCV(ensemble, param_grid=param_grid, cv=cv, return_train_score=True) grid.fit(X, y) results = pd.DataFrame(grid.cv_results_) results = results.sort_values(by='mean_test_score', ascending=False) print('Grid search results:') print(results) print('Done.')
jdwittenauer/ionyx
tests/averaging_regressor_test.py
Python
apache-2.0
1,583
# -*- coding: utf-8 -*- # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Generated code. DO NOT EDIT! # # Snippet for QueryArtifactLineageSubgraph # NOTE: This snippet has been automatically generated for illustrative purposes only. # It may require modifications to work in your environment. # To install the latest published package dependency, execute the following: # python3 -m pip install google-cloud-aiplatform # [START aiplatform_generated_aiplatform_v1beta1_MetadataService_QueryArtifactLineageSubgraph_async] from google.cloud import aiplatform_v1beta1 async def sample_query_artifact_lineage_subgraph(): # Create a client client = aiplatform_v1beta1.MetadataServiceAsyncClient() # Initialize request argument(s) request = aiplatform_v1beta1.QueryArtifactLineageSubgraphRequest( artifact="artifact_value", ) # Make the request response = await client.query_artifact_lineage_subgraph(request=request) # Handle the response print(response) # [END aiplatform_generated_aiplatform_v1beta1_MetadataService_QueryArtifactLineageSubgraph_async]
googleapis/python-aiplatform
samples/generated_samples/aiplatform_generated_aiplatform_v1beta1_metadata_service_query_artifact_lineage_subgraph_async.py
Python
apache-2.0
1,632
import os from .base import * # NOQA import dj_database_url DEBUG = False TEMPLATE_DEBUG = DEBUG ADMINS = ( ) DATABASES = {'default': dj_database_url.config()} LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s ' '%(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'null': { 'level': 'DEBUG', 'class': 'django.utils.log.NullHandler', }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django': { 'handlers': ['console', 'mail_admins'], 'level': 'DEBUG', 'propagate': True, }, 'django.request': { 'handlers': ['console', 'mail_admins'], 'level': 'ERROR', 'propagate': False, }, 'django.db.backends': { 'handlers': ['console', 'mail_admins'], 'level': 'INFO', 'propagate': False, }, # Catch All Logger -- Captures any other logging '': { 'handlers': ['console', 'mail_admins'], 'level': 'DEBUG', 'propagate': True, } } } # Honor the 'X-Forwarded-Proto' header for request.is_secure() SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Allow all host headers ALLOWED_HOSTS = ['*'] ########## EMAIL CONFIGURATION # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-backend EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-host EMAIL_HOST = os.environ.get('MAILGUN_SMTP_SERVER', None) # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-host-password EMAIL_HOST_PASSWORD = os.environ.get('MAILGUN_SMTP_PASSWORD', None) # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-host-user EMAIL_HOST_USER = os.environ.get('MAILGUN_SMTP_LOGIN', None) # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-port EMAIL_PORT = os.environ.get('MAILGUN_SMTP_PORT', None ) # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-subject-prefix EMAIL_SUBJECT_PREFIX = '[Scorinator] ' # See: https://docs.djangoproject.com/en/1.3/ref/settings/#email-use-tls EMAIL_USE_TLS = True # See: https://docs.djangoproject.com/en/1.3/ref/settings/#server-email SERVER_EMAIL = EMAIL_HOST_USER ########## END EMAIL CONFIGURATION
kencochrane/scorinator
scorinator/scorinator/settings/prod.py
Python
apache-2.0
2,973
# -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import print_function import doctest import json import os import re import unittest import multiprocessing import mock from numpy.testing import assert_array_almost_equal import tempfile from datetime import datetime, time, timedelta from email.mime.multipart import MIMEMultipart from email.mime.application import MIMEApplication import signal from time import time as timetime from time import sleep import warnings from dateutil.relativedelta import relativedelta import sqlalchemy from airflow import configuration from airflow.executors import SequentialExecutor, LocalExecutor from airflow.models import Variable from tests.test_utils.fake_datetime import FakeDatetime configuration.load_test_config() from airflow import jobs, models, DAG, utils, macros, settings, exceptions from airflow.models import BaseOperator from airflow.operators.bash_operator import BashOperator from airflow.operators.check_operator import CheckOperator, ValueCheckOperator from airflow.operators.dagrun_operator import TriggerDagRunOperator from airflow.operators.python_operator import PythonOperator from airflow.operators.dummy_operator import DummyOperator from airflow.operators.http_operator import SimpleHttpOperator from airflow.operators import sensors from airflow.hooks.base_hook import BaseHook from airflow.hooks.sqlite_hook import SqliteHook from airflow.hooks.postgres_hook import PostgresHook from airflow.bin import cli from airflow.www import app as application from airflow.settings import Session from airflow.utils.state import State from airflow.utils.dates import infer_time_unit, round_time, scale_time_units from airflow.utils.logging import LoggingMixin from lxml import html from airflow.exceptions import AirflowException from airflow.configuration import AirflowConfigException import six NUM_EXAMPLE_DAGS = 18 DEV_NULL = '/dev/null' TEST_DAG_FOLDER = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'dags') DEFAULT_DATE = datetime(2015, 1, 1) DEFAULT_DATE_ISO = DEFAULT_DATE.isoformat() DEFAULT_DATE_DS = DEFAULT_DATE_ISO[:10] TEST_DAG_ID = 'unit_tests' try: import cPickle as pickle except ImportError: # Python 3 import pickle def reset(dag_id=TEST_DAG_ID): session = Session() tis = session.query(models.TaskInstance).filter_by(dag_id=dag_id) tis.delete() session.commit() session.close() reset() class OperatorSubclass(BaseOperator): """ An operator to test template substitution """ template_fields = ['some_templated_field'] def __init__(self, some_templated_field, *args, **kwargs): super(OperatorSubclass, self).__init__(*args, **kwargs) self.some_templated_field = some_templated_field def execute(*args, **kwargs): pass class CoreTest(unittest.TestCase): # These defaults make the test faster to run default_scheduler_args = {"file_process_interval": 0, "processor_poll_interval": 0.5, "num_runs": 1} def setUp(self): configuration.load_test_config() self.dagbag = models.DagBag( dag_folder=DEV_NULL, include_examples=True) self.args = {'owner': 'airflow', 'start_date': DEFAULT_DATE} dag = DAG(TEST_DAG_ID, default_args=self.args) self.dag = dag self.dag_bash = self.dagbag.dags['example_bash_operator'] self.runme_0 = self.dag_bash.get_task('runme_0') self.run_after_loop = self.dag_bash.get_task('run_after_loop') self.run_this_last = self.dag_bash.get_task('run_this_last') def test_schedule_dag_no_previous_runs(self): """ Tests scheduling a dag with no previous runs """ dag = DAG(TEST_DAG_ID + 'test_schedule_dag_no_previous_runs') dag.add_task(models.BaseOperator( task_id="faketastic", owner='Also fake', start_date=datetime(2015, 1, 2, 0, 0))) dag_run = jobs.SchedulerJob(**self.default_scheduler_args).create_dag_run(dag) self.assertIsNotNone(dag_run) self.assertEqual(dag.dag_id, dag_run.dag_id) self.assertIsNotNone(dag_run.run_id) self.assertNotEqual('', dag_run.run_id) self.assertEqual(datetime(2015, 1, 2, 0, 0), dag_run.execution_date, msg= 'dag_run.execution_date did not match expectation: {0}' .format(dag_run.execution_date)) self.assertEqual(State.RUNNING, dag_run.state) self.assertFalse(dag_run.external_trigger) dag.clear() def test_schedule_dag_fake_scheduled_previous(self): """ Test scheduling a dag where there is a prior DagRun which has the same run_id as the next run should have """ delta = timedelta(hours=1) dag = DAG(TEST_DAG_ID + 'test_schedule_dag_fake_scheduled_previous', schedule_interval=delta, start_date=DEFAULT_DATE) dag.add_task(models.BaseOperator( task_id="faketastic", owner='Also fake', start_date=DEFAULT_DATE)) scheduler = jobs.SchedulerJob(**self.default_scheduler_args) dag.create_dagrun(run_id=models.DagRun.id_for_date(DEFAULT_DATE), execution_date=DEFAULT_DATE, state=State.SUCCESS, external_trigger=True) dag_run = scheduler.create_dag_run(dag) self.assertIsNotNone(dag_run) self.assertEqual(dag.dag_id, dag_run.dag_id) self.assertIsNotNone(dag_run.run_id) self.assertNotEqual('', dag_run.run_id) self.assertEqual(DEFAULT_DATE + delta, dag_run.execution_date, msg= 'dag_run.execution_date did not match expectation: {0}' .format(dag_run.execution_date)) self.assertEqual(State.RUNNING, dag_run.state) self.assertFalse(dag_run.external_trigger) def test_schedule_dag_once(self): """ Tests scheduling a dag scheduled for @once - should be scheduled the first time it is called, and not scheduled the second. """ dag = DAG(TEST_DAG_ID + 'test_schedule_dag_once') dag.schedule_interval = '@once' dag.add_task(models.BaseOperator( task_id="faketastic", owner='Also fake', start_date=datetime(2015, 1, 2, 0, 0))) dag_run = jobs.SchedulerJob(**self.default_scheduler_args).create_dag_run(dag) dag_run2 = jobs.SchedulerJob(**self.default_scheduler_args).create_dag_run(dag) self.assertIsNotNone(dag_run) self.assertIsNone(dag_run2) dag.clear() def test_fractional_seconds(self): """ Tests if fractional seconds are stored in the database """ dag = DAG(TEST_DAG_ID + 'test_fractional_seconds') dag.schedule_interval = '@once' dag.add_task(models.BaseOperator( task_id="faketastic", owner='Also fake', start_date=datetime(2015, 1, 2, 0, 0))) start_date = datetime.now() run = dag.create_dagrun( run_id='test_' + start_date.isoformat(), execution_date=start_date, start_date=start_date, state=State.RUNNING, external_trigger=False ) run.refresh_from_db() self.assertEqual(start_date, run.execution_date, "dag run execution_date loses precision") self.assertEqual(start_date, run.start_date, "dag run start_date loses precision ") def test_schedule_dag_start_end_dates(self): """ Tests that an attempt to schedule a task after the Dag's end_date does not succeed. """ delta = timedelta(hours=1) runs = 3 start_date = DEFAULT_DATE end_date = start_date + (runs - 1) * delta dag = DAG(TEST_DAG_ID + 'test_schedule_dag_start_end_dates', start_date=start_date, end_date=end_date, schedule_interval=delta) dag.add_task(models.BaseOperator(task_id='faketastic', owner='Also fake')) # Create and schedule the dag runs dag_runs = [] scheduler = jobs.SchedulerJob(**self.default_scheduler_args) for i in range(runs): dag_runs.append(scheduler.create_dag_run(dag)) additional_dag_run = scheduler.create_dag_run(dag) for dag_run in dag_runs: self.assertIsNotNone(dag_run) self.assertIsNone(additional_dag_run) @mock.patch('airflow.jobs.datetime', FakeDatetime) def test_schedule_dag_no_end_date_up_to_today_only(self): """ Tests that a Dag created without an end_date can only be scheduled up to and including the current datetime. For example, if today is 2016-01-01 and we are scheduling from a start_date of 2015-01-01, only jobs up to, but not including 2016-01-01 should be scheduled. """ from datetime import datetime FakeDatetime.now = classmethod(lambda cls: datetime(2016, 1, 1)) session = settings.Session() delta = timedelta(days=1) start_date = DEFAULT_DATE runs = 365 dag = DAG(TEST_DAG_ID + 'test_schedule_dag_no_end_date_up_to_today_only', start_date=start_date, schedule_interval=delta) dag.add_task(models.BaseOperator(task_id='faketastic', owner='Also fake')) dag_runs = [] scheduler = jobs.SchedulerJob(**self.default_scheduler_args) for i in range(runs): dag_run = scheduler.create_dag_run(dag) dag_runs.append(dag_run) # Mark the DagRun as complete dag_run.state = State.SUCCESS session.merge(dag_run) session.commit() # Attempt to schedule an additional dag run (for 2016-01-01) additional_dag_run = scheduler.create_dag_run(dag) for dag_run in dag_runs: self.assertIsNotNone(dag_run) self.assertIsNone(additional_dag_run) def test_confirm_unittest_mod(self): self.assertTrue(configuration.get('core', 'unit_test_mode')) def test_pickling(self): dp = self.dag.pickle() self.assertEqual(dp.pickle.dag_id, self.dag.dag_id) def test_rich_comparison_ops(self): class DAGsubclass(DAG): pass dag_eq = DAG(TEST_DAG_ID, default_args=self.args) dag_diff_load_time = DAG(TEST_DAG_ID, default_args=self.args) dag_diff_name = DAG(TEST_DAG_ID + '_neq', default_args=self.args) dag_subclass = DAGsubclass(TEST_DAG_ID, default_args=self.args) dag_subclass_diff_name = DAGsubclass( TEST_DAG_ID + '2', default_args=self.args) for d in [dag_eq, dag_diff_name, dag_subclass, dag_subclass_diff_name]: d.last_loaded = self.dag.last_loaded # test identity equality self.assertEqual(self.dag, self.dag) # test dag (in)equality based on _comps self.assertEqual(dag_eq, self.dag) self.assertNotEqual(dag_diff_name, self.dag) self.assertNotEqual(dag_diff_load_time, self.dag) # test dag inequality based on type even if _comps happen to match self.assertNotEqual(dag_subclass, self.dag) # a dag should equal an unpickled version of itself self.assertEqual(pickle.loads(pickle.dumps(self.dag)), self.dag) # dags are ordered based on dag_id no matter what the type is self.assertLess(self.dag, dag_diff_name) self.assertGreater(self.dag, dag_diff_load_time) self.assertLess(self.dag, dag_subclass_diff_name) # greater than should have been created automatically by functools self.assertGreater(dag_diff_name, self.dag) # hashes are non-random and match equality self.assertEqual(hash(self.dag), hash(self.dag)) self.assertEqual(hash(dag_eq), hash(self.dag)) self.assertNotEqual(hash(dag_diff_name), hash(self.dag)) self.assertNotEqual(hash(dag_subclass), hash(self.dag)) def test_time_sensor(self): t = sensors.TimeSensor( task_id='time_sensor_check', target_time=time(0), dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_check_operators(self): conn_id = "sqlite_default" captainHook = BaseHook.get_hook(conn_id=conn_id) captainHook.run("CREATE TABLE operator_test_table (a, b)") captainHook.run("insert into operator_test_table values (1,2)") t = CheckOperator( task_id='check', sql="select count(*) from operator_test_table", conn_id=conn_id, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) t = ValueCheckOperator( task_id='value_check', pass_value=95, tolerance=0.1, conn_id=conn_id, sql="SELECT 100", dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) captainHook.run("drop table operator_test_table") def test_clear_api(self): task = self.dag_bash.tasks[0] task.clear( start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, upstream=True, downstream=True) ti = models.TaskInstance(task=task, execution_date=DEFAULT_DATE) ti.are_dependents_done() def test_illegal_args(self): """ Tests that Operators reject illegal arguments """ with warnings.catch_warnings(record=True) as w: t = BashOperator( task_id='test_illegal_args', bash_command='echo success', dag=self.dag, illegal_argument_1234='hello?') self.assertTrue( issubclass(w[0].category, PendingDeprecationWarning)) self.assertIn( 'Invalid arguments were passed to BashOperator.', w[0].message.args[0]) def test_bash_operator(self): t = BashOperator( task_id='time_sensor_check', bash_command="echo success", dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_bash_operator_multi_byte_output(self): t = BashOperator( task_id='test_multi_byte_bash_operator', bash_command=u"echo \u2600", dag=self.dag, output_encoding='utf-8') t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_bash_operator_kill(self): import subprocess import psutil sleep_time = "100%d" % os.getpid() t = BashOperator( task_id='test_bash_operator_kill', execution_timeout=timedelta(seconds=1), bash_command="/bin/bash -c 'sleep %s'" % sleep_time, dag=self.dag) self.assertRaises( exceptions.AirflowTaskTimeout, t.run, start_date=DEFAULT_DATE, end_date=DEFAULT_DATE) sleep(2) pid = -1 for proc in psutil.process_iter(): if proc.cmdline() == ['sleep', sleep_time]: pid = proc.pid if pid != -1: os.kill(pid, signal.SIGTERM) self.fail("BashOperator's subprocess still running after stopping on timeout!") def test_trigger_dagrun(self): def trigga(context, obj): if True: return obj t = TriggerDagRunOperator( task_id='test_trigger_dagrun', trigger_dag_id='example_bash_operator', python_callable=trigga, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_dryrun(self): t = BashOperator( task_id='time_sensor_check', bash_command="echo success", dag=self.dag) t.dry_run() def test_sqlite(self): import airflow.operators.sqlite_operator t = airflow.operators.sqlite_operator.SqliteOperator( task_id='time_sqlite', sql="CREATE TABLE IF NOT EXISTS unitest (dummy VARCHAR(20))", dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_timedelta_sensor(self): t = sensors.TimeDeltaSensor( task_id='timedelta_sensor_check', delta=timedelta(seconds=2), dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_external_task_sensor(self): t = sensors.ExternalTaskSensor( task_id='test_external_task_sensor_check', external_dag_id=TEST_DAG_ID, external_task_id='time_sensor_check', dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_external_task_sensor_delta(self): t = sensors.ExternalTaskSensor( task_id='test_external_task_sensor_check_delta', external_dag_id=TEST_DAG_ID, external_task_id='time_sensor_check', execution_delta=timedelta(0), allowed_states=['success'], dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_external_task_sensor_fn(self): self.test_time_sensor() # check that the execution_fn works t = sensors.ExternalTaskSensor( task_id='test_external_task_sensor_check_delta', external_dag_id=TEST_DAG_ID, external_task_id='time_sensor_check', execution_date_fn=lambda dt: dt + timedelta(0), allowed_states=['success'], dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) # double check that the execution is being called by failing the test t2 = sensors.ExternalTaskSensor( task_id='test_external_task_sensor_check_delta', external_dag_id=TEST_DAG_ID, external_task_id='time_sensor_check', execution_date_fn=lambda dt: dt + timedelta(days=1), allowed_states=['success'], timeout=1, poke_interval=1, dag=self.dag) with self.assertRaises(exceptions.AirflowSensorTimeout): t2.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_external_task_sensor_error_delta_and_fn(self): """ Test that providing execution_delta and a function raises an error """ with self.assertRaises(ValueError): t = sensors.ExternalTaskSensor( task_id='test_external_task_sensor_check_delta', external_dag_id=TEST_DAG_ID, external_task_id='time_sensor_check', execution_delta=timedelta(0), execution_date_fn=lambda dt: dt, allowed_states=['success'], dag=self.dag) def test_timeout(self): t = PythonOperator( task_id='test_timeout', execution_timeout=timedelta(seconds=1), python_callable=lambda: sleep(5), dag=self.dag) self.assertRaises( exceptions.AirflowTaskTimeout, t.run, start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_python_op(self): def test_py_op(templates_dict, ds, **kwargs): if not templates_dict['ds'] == ds: raise Exception("failure") t = PythonOperator( task_id='test_py_op', provide_context=True, python_callable=test_py_op, templates_dict={'ds': "{{ ds }}"}, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_complex_template(self): def verify_templated_field(context): self.assertEqual(context['ti'].task.some_templated_field['bar'][1], context['ds']) t = OperatorSubclass( task_id='test_complex_template', some_templated_field={ 'foo': '123', 'bar': ['baz', '{{ ds }}'] }, on_success_callback=verify_templated_field, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) def test_template_with_variable(self): """ Test the availability of variables in templates """ val = { 'success':False, 'test_value': 'a test value' } Variable.set("a_variable", val['test_value']) def verify_templated_field(context): self.assertEqual(context['ti'].task.some_templated_field, val['test_value']) val['success'] = True t = OperatorSubclass( task_id='test_complex_template', some_templated_field='{{ var.value.a_variable }}', on_success_callback=verify_templated_field, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(val['success']) def test_template_with_json_variable(self): """ Test the availability of variables (serialized as JSON) in templates """ val = { 'success': False, 'test_value': {'foo': 'bar', 'obj': {'v1': 'yes', 'v2': 'no'}} } Variable.set("a_variable", val['test_value'], serialize_json=True) def verify_templated_field(context): self.assertEqual(context['ti'].task.some_templated_field, val['test_value']['obj']['v2']) val['success'] = True t = OperatorSubclass( task_id='test_complex_template', some_templated_field='{{ var.json.a_variable.obj.v2 }}', on_success_callback=verify_templated_field, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(val['success']) def test_template_with_json_variable_as_value(self): """ Test the availability of variables (serialized as JSON) in templates, but accessed as a value """ val = { 'success': False, 'test_value': {'foo': 'bar'} } Variable.set("a_variable", val['test_value'], serialize_json=True) def verify_templated_field(context): self.assertEqual(context['ti'].task.some_templated_field, u'{"foo": "bar"}') val['success'] = True t = OperatorSubclass( task_id='test_complex_template', some_templated_field='{{ var.value.a_variable }}', on_success_callback=verify_templated_field, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) self.assertTrue(val['success']) def test_template_non_bool(self): """ Test templates can handle objects with no sense of truthiness """ class NonBoolObject(object): def __len__(self): return NotImplemented def __bool__(self): return NotImplemented t = OperatorSubclass( task_id='test_bad_template_obj', some_templated_field=NonBoolObject(), dag=self.dag) t.resolve_template_files() def test_import_examples(self): self.assertEqual(len(self.dagbag.dags), NUM_EXAMPLE_DAGS) def test_local_task_job(self): TI = models.TaskInstance ti = TI( task=self.runme_0, execution_date=DEFAULT_DATE) job = jobs.LocalTaskJob(task_instance=ti, ignore_ti_state=True) job.run() @mock.patch('airflow.utils.dag_processing.datetime', FakeDatetime) def test_scheduler_job(self): FakeDatetime.now = classmethod(lambda cls: datetime(2016, 1, 1)) job = jobs.SchedulerJob(dag_id='example_bash_operator', **self.default_scheduler_args) job.run() log_base_directory = configuration.conf.get("scheduler", "child_process_log_directory") latest_log_directory_path = os.path.join(log_base_directory, "latest") # verify that the symlink to the latest logs exists self.assertTrue(os.path.islink(latest_log_directory_path)) # verify that the symlink points to the correct log directory log_directory = os.path.join(log_base_directory, "2016-01-01") self.assertEqual(os.readlink(latest_log_directory_path), log_directory) def test_raw_job(self): TI = models.TaskInstance ti = TI( task=self.runme_0, execution_date=DEFAULT_DATE) ti.dag = self.dag_bash ti.run(ignore_ti_state=True) def test_doctests(self): modules = [utils, macros] for mod in modules: failed, tests = doctest.testmod(mod) if failed: raise Exception("Failed a doctest") def test_variable_set_get_round_trip(self): Variable.set("tested_var_set_id", "Monday morning breakfast") self.assertEqual("Monday morning breakfast", Variable.get("tested_var_set_id")) def test_variable_set_get_round_trip_json(self): value = {"a": 17, "b": 47} Variable.set("tested_var_set_id", value, serialize_json=True) self.assertEqual(value, Variable.get("tested_var_set_id", deserialize_json=True)) def test_get_non_existing_var_should_return_default(self): default_value = "some default val" self.assertEqual(default_value, Variable.get("thisIdDoesNotExist", default_var=default_value)) def test_get_non_existing_var_should_not_deserialize_json_default(self): default_value = "}{ this is a non JSON default }{" self.assertEqual(default_value, Variable.get("thisIdDoesNotExist", default_var=default_value, deserialize_json=True)) def test_variable_setdefault_round_trip(self): key = "tested_var_setdefault_1_id" value = "Monday morning breakfast in Paris" Variable.setdefault(key, value) self.assertEqual(value, Variable.get(key)) def test_variable_setdefault_round_trip_json(self): key = "tested_var_setdefault_2_id" value = {"city": 'Paris', "Hapiness": True} Variable.setdefault(key, value, deserialize_json=True) self.assertEqual(value, Variable.get(key, deserialize_json=True)) def test_parameterized_config_gen(self): cfg = configuration.parameterized_config(configuration.DEFAULT_CONFIG) # making sure some basic building blocks are present: self.assertIn("[core]", cfg) self.assertIn("dags_folder", cfg) self.assertIn("sql_alchemy_conn", cfg) self.assertIn("fernet_key", cfg) # making sure replacement actually happened self.assertNotIn("{AIRFLOW_HOME}", cfg) self.assertNotIn("{FERNET_KEY}", cfg) def test_config_use_original_when_original_and_fallback_are_present(self): self.assertTrue(configuration.has_option("core", "FERNET_KEY")) self.assertFalse(configuration.has_option("core", "FERNET_KEY_CMD")) FERNET_KEY = configuration.get('core', 'FERNET_KEY') configuration.set("core", "FERNET_KEY_CMD", "printf HELLO") FALLBACK_FERNET_KEY = configuration.get( "core", "FERNET_KEY" ) self.assertEqual(FERNET_KEY, FALLBACK_FERNET_KEY) # restore the conf back to the original state configuration.remove_option("core", "FERNET_KEY_CMD") def test_config_throw_error_when_original_and_fallback_is_absent(self): self.assertTrue(configuration.has_option("core", "FERNET_KEY")) self.assertFalse(configuration.has_option("core", "FERNET_KEY_CMD")) FERNET_KEY = configuration.get("core", "FERNET_KEY") configuration.remove_option("core", "FERNET_KEY") with self.assertRaises(AirflowConfigException) as cm: configuration.get("core", "FERNET_KEY") exception = str(cm.exception) message = "section/key [core/fernet_key] not found in config" self.assertEqual(message, exception) # restore the conf back to the original state configuration.set("core", "FERNET_KEY", FERNET_KEY) self.assertTrue(configuration.has_option("core", "FERNET_KEY")) def test_config_override_original_when_non_empty_envvar_is_provided(self): key = "AIRFLOW__CORE__FERNET_KEY" value = "some value" self.assertNotIn(key, os.environ) os.environ[key] = value FERNET_KEY = configuration.get('core', 'FERNET_KEY') self.assertEqual(value, FERNET_KEY) # restore the envvar back to the original state del os.environ[key] def test_config_override_original_when_empty_envvar_is_provided(self): key = "AIRFLOW__CORE__FERNET_KEY" value = "" self.assertNotIn(key, os.environ) os.environ[key] = value FERNET_KEY = configuration.get('core', 'FERNET_KEY') self.assertEqual(value, FERNET_KEY) # restore the envvar back to the original state del os.environ[key] def test_class_with_logger_should_have_logger_with_correct_name(self): # each class should automatically receive a logger with a correct name class Blah(LoggingMixin): pass self.assertEqual("tests.core.Blah", Blah().logger.name) self.assertEqual("airflow.executors.sequential_executor.SequentialExecutor", SequentialExecutor().logger.name) self.assertEqual("airflow.executors.local_executor.LocalExecutor", LocalExecutor().logger.name) def test_round_time(self): rt1 = round_time(datetime(2015, 1, 1, 6), timedelta(days=1)) self.assertEqual(datetime(2015, 1, 1, 0, 0), rt1) rt2 = round_time(datetime(2015, 1, 2), relativedelta(months=1)) self.assertEqual(datetime(2015, 1, 1, 0, 0), rt2) rt3 = round_time(datetime(2015, 9, 16, 0, 0), timedelta(1), datetime( 2015, 9, 14, 0, 0)) self.assertEqual(datetime(2015, 9, 16, 0, 0), rt3) rt4 = round_time(datetime(2015, 9, 15, 0, 0), timedelta(1), datetime( 2015, 9, 14, 0, 0)) self.assertEqual(datetime(2015, 9, 15, 0, 0), rt4) rt5 = round_time(datetime(2015, 9, 14, 0, 0), timedelta(1), datetime( 2015, 9, 14, 0, 0)) self.assertEqual(datetime(2015, 9, 14, 0, 0), rt5) rt6 = round_time(datetime(2015, 9, 13, 0, 0), timedelta(1), datetime( 2015, 9, 14, 0, 0)) self.assertEqual(datetime(2015, 9, 14, 0, 0), rt6) def test_infer_time_unit(self): self.assertEqual('minutes', infer_time_unit([130, 5400, 10])) self.assertEqual('seconds', infer_time_unit([110, 50, 10, 100])) self.assertEqual('hours', infer_time_unit([100000, 50000, 10000, 20000])) self.assertEqual('days', infer_time_unit([200000, 100000])) def test_scale_time_units(self): # use assert_almost_equal from numpy.testing since we are comparing # floating point arrays arr1 = scale_time_units([130, 5400, 10], 'minutes') assert_array_almost_equal(arr1, [2.167, 90.0, 0.167], decimal=3) arr2 = scale_time_units([110, 50, 10, 100], 'seconds') assert_array_almost_equal(arr2, [110.0, 50.0, 10.0, 100.0], decimal=3) arr3 = scale_time_units([100000, 50000, 10000, 20000], 'hours') assert_array_almost_equal(arr3, [27.778, 13.889, 2.778, 5.556], decimal=3) arr4 = scale_time_units([200000, 100000], 'days') assert_array_almost_equal(arr4, [2.315, 1.157], decimal=3) def test_duplicate_dependencies(self): regexp = "Dependency (.*)runme_0(.*)run_after_loop(.*) " \ "already registered" with self.assertRaisesRegexp(AirflowException, regexp): self.runme_0.set_downstream(self.run_after_loop) with self.assertRaisesRegexp(AirflowException, regexp): self.run_after_loop.set_upstream(self.runme_0) def test_cyclic_dependencies_1(self): regexp = "Cycle detected in DAG. (.*)runme_0(.*)" with self.assertRaisesRegexp(AirflowException, regexp): self.runme_0.set_upstream(self.run_after_loop) def test_cyclic_dependencies_2(self): regexp = "Cycle detected in DAG. (.*)run_after_loop(.*)" with self.assertRaisesRegexp(AirflowException, regexp): self.run_after_loop.set_downstream(self.runme_0) def test_cyclic_dependencies_3(self): regexp = "Cycle detected in DAG. (.*)run_this_last(.*)" with self.assertRaisesRegexp(AirflowException, regexp): self.run_this_last.set_downstream(self.runme_0) def test_bad_trigger_rule(self): with self.assertRaises(AirflowException): DummyOperator( task_id='test_bad_trigger', trigger_rule="non_existant", dag=self.dag) def test_terminate_task(self): """If a task instance's db state get deleted, it should fail""" TI = models.TaskInstance dag = self.dagbag.dags.get('test_utils') task = dag.task_dict.get('sleeps_forever') ti = TI(task=task, execution_date=DEFAULT_DATE) job = jobs.LocalTaskJob( task_instance=ti, ignore_ti_state=True, executor=SequentialExecutor()) # Running task instance asynchronously p = multiprocessing.Process(target=job.run) p.start() sleep(5) settings.engine.dispose() session = settings.Session() ti.refresh_from_db(session=session) # making sure it's actually running self.assertEqual(State.RUNNING, ti.state) ti = ( session.query(TI) .filter_by( dag_id=task.dag_id, task_id=task.task_id, execution_date=DEFAULT_DATE) .one() ) # deleting the instance should result in a failure session.delete(ti) session.commit() # waiting for the async task to finish p.join() # making sure that the task ended up as failed ti.refresh_from_db(session=session) self.assertEqual(State.FAILED, ti.state) session.close() def test_task_fail_duration(self): """If a task fails, the duration should be recorded in TaskFail""" p = BashOperator( task_id='pass_sleepy', bash_command='sleep 3', dag=self.dag) f = BashOperator( task_id='fail_sleepy', bash_command='sleep 5', execution_timeout=timedelta(seconds=3), retry_delay=timedelta(seconds=0), dag=self.dag) session = settings.Session() try: p.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) except: pass try: f.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) except: pass p_fails = session.query(models.TaskFail).filter_by( task_id='pass_sleepy', dag_id=self.dag.dag_id, execution_date=DEFAULT_DATE).all() f_fails = session.query(models.TaskFail).filter_by( task_id='fail_sleepy', dag_id=self.dag.dag_id, execution_date=DEFAULT_DATE).all() print(f_fails) self.assertEqual(0, len(p_fails)) self.assertEqual(1, len(f_fails)) # C self.assertGreaterEqual(sum([f.duration for f in f_fails]), 3) def test_dag_stats(self): """Correctly sets/dirties/cleans rows of DagStat table""" session = settings.Session() session.query(models.DagRun).delete() session.query(models.DagStat).delete() session.commit() with warnings.catch_warnings(record=True) as caught_warnings: models.DagStat.clean_dirty([], session=session) self.assertEqual([], caught_warnings) run1 = self.dag_bash.create_dagrun( run_id="run1", execution_date=DEFAULT_DATE, state=State.RUNNING) with warnings.catch_warnings(record=True) as caught_warnings: models.DagStat.clean_dirty([self.dag_bash.dag_id], session=session) self.assertEqual([], caught_warnings) qry = session.query(models.DagStat).all() self.assertEqual(1, len(qry)) self.assertEqual(self.dag_bash.dag_id, qry[0].dag_id) self.assertEqual(State.RUNNING, qry[0].state) self.assertEqual(1, qry[0].count) self.assertFalse(qry[0].dirty) run2 = self.dag_bash.create_dagrun( run_id="run2", execution_date=DEFAULT_DATE+timedelta(days=1), state=State.RUNNING) with warnings.catch_warnings(record=True) as caught_warnings: models.DagStat.clean_dirty([self.dag_bash.dag_id], session=session) self.assertEqual([], caught_warnings) qry = session.query(models.DagStat).all() self.assertEqual(1, len(qry)) self.assertEqual(self.dag_bash.dag_id, qry[0].dag_id) self.assertEqual(State.RUNNING, qry[0].state) self.assertEqual(2, qry[0].count) self.assertFalse(qry[0].dirty) session.query(models.DagRun).first().state = State.SUCCESS session.commit() with warnings.catch_warnings(record=True) as caught_warnings: models.DagStat.clean_dirty([self.dag_bash.dag_id], session=session) self.assertEqual([], caught_warnings) qry = session.query(models.DagStat).filter(models.DagStat.state == State.SUCCESS).all() self.assertEqual(1, len(qry)) self.assertEqual(self.dag_bash.dag_id, qry[0].dag_id) self.assertEqual(State.SUCCESS, qry[0].state) self.assertEqual(1, qry[0].count) self.assertFalse(qry[0].dirty) qry = session.query(models.DagStat).filter(models.DagStat.state == State.RUNNING).all() self.assertEqual(1, len(qry)) self.assertEqual(self.dag_bash.dag_id, qry[0].dag_id) self.assertEqual(State.RUNNING, qry[0].state) self.assertEqual(1, qry[0].count) self.assertFalse(qry[0].dirty) session.query(models.DagRun).delete() session.query(models.DagStat).delete() session.commit() session.close() class CliTests(unittest.TestCase): def setUp(self): configuration.load_test_config() app = application.create_app() app.config['TESTING'] = True self.parser = cli.CLIFactory.get_parser() self.dagbag = models.DagBag( dag_folder=DEV_NULL, include_examples=True) # Persist DAGs def test_cli_list_dags(self): args = self.parser.parse_args(['list_dags', '--report']) cli.list_dags(args) def test_cli_list_tasks(self): for dag_id in self.dagbag.dags.keys(): args = self.parser.parse_args(['list_tasks', dag_id]) cli.list_tasks(args) args = self.parser.parse_args([ 'list_tasks', 'example_bash_operator', '--tree']) cli.list_tasks(args) def test_cli_initdb(self): cli.initdb(self.parser.parse_args(['initdb'])) def test_cli_connections_list(self): with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args(['connections', '--list'])) stdout = mock_stdout.getvalue() conns = [[x.strip("'") for x in re.findall("'\w+'", line)[:2]] for ii, line in enumerate(stdout.split('\n')) if ii % 2 == 1] conns = [conn for conn in conns if len(conn) > 0] # Assert that some of the connections are present in the output as # expected: self.assertIn(['aws_default', 'aws'], conns) self.assertIn(['beeline_default', 'beeline'], conns) self.assertIn(['bigquery_default', 'bigquery'], conns) self.assertIn(['emr_default', 'emr'], conns) self.assertIn(['mssql_default', 'mssql'], conns) self.assertIn(['mysql_default', 'mysql'], conns) self.assertIn(['postgres_default', 'postgres'], conns) # Attempt to list connections with invalid cli args with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--list', '--conn_id=fake', '--conn_uri=fake-uri'])) stdout = mock_stdout.getvalue() # Check list attempt stdout lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ ("\tThe following args are not compatible with the " + "--list flag: ['conn_id', 'conn_uri']"), ]) def test_cli_connections_add_delete(self): # Add connections: uri = 'postgresql://airflow:airflow@host:5432/airflow' with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--add', '--conn_id=new1', '--conn_uri=%s' % uri])) cli.connections(self.parser.parse_args( ['connections', '-a', '--conn_id=new2', '--conn_uri=%s' % uri])) cli.connections(self.parser.parse_args( ['connections', '--add', '--conn_id=new3', '--conn_uri=%s' % uri, '--conn_extra', "{'extra': 'yes'}"])) cli.connections(self.parser.parse_args( ['connections', '-a', '--conn_id=new4', '--conn_uri=%s' % uri, '--conn_extra', "{'extra': 'yes'}"])) stdout = mock_stdout.getvalue() # Check addition stdout lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ ("\tSuccessfully added `conn_id`=new1 : " + "postgresql://airflow:airflow@host:5432/airflow"), ("\tSuccessfully added `conn_id`=new2 : " + "postgresql://airflow:airflow@host:5432/airflow"), ("\tSuccessfully added `conn_id`=new3 : " + "postgresql://airflow:airflow@host:5432/airflow"), ("\tSuccessfully added `conn_id`=new4 : " + "postgresql://airflow:airflow@host:5432/airflow"), ]) # Attempt to add duplicate with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--add', '--conn_id=new1', '--conn_uri=%s' % uri])) stdout = mock_stdout.getvalue() # Check stdout for addition attempt lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ "\tA connection with `conn_id`=new1 already exists", ]) # Attempt to add without providing conn_id with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--add', '--conn_uri=%s' % uri])) stdout = mock_stdout.getvalue() # Check stdout for addition attempt lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ ("\tThe following args are required to add a connection:" + " ['conn_id']"), ]) # Attempt to add without providing conn_uri with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--add', '--conn_id=new'])) stdout = mock_stdout.getvalue() # Check stdout for addition attempt lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ ("\tThe following args are required to add a connection:" + " ['conn_uri']"), ]) # Prepare to add connections session = settings.Session() extra = {'new1': None, 'new2': None, 'new3': "{'extra': 'yes'}", 'new4': "{'extra': 'yes'}"} # Add connections for conn_id in ['new1', 'new2', 'new3', 'new4']: result = (session .query(models.Connection) .filter(models.Connection.conn_id == conn_id) .first()) result = (result.conn_id, result.conn_type, result.host, result.port, result.get_extra()) self.assertEqual(result, (conn_id, 'postgres', 'host', 5432, extra[conn_id])) # Delete connections with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=new1'])) cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=new2'])) cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=new3'])) cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=new4'])) stdout = mock_stdout.getvalue() # Check deletion stdout lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ "\tSuccessfully deleted `conn_id`=new1", "\tSuccessfully deleted `conn_id`=new2", "\tSuccessfully deleted `conn_id`=new3", "\tSuccessfully deleted `conn_id`=new4" ]) # Check deletions for conn_id in ['new1', 'new2', 'new3', 'new4']: result = (session .query(models.Connection) .filter(models.Connection.conn_id == conn_id) .first()) self.assertTrue(result is None) # Attempt to delete a non-existing connnection with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=fake'])) stdout = mock_stdout.getvalue() # Check deletion attempt stdout lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ "\tDid not find a connection with `conn_id`=fake", ]) # Attempt to delete with invalid cli args with mock.patch('sys.stdout', new_callable=six.StringIO) as mock_stdout: cli.connections(self.parser.parse_args( ['connections', '--delete', '--conn_id=fake', '--conn_uri=%s' % uri])) stdout = mock_stdout.getvalue() # Check deletion attempt stdout lines = [l for l in stdout.split('\n') if len(l) > 0] self.assertListEqual(lines, [ ("\tThe following args are not compatible with the " + "--delete flag: ['conn_uri']"), ]) session.close() def test_cli_test(self): cli.test(self.parser.parse_args([ 'test', 'example_bash_operator', 'runme_0', DEFAULT_DATE.isoformat()])) cli.test(self.parser.parse_args([ 'test', 'example_bash_operator', 'runme_0', '--dry_run', DEFAULT_DATE.isoformat()])) def test_cli_test_with_params(self): cli.test(self.parser.parse_args([ 'test', 'example_passing_params_via_test_command', 'run_this', '-tp', '{"foo":"bar"}', DEFAULT_DATE.isoformat()])) cli.test(self.parser.parse_args([ 'test', 'example_passing_params_via_test_command', 'also_run_this', '-tp', '{"foo":"bar"}', DEFAULT_DATE.isoformat()])) def test_cli_run(self): cli.run(self.parser.parse_args([ 'run', 'example_bash_operator', 'runme_0', '-l', DEFAULT_DATE.isoformat()])) def test_task_state(self): cli.task_state(self.parser.parse_args([ 'task_state', 'example_bash_operator', 'runme_0', DEFAULT_DATE.isoformat()])) def test_dag_state(self): self.assertEqual(None, cli.dag_state(self.parser.parse_args([ 'dag_state', 'example_bash_operator', DEFAULT_DATE.isoformat()]))) def test_pause(self): args = self.parser.parse_args([ 'pause', 'example_bash_operator']) cli.pause(args) self.assertIn(self.dagbag.dags['example_bash_operator'].is_paused, [True, 1]) args = self.parser.parse_args([ 'unpause', 'example_bash_operator']) cli.unpause(args) self.assertIn(self.dagbag.dags['example_bash_operator'].is_paused, [False, 0]) def test_subdag_clear(self): args = self.parser.parse_args([ 'clear', 'example_subdag_operator', '--no_confirm']) cli.clear(args) args = self.parser.parse_args([ 'clear', 'example_subdag_operator', '--no_confirm', '--exclude_subdags']) cli.clear(args) def test_backfill(self): cli.backfill(self.parser.parse_args([ 'backfill', 'example_bash_operator', '-s', DEFAULT_DATE.isoformat()])) cli.backfill(self.parser.parse_args([ 'backfill', 'example_bash_operator', '-t', 'runme_0', '--dry_run', '-s', DEFAULT_DATE.isoformat()])) cli.backfill(self.parser.parse_args([ 'backfill', 'example_bash_operator', '--dry_run', '-s', DEFAULT_DATE.isoformat()])) cli.backfill(self.parser.parse_args([ 'backfill', 'example_bash_operator', '-l', '-s', DEFAULT_DATE.isoformat()])) def test_process_subdir_path_with_placeholder(self): self.assertEqual(os.path.join(settings.DAGS_FOLDER, 'abc'), cli.process_subdir('DAGS_FOLDER/abc')) def test_trigger_dag(self): cli.trigger_dag(self.parser.parse_args([ 'trigger_dag', 'example_bash_operator', '-c', '{"foo": "bar"}'])) self.assertRaises( ValueError, cli.trigger_dag, self.parser.parse_args([ 'trigger_dag', 'example_bash_operator', '--run_id', 'trigger_dag_xxx', '-c', 'NOT JSON']) ) def test_pool(self): # Checks if all subcommands are properly received cli.pool(self.parser.parse_args([ 'pool', '-s', 'foo', '1', '"my foo pool"'])) cli.pool(self.parser.parse_args([ 'pool', '-g', 'foo'])) cli.pool(self.parser.parse_args([ 'pool', '-x', 'foo'])) def test_variables(self): # Checks if all subcommands are properly received cli.variables(self.parser.parse_args([ 'variables', '-s', 'foo', '{"foo":"bar"}'])) cli.variables(self.parser.parse_args([ 'variables', '-g', 'foo'])) cli.variables(self.parser.parse_args([ 'variables', '-g', 'baz', '-d', 'bar'])) cli.variables(self.parser.parse_args([ 'variables'])) cli.variables(self.parser.parse_args([ 'variables', '-x', 'bar'])) cli.variables(self.parser.parse_args([ 'variables', '-i', DEV_NULL])) cli.variables(self.parser.parse_args([ 'variables', '-e', DEV_NULL])) cli.variables(self.parser.parse_args([ 'variables', '-s', 'bar', 'original'])) # First export cli.variables(self.parser.parse_args([ 'variables', '-e', 'variables1.json'])) first_exp = open('variables1.json', 'r') cli.variables(self.parser.parse_args([ 'variables', '-s', 'bar', 'updated'])) cli.variables(self.parser.parse_args([ 'variables', '-s', 'foo', '{"foo":"oops"}'])) cli.variables(self.parser.parse_args([ 'variables', '-x', 'foo'])) # First import cli.variables(self.parser.parse_args([ 'variables', '-i', 'variables1.json'])) self.assertEqual('original', models.Variable.get('bar')) self.assertEqual('{"foo": "bar"}', models.Variable.get('foo')) # Second export cli.variables(self.parser.parse_args([ 'variables', '-e', 'variables2.json'])) second_exp = open('variables2.json', 'r') self.assertEqual(first_exp.read(), second_exp.read()) second_exp.close() first_exp.close() # Second import cli.variables(self.parser.parse_args([ 'variables', '-i', 'variables2.json'])) self.assertEqual('original', models.Variable.get('bar')) self.assertEqual('{"foo": "bar"}', models.Variable.get('foo')) session = settings.Session() session.query(Variable).delete() session.commit() session.close() os.remove('variables1.json') os.remove('variables2.json') class CSRFTests(unittest.TestCase): def setUp(self): configuration.load_test_config() configuration.conf.set("webserver", "authenticate", "False") configuration.conf.set("webserver", "expose_config", "True") app = application.create_app() app.config['TESTING'] = True self.app = app.test_client() self.dagbag = models.DagBag( dag_folder=DEV_NULL, include_examples=True) self.dag_bash = self.dagbag.dags['example_bash_operator'] self.runme_0 = self.dag_bash.get_task('runme_0') def get_csrf(self, response): tree = html.fromstring(response.data) form = tree.find('.//form') return form.find('.//input[@name="_csrf_token"]').value def test_csrf_rejection(self): endpoints = ([ "/admin/queryview/", "/admin/airflow/paused?dag_id=example_python_operator&is_paused=false", ]) for endpoint in endpoints: response = self.app.post(endpoint) self.assertIn('CSRF token is missing', response.data.decode('utf-8')) def test_csrf_acceptance(self): response = self.app.get("/admin/queryview/") csrf = self.get_csrf(response) response = self.app.post("/admin/queryview/", data=dict(csrf_token=csrf)) self.assertEqual(200, response.status_code) def tearDown(self): configuration.conf.set("webserver", "expose_config", "False") self.dag_bash.clear(start_date=DEFAULT_DATE, end_date=datetime.now()) class WebUiTests(unittest.TestCase): def setUp(self): configuration.load_test_config() configuration.conf.set("webserver", "authenticate", "False") configuration.conf.set("webserver", "expose_config", "True") app = application.create_app() app.config['TESTING'] = True app.config['WTF_CSRF_METHODS'] = [] self.app = app.test_client() self.dagbag = models.DagBag(include_examples=True) self.dag_bash = self.dagbag.dags['example_bash_operator'] self.dag_bash2 = self.dagbag.dags['test_example_bash_operator'] self.sub_dag = self.dagbag.dags['example_subdag_operator'] self.runme_0 = self.dag_bash.get_task('runme_0') self.dag_bash2.create_dagrun( run_id="test_{}".format(models.DagRun.id_for_date(datetime.now())), execution_date=DEFAULT_DATE, start_date=datetime.now(), state=State.RUNNING ) self.sub_dag.create_dagrun( run_id="test_{}".format(models.DagRun.id_for_date(datetime.now())), execution_date=DEFAULT_DATE, start_date=datetime.now(), state=State.RUNNING ) def test_index(self): response = self.app.get('/', follow_redirects=True) self.assertIn("DAGs", response.data.decode('utf-8')) self.assertIn("example_bash_operator", response.data.decode('utf-8')) def test_query(self): response = self.app.get('/admin/queryview/') self.assertIn("Ad Hoc Query", response.data.decode('utf-8')) response = self.app.post( "/admin/queryview/", data=dict( conn_id="airflow_db", sql="SELECT+COUNT%281%29+as+TEST+FROM+task_instance")) self.assertIn("TEST", response.data.decode('utf-8')) def test_health(self): response = self.app.get('/health') self.assertIn('The server is healthy!', response.data.decode('utf-8')) def test_headers(self): response = self.app.get('/admin/airflow/headers') self.assertIn('"headers":', response.data.decode('utf-8')) def test_noaccess(self): response = self.app.get('/admin/airflow/noaccess') self.assertIn("You don't seem to have access.", response.data.decode('utf-8')) def test_pickle_info(self): response = self.app.get('/admin/airflow/pickle_info') self.assertIn('{', response.data.decode('utf-8')) def test_dag_views(self): response = self.app.get( '/admin/airflow/graph?dag_id=example_bash_operator') self.assertIn("runme_0", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/tree?num_runs=25&dag_id=example_bash_operator') self.assertIn("runme_0", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/duration?days=30&dag_id=example_bash_operator') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/tries?days=30&dag_id=example_bash_operator') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/landing_times?' 'days=30&dag_id=example_bash_operator') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/gantt?dag_id=example_bash_operator') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/code?dag_id=example_bash_operator') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/blocked') response = self.app.get( '/admin/configurationview/') self.assertIn("Airflow Configuration", response.data.decode('utf-8')) self.assertIn("Running Configuration", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/rendered?' 'task_id=runme_1&dag_id=example_bash_operator&' 'execution_date={}'.format(DEFAULT_DATE_ISO)) self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/log?task_id=run_this_last&' 'dag_id=example_bash_operator&execution_date={}' ''.format(DEFAULT_DATE_ISO)) self.assertIn("run_this_last", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/task?' 'task_id=runme_0&dag_id=example_bash_operator&' 'execution_date={}'.format(DEFAULT_DATE_DS)) self.assertIn("Attributes", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/dag_stats') self.assertIn("example_bash_operator", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/task_stats') self.assertIn("example_bash_operator", response.data.decode('utf-8')) url = ( "/admin/airflow/success?task_id=run_this_last&" "dag_id=test_example_bash_operator&upstream=false&downstream=false&" "future=false&past=false&execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) response = self.app.get(url) self.assertIn("Wait a minute", response.data.decode('utf-8')) response = self.app.get(url + "&confirmed=true") response = self.app.get( '/admin/airflow/clear?task_id=run_this_last&' 'dag_id=test_example_bash_operator&future=true&past=false&' 'upstream=true&downstream=false&' 'execution_date={}&' 'origin=/admin'.format(DEFAULT_DATE_DS)) self.assertIn("Wait a minute", response.data.decode('utf-8')) url = ( "/admin/airflow/success?task_id=section-1&" "dag_id=example_subdag_operator&upstream=true&downstream=true&" "future=false&past=false&execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) response = self.app.get(url) self.assertIn("Wait a minute", response.data.decode('utf-8')) self.assertIn("section-1-task-1", response.data.decode('utf-8')) self.assertIn("section-1-task-2", response.data.decode('utf-8')) self.assertIn("section-1-task-3", response.data.decode('utf-8')) self.assertIn("section-1-task-4", response.data.decode('utf-8')) self.assertIn("section-1-task-5", response.data.decode('utf-8')) response = self.app.get(url + "&confirmed=true") url = ( "/admin/airflow/clear?task_id=runme_1&" "dag_id=test_example_bash_operator&future=false&past=false&" "upstream=false&downstream=true&" "execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) response = self.app.get(url) self.assertIn("Wait a minute", response.data.decode('utf-8')) response = self.app.get(url + "&confirmed=true") url = ( "/admin/airflow/run?task_id=runme_0&" "dag_id=example_bash_operator&ignore_all_deps=false&ignore_ti_state=true&" "ignore_task_deps=true&execution_date={}&" "origin=/admin".format(DEFAULT_DATE_DS)) response = self.app.get(url) response = self.app.get( "/admin/airflow/refresh?dag_id=example_bash_operator") response = self.app.get("/admin/airflow/refresh_all") response = self.app.post( "/admin/airflow/paused?" "dag_id=example_python_operator&is_paused=false") self.assertIn("OK", response.data.decode('utf-8')) response = self.app.get("/admin/xcom", follow_redirects=True) self.assertIn("Xcoms", response.data.decode('utf-8')) def test_charts(self): session = Session() chart_label = "Airflow task instance by type" chart = session.query( models.Chart).filter(models.Chart.label == chart_label).first() chart_id = chart.id session.close() response = self.app.get( '/admin/airflow/chart' '?chart_id={}&iteration_no=1'.format(chart_id)) self.assertIn("Airflow task instance by type", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/chart_data' '?chart_id={}&iteration_no=1'.format(chart_id)) self.assertIn("example", response.data.decode('utf-8')) response = self.app.get( '/admin/airflow/dag_details?dag_id=example_branch_operator') self.assertIn("run_this_first", response.data.decode('utf-8')) def test_fetch_task_instance(self): url = ( "/admin/airflow/object/task_instances?" "dag_id=test_example_bash_operator&" "execution_date={}".format(DEFAULT_DATE_DS)) response = self.app.get(url) self.assertIn("run_this_last", response.data.decode('utf-8')) def tearDown(self): configuration.conf.set("webserver", "expose_config", "False") self.dag_bash.clear(start_date=DEFAULT_DATE, end_date=datetime.now()) session = Session() session.query(models.DagRun).delete() session.query(models.TaskInstance).delete() session.commit() session.close() class WebPasswordAuthTest(unittest.TestCase): def setUp(self): configuration.conf.set("webserver", "authenticate", "True") configuration.conf.set("webserver", "auth_backend", "airflow.contrib.auth.backends.password_auth") app = application.create_app() app.config['TESTING'] = True self.app = app.test_client() from airflow.contrib.auth.backends.password_auth import PasswordUser session = Session() user = models.User() password_user = PasswordUser(user) password_user.username = 'airflow_passwordauth' password_user.password = 'password' print(password_user._password) session.add(password_user) session.commit() session.close() def get_csrf(self, response): tree = html.fromstring(response.data) form = tree.find('.//form') return form.find('.//input[@name="_csrf_token"]').value def login(self, username, password): response = self.app.get('/admin/airflow/login') csrf_token = self.get_csrf(response) return self.app.post('/admin/airflow/login', data=dict( username=username, password=password, csrf_token=csrf_token ), follow_redirects=True) def logout(self): return self.app.get('/admin/airflow/logout', follow_redirects=True) def test_login_logout_password_auth(self): self.assertTrue(configuration.getboolean('webserver', 'authenticate')) response = self.login('user1', 'whatever') self.assertIn('Incorrect login details', response.data.decode('utf-8')) response = self.login('airflow_passwordauth', 'wrongpassword') self.assertIn('Incorrect login details', response.data.decode('utf-8')) response = self.login('airflow_passwordauth', 'password') self.assertIn('Data Profiling', response.data.decode('utf-8')) response = self.logout() self.assertIn('form-signin', response.data.decode('utf-8')) def test_unauthorized_password_auth(self): response = self.app.get("/admin/airflow/landing_times") self.assertEqual(response.status_code, 302) def tearDown(self): configuration.load_test_config() session = Session() session.query(models.User).delete() session.commit() session.close() configuration.conf.set("webserver", "authenticate", "False") class WebLdapAuthTest(unittest.TestCase): def setUp(self): configuration.conf.set("webserver", "authenticate", "True") configuration.conf.set("webserver", "auth_backend", "airflow.contrib.auth.backends.ldap_auth") try: configuration.conf.add_section("ldap") except: pass configuration.conf.set("ldap", "uri", "ldap://localhost:3890") configuration.conf.set("ldap", "user_filter", "objectClass=*") configuration.conf.set("ldap", "user_name_attr", "uid") configuration.conf.set("ldap", "bind_user", "cn=Manager,dc=example,dc=com") configuration.conf.set("ldap", "bind_password", "insecure") configuration.conf.set("ldap", "basedn", "dc=example,dc=com") configuration.conf.set("ldap", "cacert", "") app = application.create_app() app.config['TESTING'] = True self.app = app.test_client() def get_csrf(self, response): tree = html.fromstring(response.data) form = tree.find('.//form') return form.find('.//input[@name="_csrf_token"]').value def login(self, username, password): response = self.app.get('/admin/airflow/login') csrf_token = self.get_csrf(response) return self.app.post('/admin/airflow/login', data=dict( username=username, password=password, csrf_token=csrf_token ), follow_redirects=True) def logout(self): return self.app.get('/admin/airflow/logout', follow_redirects=True) def test_login_logout_ldap(self): self.assertTrue(configuration.getboolean('webserver', 'authenticate')) response = self.login('user1', 'userx') self.assertIn('Incorrect login details', response.data.decode('utf-8')) response = self.login('userz', 'user1') self.assertIn('Incorrect login details', response.data.decode('utf-8')) response = self.login('user1', 'user1') self.assertIn('Data Profiling', response.data.decode('utf-8')) response = self.logout() self.assertIn('form-signin', response.data.decode('utf-8')) def test_unauthorized(self): response = self.app.get("/admin/airflow/landing_times") self.assertEqual(response.status_code, 302) def test_no_filter(self): response = self.login('user1', 'user1') self.assertIn('Data Profiling', response.data.decode('utf-8')) self.assertIn('Connections', response.data.decode('utf-8')) def test_with_filters(self): configuration.conf.set('ldap', 'superuser_filter', 'description=superuser') configuration.conf.set('ldap', 'data_profiler_filter', 'description=dataprofiler') response = self.login('dataprofiler', 'dataprofiler') self.assertIn('Data Profiling', response.data.decode('utf-8')) response = self.login('superuser', 'superuser') self.assertIn('Connections', response.data.decode('utf-8')) def tearDown(self): configuration.load_test_config() session = Session() session.query(models.User).delete() session.commit() session.close() configuration.conf.set("webserver", "authenticate", "False") class LdapGroupTest(unittest.TestCase): def setUp(self): configuration.conf.set("webserver", "authenticate", "True") configuration.conf.set("webserver", "auth_backend", "airflow.contrib.auth.backends.ldap_auth") try: configuration.conf.add_section("ldap") except: pass configuration.conf.set("ldap", "uri", "ldap://localhost:3890") configuration.conf.set("ldap", "user_filter", "objectClass=*") configuration.conf.set("ldap", "user_name_attr", "uid") configuration.conf.set("ldap", "bind_user", "cn=Manager,dc=example,dc=com") configuration.conf.set("ldap", "bind_password", "insecure") configuration.conf.set("ldap", "basedn", "dc=example,dc=com") configuration.conf.set("ldap", "cacert", "") def test_group_belonging(self): from airflow.contrib.auth.backends.ldap_auth import LdapUser users = {"user1": ["group1", "group3"], "user2": ["group2"] } for user in users: mu = models.User(username=user, is_superuser=False) auth = LdapUser(mu) self.assertEqual(set(users[user]), set(auth.ldap_groups)) def tearDown(self): configuration.load_test_config() configuration.conf.set("webserver", "authenticate", "False") class FakeSession(object): def __init__(self): from requests import Response self.response = Response() self.response.status_code = 200 self.response._content = 'airbnb/airflow'.encode('ascii', 'ignore') def send(self, request, **kwargs): return self.response def prepare_request(self, request): if 'date' in request.params: self.response._content += ( '/' + request.params['date']).encode('ascii', 'ignore') return self.response class HttpOpSensorTest(unittest.TestCase): def setUp(self): configuration.load_test_config() args = {'owner': 'airflow', 'start_date': DEFAULT_DATE_ISO} dag = DAG(TEST_DAG_ID, default_args=args) self.dag = dag @mock.patch('requests.Session', FakeSession) def test_get(self): t = SimpleHttpOperator( task_id='get_op', method='GET', endpoint='/search', data={"client": "ubuntu", "q": "airflow"}, headers={}, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) @mock.patch('requests.Session', FakeSession) def test_get_response_check(self): t = SimpleHttpOperator( task_id='get_op', method='GET', endpoint='/search', data={"client": "ubuntu", "q": "airflow"}, response_check=lambda response: ("airbnb/airflow" in response.text), headers={}, dag=self.dag) t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) @mock.patch('requests.Session', FakeSession) def test_sensor(self): sensor = sensors.HttpSensor( task_id='http_sensor_check', http_conn_id='http_default', endpoint='/search', params={"client": "ubuntu", "q": "airflow", 'date': '{{ds}}'}, headers={}, response_check=lambda response: ( "airbnb/airflow/" + DEFAULT_DATE.strftime('%Y-%m-%d') in response.text), poke_interval=5, timeout=15, dag=self.dag) sensor.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, ignore_ti_state=True) class FakeWebHDFSHook(object): def __init__(self, conn_id): self.conn_id = conn_id def get_conn(self): return self.conn_id def check_for_path(self, hdfs_path): return hdfs_path class FakeSnakeBiteClientException(Exception): pass class FakeSnakeBiteClient(object): def __init__(self): self.started = True def ls(self, path, include_toplevel=False): """ the fake snakebite client :param path: the array of path to test :param include_toplevel: to return the toplevel directory info :return: a list for path for the matching queries """ if path[0] == '/datadirectory/empty_directory' and not include_toplevel: return [] elif path[0] == '/datadirectory/datafile': return [{'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 0, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/datafile'}] elif path[0] == '/datadirectory/empty_directory' and include_toplevel: return [ {'group': u'supergroup', 'permission': 493, 'file_type': 'd', 'access_time': 0, 'block_replication': 0, 'modification_time': 1481132141540, 'length': 0, 'blocksize': 0, 'owner': u'hdfs', 'path': '/datadirectory/empty_directory'}] elif path[0] == '/datadirectory/not_empty_directory' and include_toplevel: return [ {'group': u'supergroup', 'permission': 493, 'file_type': 'd', 'access_time': 0, 'block_replication': 0, 'modification_time': 1481132141540, 'length': 0, 'blocksize': 0, 'owner': u'hdfs', 'path': '/datadirectory/empty_directory'}, {'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 0, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/not_empty_directory/test_file'}] elif path[0] == '/datadirectory/not_empty_directory': return [{'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 0, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/not_empty_directory/test_file'}] elif path[0] == '/datadirectory/not_existing_file_or_directory': raise FakeSnakeBiteClientException elif path[0] == '/datadirectory/regex_dir': return [{'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 12582912, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/regex_dir/test1file'}, {'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 12582912, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/regex_dir/test2file'}, {'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 12582912, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/regex_dir/test3file'}, {'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 12582912, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/regex_dir/copying_file_1.txt._COPYING_'}, {'group': u'supergroup', 'permission': 420, 'file_type': 'f', 'access_time': 1481122343796, 'block_replication': 3, 'modification_time': 1481122343862, 'length': 12582912, 'blocksize': 134217728, 'owner': u'hdfs', 'path': '/datadirectory/regex_dir/copying_file_3.txt.sftp'} ] else: raise FakeSnakeBiteClientException class FakeHDFSHook(object): def __init__(self, conn_id=None): self.conn_id = conn_id def get_conn(self): client = FakeSnakeBiteClient() return client class ConnectionTest(unittest.TestCase): def setUp(self): configuration.load_test_config() utils.db.initdb() os.environ['AIRFLOW_CONN_TEST_URI'] = ( 'postgres://username:password@ec2.compute.com:5432/the_database') os.environ['AIRFLOW_CONN_TEST_URI_NO_CREDS'] = ( 'postgres://ec2.compute.com/the_database') def tearDown(self): env_vars = ['AIRFLOW_CONN_TEST_URI', 'AIRFLOW_CONN_AIRFLOW_DB'] for ev in env_vars: if ev in os.environ: del os.environ[ev] def test_using_env_var(self): c = SqliteHook.get_connection(conn_id='test_uri') self.assertEqual('ec2.compute.com', c.host) self.assertEqual('the_database', c.schema) self.assertEqual('username', c.login) self.assertEqual('password', c.password) self.assertEqual(5432, c.port) def test_using_unix_socket_env_var(self): c = SqliteHook.get_connection(conn_id='test_uri_no_creds') self.assertEqual('ec2.compute.com', c.host) self.assertEqual('the_database', c.schema) self.assertIsNone(c.login) self.assertIsNone(c.password) self.assertIsNone(c.port) def test_param_setup(self): c = models.Connection(conn_id='local_mysql', conn_type='mysql', host='localhost', login='airflow', password='airflow', schema='airflow') self.assertEqual('localhost', c.host) self.assertEqual('airflow', c.schema) self.assertEqual('airflow', c.login) self.assertEqual('airflow', c.password) self.assertIsNone(c.port) def test_env_var_priority(self): c = SqliteHook.get_connection(conn_id='airflow_db') self.assertNotEqual('ec2.compute.com', c.host) os.environ['AIRFLOW_CONN_AIRFLOW_DB'] = \ 'postgres://username:password@ec2.compute.com:5432/the_database' c = SqliteHook.get_connection(conn_id='airflow_db') self.assertEqual('ec2.compute.com', c.host) self.assertEqual('the_database', c.schema) self.assertEqual('username', c.login) self.assertEqual('password', c.password) self.assertEqual(5432, c.port) del os.environ['AIRFLOW_CONN_AIRFLOW_DB'] def test_dbapi_get_uri(self): conn = BaseHook.get_connection(conn_id='test_uri') hook = conn.get_hook() self.assertEqual('postgres://username:password@ec2.compute.com:5432/the_database', hook.get_uri()) conn2 = BaseHook.get_connection(conn_id='test_uri_no_creds') hook2 = conn2.get_hook() self.assertEqual('postgres://ec2.compute.com/the_database', hook2.get_uri()) def test_dbapi_get_sqlalchemy_engine(self): conn = BaseHook.get_connection(conn_id='test_uri') hook = conn.get_hook() engine = hook.get_sqlalchemy_engine() self.assertIsInstance(engine, sqlalchemy.engine.Engine) self.assertEqual('postgres://username:password@ec2.compute.com:5432/the_database', str(engine.url)) def test_get_connections_env_var(self): conns = SqliteHook.get_connections(conn_id='test_uri') assert len(conns) == 1 assert conns[0].host == 'ec2.compute.com' assert conns[0].schema == 'the_database' assert conns[0].login == 'username' assert conns[0].password == 'password' assert conns[0].port == 5432 def test_get_connections_db(self): conns = BaseHook.get_connections(conn_id='airflow_db') assert len(conns) == 1 assert conns[0].host == 'localhost' assert conns[0].schema == 'airflow' assert conns[0].login == 'root' class WebHDFSHookTest(unittest.TestCase): def setUp(self): configuration.load_test_config() def test_simple_init(self): from airflow.hooks.webhdfs_hook import WebHDFSHook c = WebHDFSHook() self.assertIsNone(c.proxy_user) def test_init_proxy_user(self): from airflow.hooks.webhdfs_hook import WebHDFSHook c = WebHDFSHook(proxy_user='someone') self.assertEqual('someone', c.proxy_user) try: from airflow.hooks.hdfs_hook import HDFSHook import snakebite except ImportError: HDFSHook = None @unittest.skipIf(HDFSHook is None, "Skipping test because HDFSHook is not installed") class HDFSHookTest(unittest.TestCase): def setUp(self): configuration.load_test_config() os.environ['AIRFLOW_CONN_HDFS_DEFAULT'] = ('hdfs://localhost:8020') def test_get_client(self): client = HDFSHook(proxy_user='foo').get_conn() self.assertIsInstance(client, snakebite.client.Client) self.assertEqual('localhost', client.host) self.assertEqual(8020, client.port) self.assertEqual('foo', client.service.channel.effective_user) @mock.patch('airflow.hooks.hdfs_hook.AutoConfigClient') @mock.patch('airflow.hooks.hdfs_hook.HDFSHook.get_connections') def test_get_autoconfig_client(self, mock_get_connections, MockAutoConfigClient): c = models.Connection(conn_id='hdfs', conn_type='hdfs', host='localhost', port=8020, login='foo', extra=json.dumps({'autoconfig': True})) mock_get_connections.return_value = [c] HDFSHook(hdfs_conn_id='hdfs').get_conn() MockAutoConfigClient.assert_called_once_with(effective_user='foo', use_sasl=False) @mock.patch('airflow.hooks.hdfs_hook.AutoConfigClient') def test_get_autoconfig_client_no_conn(self, MockAutoConfigClient): HDFSHook(hdfs_conn_id='hdfs_missing', autoconfig=True).get_conn() MockAutoConfigClient.assert_called_once_with(effective_user=None, use_sasl=False) @mock.patch('airflow.hooks.hdfs_hook.HDFSHook.get_connections') def test_get_ha_client(self, mock_get_connections): c1 = models.Connection(conn_id='hdfs_default', conn_type='hdfs', host='localhost', port=8020) c2 = models.Connection(conn_id='hdfs_default', conn_type='hdfs', host='localhost2', port=8020) mock_get_connections.return_value = [c1, c2] client = HDFSHook().get_conn() self.assertIsInstance(client, snakebite.client.HAClient) try: from airflow.hooks.S3_hook import S3Hook except ImportError: S3Hook = None @unittest.skipIf(S3Hook is None, "Skipping test because S3Hook is not installed") class S3HookTest(unittest.TestCase): def setUp(self): configuration.load_test_config() self.s3_test_url = "s3://test/this/is/not/a-real-key.txt" def test_parse_s3_url(self): parsed = S3Hook.parse_s3_url(self.s3_test_url) self.assertEqual(parsed, ("test", "this/is/not/a-real-key.txt"), "Incorrect parsing of the s3 url") HELLO_SERVER_CMD = """ import socket, sys listener = socket.socket() listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) listener.bind(('localhost', 2134)) listener.listen(1) sys.stdout.write('ready') sys.stdout.flush() conn = listener.accept()[0] conn.sendall(b'hello') """ class SSHHookTest(unittest.TestCase): def setUp(self): configuration.load_test_config() from airflow.contrib.hooks.ssh_hook import SSHHook self.hook = SSHHook() self.hook.no_host_key_check = True def test_remote_cmd(self): output = self.hook.check_output(["echo", "-n", "airflow"]) self.assertEqual(output, b"airflow") def test_tunnel(self): print("Setting up remote listener") import subprocess import socket self.handle = self.hook.Popen([ "python", "-c", '"{0}"'.format(HELLO_SERVER_CMD) ], stdout=subprocess.PIPE) print("Setting up tunnel") with self.hook.tunnel(2135, 2134): print("Tunnel up") server_output = self.handle.stdout.read(5) self.assertEqual(server_output, b"ready") print("Connecting to server via tunnel") s = socket.socket() s.connect(("localhost", 2135)) print("Receiving...", ) response = s.recv(5) self.assertEqual(response, b"hello") print("Closing connection") s.close() print("Waiting for listener...") output, _ = self.handle.communicate() self.assertEqual(self.handle.returncode, 0) print("Closing tunnel") send_email_test = mock.Mock() class EmailTest(unittest.TestCase): def setUp(self): configuration.remove_option('email', 'EMAIL_BACKEND') @mock.patch('airflow.utils.email.send_email') def test_default_backend(self, mock_send_email): res = utils.email.send_email('to', 'subject', 'content') mock_send_email.assert_called_with('to', 'subject', 'content') self.assertEqual(mock_send_email.return_value, res) @mock.patch('airflow.utils.email.send_email_smtp') def test_custom_backend(self, mock_send_email): configuration.set('email', 'EMAIL_BACKEND', 'tests.core.send_email_test') utils.email.send_email('to', 'subject', 'content') send_email_test.assert_called_with('to', 'subject', 'content', files=None, dryrun=False, cc=None, bcc=None, mime_subtype='mixed') self.assertFalse(mock_send_email.called) class EmailSmtpTest(unittest.TestCase): def setUp(self): configuration.set('smtp', 'SMTP_SSL', 'False') @mock.patch('airflow.utils.email.send_MIME_email') def test_send_smtp(self, mock_send_mime): attachment = tempfile.NamedTemporaryFile() attachment.write(b'attachment') attachment.seek(0) utils.email.send_email_smtp('to', 'subject', 'content', files=[attachment.name]) self.assertTrue(mock_send_mime.called) call_args = mock_send_mime.call_args[0] self.assertEqual(configuration.get('smtp', 'SMTP_MAIL_FROM'), call_args[0]) self.assertEqual(['to'], call_args[1]) msg = call_args[2] self.assertEqual('subject', msg['Subject']) self.assertEqual(configuration.get('smtp', 'SMTP_MAIL_FROM'), msg['From']) self.assertEqual(2, len(msg.get_payload())) self.assertEqual(u'attachment; filename="' + os.path.basename(attachment.name) + '"', msg.get_payload()[-1].get(u'Content-Disposition')) mimeapp = MIMEApplication('attachment') self.assertEqual(mimeapp.get_payload(), msg.get_payload()[-1].get_payload()) @mock.patch('airflow.utils.email.send_MIME_email') def test_send_bcc_smtp(self, mock_send_mime): attachment = tempfile.NamedTemporaryFile() attachment.write(b'attachment') attachment.seek(0) utils.email.send_email_smtp('to', 'subject', 'content', files=[attachment.name], cc='cc', bcc='bcc') self.assertTrue(mock_send_mime.called) call_args = mock_send_mime.call_args[0] self.assertEqual(configuration.get('smtp', 'SMTP_MAIL_FROM'), call_args[0]) self.assertEqual(['to', 'cc', 'bcc'], call_args[1]) msg = call_args[2] self.assertEqual('subject', msg['Subject']) self.assertEqual(configuration.get('smtp', 'SMTP_MAIL_FROM'), msg['From']) self.assertEqual(2, len(msg.get_payload())) self.assertEqual(u'attachment; filename="' + os.path.basename(attachment.name) + '"', msg.get_payload()[-1].get(u'Content-Disposition')) mimeapp = MIMEApplication('attachment') self.assertEqual(mimeapp.get_payload(), msg.get_payload()[-1].get_payload()) @mock.patch('smtplib.SMTP_SSL') @mock.patch('smtplib.SMTP') def test_send_mime(self, mock_smtp, mock_smtp_ssl): mock_smtp.return_value = mock.Mock() mock_smtp_ssl.return_value = mock.Mock() msg = MIMEMultipart() utils.email.send_MIME_email('from', 'to', msg, dryrun=False) mock_smtp.assert_called_with( configuration.get('smtp', 'SMTP_HOST'), configuration.getint('smtp', 'SMTP_PORT'), ) self.assertTrue(mock_smtp.return_value.starttls.called) mock_smtp.return_value.login.assert_called_with( configuration.get('smtp', 'SMTP_USER'), configuration.get('smtp', 'SMTP_PASSWORD'), ) mock_smtp.return_value.sendmail.assert_called_with('from', 'to', msg.as_string()) self.assertTrue(mock_smtp.return_value.quit.called) @mock.patch('smtplib.SMTP_SSL') @mock.patch('smtplib.SMTP') def test_send_mime_ssl(self, mock_smtp, mock_smtp_ssl): configuration.set('smtp', 'SMTP_SSL', 'True') mock_smtp.return_value = mock.Mock() mock_smtp_ssl.return_value = mock.Mock() utils.email.send_MIME_email('from', 'to', MIMEMultipart(), dryrun=False) self.assertFalse(mock_smtp.called) mock_smtp_ssl.assert_called_with( configuration.get('smtp', 'SMTP_HOST'), configuration.getint('smtp', 'SMTP_PORT'), ) @mock.patch('smtplib.SMTP_SSL') @mock.patch('smtplib.SMTP') def test_send_mime_noauth(self, mock_smtp, mock_smtp_ssl): configuration.conf.remove_option('smtp', 'SMTP_USER') configuration.conf.remove_option('smtp', 'SMTP_PASSWORD') mock_smtp.return_value = mock.Mock() mock_smtp_ssl.return_value = mock.Mock() utils.email.send_MIME_email('from', 'to', MIMEMultipart(), dryrun=False) self.assertFalse(mock_smtp_ssl.called) mock_smtp.assert_called_with( configuration.get('smtp', 'SMTP_HOST'), configuration.getint('smtp', 'SMTP_PORT'), ) self.assertFalse(mock_smtp.login.called) @mock.patch('smtplib.SMTP_SSL') @mock.patch('smtplib.SMTP') def test_send_mime_dryrun(self, mock_smtp, mock_smtp_ssl): utils.email.send_MIME_email('from', 'to', MIMEMultipart(), dryrun=True) self.assertFalse(mock_smtp.called) self.assertFalse(mock_smtp_ssl.called) if __name__ == '__main__': unittest.main()
easytaxibr/airflow
tests/core.py
Python
apache-2.0
93,982
class TreeNode: def __init__(self, x): self.val = x self.left = None class Solution: def distributeCoins(self, root: TreeNode) -> int: total = 0 def dfs(node): if not node: return 0 L, R = dfs(node.left), dfs(node.right) total += abs(L) + abs(R) return node.val + L + R - 1 dfs(root) return total
ccqpein/Arithmetic-Exercises
Distribute-Coins-in-Binary-Tree/DCIBT.py
Python
apache-2.0
433
#!/usr/bin/env python from __future__ import absolute_import from .annotator import Annotator, AnnoTier, AnnoSpan import re import pyparsing as pypar def word_token_regex(disallowed_delimiter): return pypar.Regex(r"[^\s\n" + re.escape(disallowed_delimiter) + r"]+") pypar.ParserElement.setDefaultWhitespaceChars(" \t") table_parser = pypar.NoMatch() table_cell_separators = ["|", "/", ","] for separator in table_cell_separators: value = pypar.Combine( word_token_regex(separator) * (0, 10), joinString=' ', adjacent=False) value.setParseAction(lambda start, tokens: (start, tokens[0])) empty = pypar.Empty() empty.setParseAction(lambda start, tokens: (start, tokens)) value = pypar.Group(value + empty) row = pypar.Group(pypar.Optional(separator).suppress() + (value + pypar.Literal(separator).suppress()) * (1, None) + pypar.Optional(value) + (pypar.StringEnd() | pypar.Literal("\n")).suppress() + pypar.Optional("\n").suppress()) table_parser ^= ( (pypar.LineStart() + pypar.Optional(pypar.White())).suppress() + # Allow line breaks for table headings row + pypar.Optional(pypar.Regex(r"[\-_=]{3,}") + pypar.Literal("\n") * (1, 2)).suppress() + row * (0, None)).setResultsName("delimiter:" + separator) table_parser.parseWithTabs() key_value_separators = [":", "-", ">"] key_value_list_parser = pypar.NoMatch() for separator in key_value_separators: value = pypar.Combine( word_token_regex(separator) * (1, 10), joinString=' ', adjacent=False) value.setParseAction(lambda start, tokens: (start, tokens[0])) empty = pypar.Empty() empty.setParseAction(lambda start, tokens: (start, tokens)) value = pypar.Group(value + empty) row = pypar.Group(value + pypar.Literal(separator).suppress() + value + (pypar.StringEnd() | pypar.Literal("\n")).suppress() + pypar.Optional("\n").suppress()) key_value_list_parser ^= ( (pypar.LineStart() + pypar.Optional(pypar.White())).suppress() + row * (2, None)).setResultsName("delimiter:" + separator) key_value_list_parser.parseWithTabs() class StructuredDataAnnotator(Annotator): """ Annotates tables and key value lists embedded in documents. """ def annotate(self, doc): doc_text_len = len(doc.text) def create_trimmed_annospan_for_doc(start, end, label=None, metadata=None): return AnnoSpan( start, min(doc_text_len, end), doc, label=label, metadata=metadata).trimmed() spans = [] value_spans = [] for token, start, end in table_parser.scanString(doc.text): data = [[ create_trimmed_annospan_for_doc(value_start, value_end) for ((value_start, value), (value_end, _)) in row] for row in token] new_value_spans = [value for row in data for value in row] # Skip tables with one row and numeric/empty columns since they are likely # to be confused with unstructured text punctuation. if len(data) == 1: if len(new_value_spans) < 3: continue elif any(re.match(r"\d*$", value.text) for value in new_value_spans): continue # Skip tables with differing numbers of columns in each row else: row_lengths = sorted([len(row) for row in data]) # Determine the min and max difference between any two row lengths. max_diff = row_lengths[-1] - row_lengths[0] min_diff = max_diff for row_len, next_row_len in zip(row_lengths, row_lengths[1:]): len_diff = next_row_len - row_len if len_diff < min_diff: min_diff = len_diff if min_diff > 0 and max_diff > 1: continue spans.append(create_trimmed_annospan_for_doc(start, end, "table", metadata={ "type": "table", "data": data, "delimiter": next(k.split("delimiter:")[1] for k in token.keys() if k.startswith("delimiter:")) })) value_spans += new_value_spans for token, start, end in key_value_list_parser.scanString(doc.text): data = { create_trimmed_annospan_for_doc(key_start, key_end): create_trimmed_annospan_for_doc(value_start, value_end) for (((key_start, key), (key_end, _)), ((value_start, value), (value_end, _2))) in token } spans.append(create_trimmed_annospan_for_doc(start, end, "keyValuePairs", metadata={ "type": "keyValuePairs", "data": data, "delimiter": next(k.split("delimiter:")[1] for k in token.keys() if k.startswith("delimiter:")) })) value_spans += data.values() return { 'structured_data': AnnoTier(spans), 'structured_data.values': AnnoTier(value_spans) }
ecohealthalliance/EpiTator
epitator/structured_data_annotator.py
Python
apache-2.0
5,239
import tensorflow as tf import tensorflow.contrib.slim as slim import pprint import os from datasets import dataset_factory from dcgan import dcgan_generator, dcgan_discriminator from train import dcgan_train_step from tensorflow.python.training import optimizer from collections import OrderedDict from utils import graph_replace #from keras.optimizers import Adam flags = tf.app.flags flags.DEFINE_integer('batch_size', 128, 'The size of minibatch when training [128]') flags.DEFINE_float('learning_rate', 2e-4, 'Learning rate of optimizer [2e-4]') flags.DEFINE_string('optimizer', 'Adam', 'Optimizer used when training [Adam]') flags.DEFINE_string('dataset_name', 'mnist', 'Image dataset used when trainging [mnist]') flags.DEFINE_string('split_name', 'train', 'Split name of dataset [train]') flags.DEFINE_string('dataset_dir', './data/mnist/', 'Path to dataset directory [./data/mnist]') flags.DEFINE_string('checkpoint_path', None, 'Path to checkpoint path [None]') flags.DEFINE_string('train_dir', './train', 'Path to save new training result [./train]') flags.DEFINE_integer('max_step', 1000, 'Maximum training steps [1000]') flags.DEFINE_integer('z_dim', 100, 'z-dim for generator [100]') flags.DEFINE_float('beta1', 0.5, 'Beta1 for Adam optimizer [0.5]') flags.DEFINE_float('beta2', 0.999, 'Beta2 for Adam optimizer [0.999]') flags.DEFINE_float('epsilon', 1e-8, 'Epsilon for Adam optimizer [1e-8]') flags.DEFINE_integer('log_every_n_steps', 10, 'Log every n training steps [10]') flags.DEFINE_integer('save_interval_secs', 600, 'How often, in seconds, to save the model checkpoint [600]') flags.DEFINE_integer('save_summaries_secs', 10, 'How often, in seconds, to save the summary [10]') flags.DEFINE_integer('sample_n', 16, 'How many images the network will produce in a sample process [16]') flags.DEFINE_integer('unrolled_step', 0, 'Unrolled step in surrogate loss for generator [0]') def extract_update_dict(update_ops): """Extract the map between tensor and its updated version in update_ops""" update_map = OrderedDict() name_to_var = {v.name: v for v in tf.global_variables()} for u in update_ops: var_name = u.op.inputs[0].name var = name_to_var[var_name] value = u.op.inputs[1] if u.op.type == 'Assign': update_map[var.value()] = value elif u.op.type == 'AssignAdd': update_map[var.value()] = value + var else: raise ValueError('Undefined unroll update type %s', u.op.type) return update_map def main(*args): FLAGS = flags.FLAGS pp = pprint.PrettyPrinter(indent=4) print('Running flags:') pp.pprint(FLAGS.__dict__['__flags']) tf.logging.set_verbosity('INFO') config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Graph().as_default(): provider = slim.dataset_data_provider.DatasetDataProvider(dataset_factory.get_dataset(FLAGS.dataset_name, FLAGS.split_name, FLAGS.dataset_dir), common_queue_capacity=2*FLAGS.batch_size, common_queue_min=FLAGS.batch_size) [image] = provider.get(['image']) image = tf.to_float(image) image = tf.subtract(tf.divide(image, 127.5), 1) z = tf.random_uniform(shape=([FLAGS.z_dim]), minval=-1, maxval=1, name='z') label_true = tf.random_uniform(shape=([]), minval=0.7, maxval=1.2, name='label_t') label_false = tf.random_uniform(shape=([]), minval=0, maxval=0.3, name='label_f') sampler_z = tf.random_uniform(shape=([FLAGS.batch_size, FLAGS.z_dim]), minval=-1, maxval=1, name='sampler_z') [image, z, label_true, label_false] = tf.train.batch([image, z, label_true, label_false], batch_size=FLAGS.batch_size, capacity=2*FLAGS.batch_size) generator_result = dcgan_generator(z, 'Generator', reuse=False, output_height=28, fc1_c=1024, grayscale=True) sampler_result = dcgan_generator(sampler_z, 'Generator', reuse=True, output_height=28, fc1_c=1024, grayscale=True) discriminator_g, g_logits = dcgan_discriminator(generator_result, 'Discriminator', reuse=False, conv2d1_c=128, grayscale=True) discriminator_d, d_logits = dcgan_discriminator(image, 'Discriminator', reuse=True, conv2d1_c=128, grayscale=True) d_loss = tf.losses.sigmoid_cross_entropy(multi_class_labels=label_false, logits=g_logits) + \ tf.losses.sigmoid_cross_entropy(multi_class_labels=label_true, logits=d_logits) standard_g_loss = tf.losses.sigmoid_cross_entropy(multi_class_labels=label_true, logits=g_logits) if FLAGS.optimizer == 'Adam': g_optimizer = tf.train.AdamOptimizer(learning_rate=FLAGS.learning_rate, beta1=FLAGS.beta1, beta2=FLAGS.beta2, epsilon=FLAGS.epsilon, name='g_adam') d_optimizer = tf.train.AdamOptimizer(learning_rate=FLAGS.learning_rate, beta1=FLAGS.beta1, beta2=FLAGS.beta2, epsilon=FLAGS.epsilon, name='d_adam') #unrolled_optimizer = Adam(lr=FLAGS.learning_rate, # beta_1=FLAGS.beta1, # beta_2=FLAGS.beta2, # epsilon=FLAGS.epsilon) elif FLAGS.optimizer == 'SGD': g_optimizer = tf.train.GradientDescentOptimizer(learning_rate=FLAGS.learning_rate, name='g_sgd') d_optimizer = tf.train.GradientDescentOptimizer(learning_rate=FLAGS.learning_rate, name='d_sgd') var_g = slim.get_variables(scope='Generator', collection=tf.GraphKeys.TRAINABLE_VARIABLES) var_d = slim.get_variables(scope='Discriminator', collection=tf.GraphKeys.TRAINABLE_VARIABLES) #update_ops = unrolled_optimizer.get_updates(var_d, [], d_loss) #update_map = extract_update_dict(update_ops) #current_update_map = update_map #pp.pprint(current_update_map) current_update_map = OrderedDict() for i in xrange(FLAGS.unrolled_step): grads_d = list(zip(tf.gradients(standard_g_loss, var_d), var_d)) update_map = OrderedDict() for g, v in grads_d: update_map[v.value()] = v + g * FLAGS.learning_rate current_update_map = graph_replace(update_map, update_map) pp.pprint(current_update_map) if FLAGS.unrolled_step != 0: unrolled_loss = graph_replace(standard_g_loss, current_update_map) g_loss = unrolled_loss else: g_loss = standard_g_loss generator_global_step = slim.variable("generator_global_step", shape=[], dtype=tf.int64, initializer=tf.zeros_initializer, trainable=False) discriminator_global_step = slim.variable("discriminator_global_step", shape=[], dtype=tf.int64, initializer=tf.zeros_initializer, trainable=False) global_step = slim.get_or_create_global_step() with tf.name_scope('train_step'): train_step_kwargs = {} train_step_kwargs['g'] = generator_global_step train_step_kwargs['d'] = discriminator_global_step if FLAGS.max_step: train_step_kwargs['should_stop'] = tf.greater_equal(global_step, FLAGS.max_step) else: train_step_kwargs['should_stop'] = tf.constant(False) train_step_kwargs['should_log'] = tf.equal(tf.mod(global_step, FLAGS.log_every_n_steps), 0) train_op_d = slim.learning.create_train_op(d_loss, d_optimizer, variables_to_train=var_d, global_step=discriminator_global_step) train_op_g = slim.learning.create_train_op(g_loss, g_optimizer, variables_to_train=var_g, global_step=generator_global_step) train_op_s = tf.assign_add(global_step, 1) train_op = [train_op_g, train_op_d, train_op_s] def group_image(images): sampler_result = tf.split(images, FLAGS.batch_size // 16, axis=0) group_sample = [] for sample in sampler_result: unstack_sample = tf.unstack(sample, num=16, axis=0) group_sample.append(tf.concat([tf.concat([unstack_sample[i*4+j] for j in range(4)], axis=1) for i in range(4)], axis=0)) sampler_result = tf.stack(group_sample, axis=0) return sampler_result sampler_result = group_image(sampler_result) train_data = group_image(image) tf.summary.image('sampler_z', sampler_result, max_outputs=16) tf.summary.image('train_data', train_data, max_outputs=16) tf.summary.scalar('loss/g_loss', g_loss) tf.summary.scalar('loss/d_loss', d_loss) tf.summary.scalar('loss/standard_g_loss', standard_g_loss) tf.summary.scalar('loss/total_loss', g_loss + d_loss) tf.summary.scalar('loss/standard_total_loss', standard_g_loss + d_loss) if FLAGS.unrolled_step != 0: tf.summary.scalar('loss/unrolled_loss', unrolled_loss) saver = tf.train.Saver() with tf.Session(config=config) as sess: sess.run(tf.global_variables_initializer()) if FLAGS.checkpoint_path: if not tf.train.checkpoint_exists(FLAGS.checkpoint_path): raise ValueError('Checkpoint not exist in path ', FLAGS.checkpoint_path) else: restore_vars = slim.get_variables_to_restore(exclude_patterns=split(FLAGS.exclude_scope, ',')) sess.run(slim.assign_from_checkpoint(FLAGS.checkpoint_path, restore_vars, ignore_missing_vars=False)) slim.learning.train(train_op, FLAGS.train_dir, global_step=global_step, train_step_fn=dcgan_train_step, train_step_kwargs=train_step_kwargs, saver=saver, save_interval_secs=FLAGS.save_interval_secs, save_summaries_secs=FLAGS.save_summaries_secs) return if __name__ == '__main__': tf.app.run(main=main)
lishuwnc/DCGAN
main.py
Python
apache-2.0
10,297
# Copyright 2014-2016 The Meson development team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os from . import coredata, environment, mesonlib, build, mintro, mlog from .ast import AstIDGenerator def add_arguments(parser): coredata.register_builtin_arguments(parser) parser.add_argument('builddir', nargs='?', default='.') parser.add_argument('--clearcache', action='store_true', default=False, help='Clear cached state (e.g. found dependencies)') def make_lower_case(val): if isinstance(val, bool): return str(val).lower() elif isinstance(val, list): return [make_lower_case(i) for i in val] else: return str(val) class ConfException(mesonlib.MesonException): pass class Conf: def __init__(self, build_dir): self.build_dir = os.path.abspath(os.path.realpath(build_dir)) if 'meson.build' in [os.path.basename(self.build_dir), self.build_dir]: self.build_dir = os.path.dirname(self.build_dir) self.build = None self.max_choices_line_length = 60 self.name_col = [] self.value_col = [] self.choices_col = [] self.descr_col = [] self.has_choices = False self.all_subprojects = set() self.yielding_options = set() if os.path.isdir(os.path.join(self.build_dir, 'meson-private')): self.build = build.load(self.build_dir) self.source_dir = self.build.environment.get_source_dir() self.coredata = coredata.load(self.build_dir) self.default_values_only = False elif os.path.isfile(os.path.join(self.build_dir, environment.build_filename)): # Make sure that log entries in other parts of meson don't interfere with the JSON output mlog.disable() self.source_dir = os.path.abspath(os.path.realpath(self.build_dir)) intr = mintro.IntrospectionInterpreter(self.source_dir, '', 'ninja', visitors = [AstIDGenerator()]) intr.analyze() # Re-enable logging just in case mlog.enable() self.coredata = intr.coredata self.default_values_only = True else: raise ConfException('Directory {} is neither a Meson build directory nor a project source directory.'.format(build_dir)) def clear_cache(self): self.coredata.deps.host.clear() self.coredata.deps.build.clear() def set_options(self, options): self.coredata.set_options(options) def save(self): # Do nothing when using introspection if self.default_values_only: return # Only called if something has changed so overwrite unconditionally. coredata.save(self.coredata, self.build_dir) # We don't write the build file because any changes to it # are erased when Meson is executed the next time, i.e. when # Ninja is run. def print_aligned(self): col_widths = (max([len(i) for i in self.name_col], default=0), max([len(i) for i in self.value_col], default=0), max([len(i) for i in self.choices_col], default=0)) for line in zip(self.name_col, self.value_col, self.choices_col, self.descr_col): if self.has_choices: print('{0:{width[0]}} {1:{width[1]}} {2:{width[2]}} {3}'.format(*line, width=col_widths)) else: print('{0:{width[0]}} {1:{width[1]}} {3}'.format(*line, width=col_widths)) def split_options_per_subproject(self, options): result = {} for k, o in options.items(): subproject = '' if ':' in k: subproject, optname = k.split(':') if o.yielding and optname in options: self.yielding_options.add(k) self.all_subprojects.add(subproject) result.setdefault(subproject, {})[k] = o return result def _add_line(self, name, value, choices, descr): self.name_col.append(' ' * self.print_margin + name) self.value_col.append(value) self.choices_col.append(choices) self.descr_col.append(descr) def add_option(self, name, descr, value, choices): if isinstance(value, list): value = '[{0}]'.format(', '.join(make_lower_case(value))) else: value = make_lower_case(value) if choices: self.has_choices = True if isinstance(choices, list): choices_list = make_lower_case(choices) current = '[' while choices_list: i = choices_list.pop(0) if len(current) + len(i) >= self.max_choices_line_length: self._add_line(name, value, current + ',', descr) name = '' value = '' descr = '' current = ' ' if len(current) > 1: current += ', ' current += i choices = current + ']' else: choices = make_lower_case(choices) else: choices = '' self._add_line(name, value, choices, descr) def add_title(self, title): titles = {'descr': 'Description', 'value': 'Current Value', 'choices': 'Possible Values'} if self.default_values_only: titles['value'] = 'Default Value' self._add_line('', '', '', '') self._add_line(title, titles['value'], titles['choices'], titles['descr']) self._add_line('-' * len(title), '-' * len(titles['value']), '-' * len(titles['choices']), '-' * len(titles['descr'])) def add_section(self, section): self.print_margin = 0 self._add_line('', '', '', '') self._add_line(section + ':', '', '', '') self.print_margin = 2 def print_options(self, title, options): if not options: return if title: self.add_title(title) for k, o in sorted(options.items()): printable_value = o.printable_value() if k in self.yielding_options: printable_value = '<inherited from main project>' self.add_option(k, o.description, printable_value, o.choices) def print_conf(self): def print_default_values_warning(): mlog.warning('The source directory instead of the build directory was specified.') mlog.warning('Only the default values for the project are printed, and all command line parameters are ignored.') if self.default_values_only: print_default_values_warning() print('') print('Core properties:') print(' Source dir', self.source_dir) if not self.default_values_only: print(' Build dir ', self.build_dir) dir_option_names = ['bindir', 'datadir', 'includedir', 'infodir', 'libdir', 'libexecdir', 'localedir', 'localstatedir', 'mandir', 'prefix', 'sbindir', 'sharedstatedir', 'sysconfdir'] test_option_names = ['errorlogs', 'stdsplit'] core_option_names = [k for k in self.coredata.builtins if k not in dir_option_names + test_option_names] dir_options = {k: o for k, o in self.coredata.builtins.items() if k in dir_option_names} test_options = {k: o for k, o in self.coredata.builtins.items() if k in test_option_names} core_options = {k: o for k, o in self.coredata.builtins.items() if k in core_option_names} def insert_build_prefix(k): idx = k.find(':') if idx < 0: return 'build.' + k return k[:idx + 1] + 'build.' + k[idx + 1:] core_options = self.split_options_per_subproject(core_options) host_compiler_options = self.split_options_per_subproject( dict(self.coredata.flatten_lang_iterator( self.coredata.compiler_options.host.items()))) build_compiler_options = self.split_options_per_subproject( dict(self.coredata.flatten_lang_iterator( (insert_build_prefix(k), o) for k, o in self.coredata.compiler_options.build.items()))) project_options = self.split_options_per_subproject(self.coredata.user_options) show_build_options = self.default_values_only or self.build.environment.is_cross_build() self.add_section('Main project options') self.print_options('Core options', core_options['']) self.print_options('', self.coredata.builtins_per_machine.host) if show_build_options: self.print_options('', {insert_build_prefix(k): o for k, o in self.coredata.builtins_per_machine.build.items()}) self.print_options('Backend options', self.coredata.backend_options) self.print_options('Base options', self.coredata.base_options) self.print_options('Compiler options', host_compiler_options.get('', {})) if show_build_options: self.print_options('', build_compiler_options.get('', {})) self.print_options('Directories', dir_options) self.print_options('Testing options', test_options) self.print_options('Project options', project_options.get('', {})) for subproject in sorted(self.all_subprojects): if subproject == '': continue self.add_section('Subproject ' + subproject) if subproject in core_options: self.print_options('Core options', core_options[subproject]) if subproject in host_compiler_options: self.print_options('Compiler options', host_compiler_options[subproject]) if subproject in build_compiler_options and show_build_options: self.print_options('', build_compiler_options[subproject]) if subproject in project_options: self.print_options('Project options', project_options[subproject]) self.print_aligned() # Print the warning twice so that the user shouldn't be able to miss it if self.default_values_only: print('') print_default_values_warning() def run(options): coredata.parse_cmd_line_options(options) builddir = os.path.abspath(os.path.realpath(options.builddir)) c = None try: c = Conf(builddir) if c.default_values_only: c.print_conf() return 0 save = False if len(options.cmd_line_options) > 0: c.set_options(options.cmd_line_options) coredata.update_cmd_line_file(builddir, options) save = True elif options.clearcache: c.clear_cache() save = True else: c.print_conf() if save: c.save() mintro.update_build_options(c.coredata, c.build.environment.info_dir) mintro.write_meson_info_file(c.build, []) except ConfException as e: print('Meson configurator encountered an error:') if c is not None and c.build is not None: mintro.write_meson_info_file(c.build, [e]) raise e return 0
becm/meson
mesonbuild/mconf.py
Python
apache-2.0
12,095
#------------------------------------------------------------------------------ # Copyright 2013 Esri # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #------------------------------------------------------------------------------ # Name: TestAddDTEDtoElevationMosaicDataset.py # Requirements: ArcGIS Desktop Standard #------------------------------------------------------------------------------ import arcpy import os import sys import traceback import TestUtilities def RunTest(): try: arcpy.AddMessage("Starting Test: Add DTED To Elevation Mosaic Dataset") toolbox = TestUtilities.toolbox arcpy.ImportToolbox(toolbox, "DefenseTopo") arcpy.env.overwriteOutput = True inputMosaicDataset = os.path.join(TestUtilities.inputGDB, "Elevation_Test") print(inputMosaicDataset) # Set environment settings print("Running from: " + str(TestUtilities.currentPath)) print("Geodatabase path: " + str(TestUtilities.geodatabasePath)) arcpy.env.overwriteOutput = True ########################################################3 # Execute the Model under test: arcpy.Model_DefenseTopo(inputMosaicDataset, TestUtilities.sampleInputPath) ########################################################3 inputFeatureCount2 = int(arcpy.GetCount_management(inputMosaicDataset).getOutput(0)) print("Input FeatureClass: " + str(inputMosaicDataset)) print("Input Feature Count: " + str(inputFeatureCount2)) if (inputFeatureCount2 <= 0) : print("Invalid Input Feature Count: " + str(inputFeatureCount2)) raise Exception("Test Failed") print("Test Successful") except arcpy.ExecuteError: # Get the tool error messages msgs = arcpy.GetMessages() arcpy.AddError(msgs) # return a system error code sys.exit(-1) except Exception as e: # Get the traceback object tb = sys.exc_info()[2] tbinfo = traceback.format_tb(tb)[0] # Concatenate information together concerning the error into a message string pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages() + "\n" # Return python error messages for use in script tool or Python Window arcpy.AddError(pymsg) arcpy.AddError(msgs) # return a system error code sys.exit(-1) RunTest()
JudTown17/solutions-geoprocessing-toolbox
data_management/test/test_topographic_tools/TestAddDTEDtoElevationMosaicDataset.py
Python
apache-2.0
3,123
# Copyright 2022 The Magenta Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Tests for metrics.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from magenta.models.onsets_frames_transcription import infer_util import numpy as np import tensorflow.compat.v1 as tf tf.disable_v2_behavior() class InferUtilTest(tf.test.TestCase): def testProbsToPianorollViterbi(self): frame_probs = np.array([[0.2, 0.1], [0.5, 0.1], [0.5, 0.1], [0.8, 0.1]]) onset_probs = np.array([[0.1, 0.1], [0.1, 0.1], [0.9, 0.1], [0.1, 0.1]]) pianoroll = infer_util.probs_to_pianoroll_viterbi(frame_probs, onset_probs) np.testing.assert_array_equal( [[False, False], [False, False], [True, False], [True, False]], pianoroll) if __name__ == '__main__': tf.test.main()
magenta/magenta
magenta/models/onsets_frames_transcription/infer_util_test.py
Python
apache-2.0
1,356
import uuid def is_username(val): """ If the value parses as a UUID, then it's an ID, not a username. If it does not parse as such, then it must be a username. """ try: uuid.UUID(val) return False except ValueError: return True def split_ids_and_usernames(identity_ids): ids = set() usernames = set() for val in identity_ids: if is_username(val): usernames.add(val) else: ids.add(val) return ids, usernames class IdentityMap: r""" There's a common pattern of having a large batch of Globus Auth Identities which you want to inspect. For example, you may have a list of identity IDs fetched from Access Control Lists on Globus Endpoints. In order to display these identities to an end user, you may want to resolve them to usernames. However, naively looking up the identities one-by-one is very inefficient. It's best to do batched lookups with multiple identities at once. In these cases, an ``IdentityMap`` can be used to do those batched lookups for you. An ``IdentityMap`` is a mapping-like type which converts Identity IDs and Identity Names to Identity records (dictionaries) using the Globus Auth API. .. note:: ``IdentityMap`` objects are not full Mappings in the same sense as python dicts and similar objects. By design, they only implement a small part of the Mapping protocol. The basic usage pattern is - create an ``IdentityMap`` with an AuthClient which will be used to call out to Globus Auth - seed the ``IdentityMap`` with IDs and Usernames via :py:meth:`~IdentityMap.add` (you can also do this during initialization) - retrieve identity IDs or Usernames from the map Because the map can be populated with a collection of identity IDs and Usernames prior to lookups being performed, it can improve the efficiency of these operations up to 100x over individual lookups. If you attempt to retrieve an identity which has not been previously added to the map, it will be immediately added. But adding many identities beforehand will improve performance. The ``IdentityMap`` will cache its results so that repeated lookups of the same Identity will not repeat work. It will also map identities both by ID and by Username, regardless of how they're initially looked up. .. warning:: If an Identity is not found in Globus Auth, it will trigger a KeyError when looked up. Your code must be ready to handle KeyErrors when doing a lookup. Correct usage looks something like so:: ac = globus_sdk.AuthClient(...) idmap = globus_sdk.IdentityMap( ac, ["foo@globusid.org", "bar@uchicago.edu"] ) idmap.add("baz@xsede.org") # adding by ID is also valid idmap.add("c699d42e-d274-11e5-bf75-1fc5bf53bb24") # map ID to username assert ( idmap["c699d42e-d274-11e5-bf75-1fc5bf53bb24"]["username"] == "go@globusid.org" ) # map username to ID assert ( idmap["go@globusid.org"]["id"] == "c699d42e-d274-11e5-bf75-1fc5bf53bb24" ) And simple handling of errors:: try: record = idmap["no-such-valid-id@example.org"] except KeyError: username = "NO_SUCH_IDENTITY" else: username = record["username"] or you may achieve this by using the :py:meth:`~.IdentityMap.get` method:: # internally handles the KeyError and returns the default value record = idmap.get("no-such-valid-id@example.org", None) username = record["username"] if record is not None else "NO_SUCH_IDENTITY" :param auth_client: The client object which will be used for lookups against Globus Auth :type auth_client: :class:`AuthClient <globus_sdk.AuthClient>` :param identity_ids: A list or other iterable of usernames or identity IDs (potentially mixed together) which will be used to seed the ``IdentityMap`` 's tracking of unresolved Identities. :type identity_ids: iterable of str :param id_batch_size: A non-default batch size to use when communicating with Globus Auth. Leaving this set to the default is strongly recommended. :type id_batch_size: int, optional .. automethodlist:: globus_sdk.IdentityMap include_methods=__getitem__,__delitem__ """ # noqa _default_id_batch_size = 100 def __init__(self, auth_client, identity_ids=None, id_batch_size=None): self.auth_client = auth_client self.id_batch_size = id_batch_size or self._default_id_batch_size # uniquify, copy, and split into IDs vs usernames self.unresolved_ids, self.unresolved_usernames = split_ids_and_usernames( [] if identity_ids is None else identity_ids ) # the cache is a dict mapping IDs and Usernames self._cache = {} def _fetch_batch_including(self, key): """ Batch resolve identifiers (usernames or IDs), being sure to include the desired, named key. The key also determines which kind of batch will be built -- usernames or IDs. Store the results in the internal cache. """ # for whichever set of unresolved names is appropriate, build the batch to # lookup up to *at most* the batch size # also, remove the unresolved names from tracking so that they will not be # looked up again batch = [] set_to_use = ( self.unresolved_usernames if is_username(key) else self.unresolved_ids ) for _ in range(0, min(self.id_batch_size - 1, len(set_to_use))): batch.append(set_to_use.pop()) # avoid double-adding the provided key, but add it if it's missing if key not in batch: batch.append(key) else: try: batch.append(set_to_use.pop()) except KeyError: # empty set, ignore pass response = self.auth_client.get_identities( **(dict(usernames=batch) if is_username(key) else dict(ids=batch)) ) for x in response["identities"]: self._cache[x["id"]] = x self._cache[x["username"]] = x def add(self, identity_id): """ Add a username or ID to the ``IdentityMap`` for batch lookups later. Returns True if the ID was added for lookup. Returns False if it was rejected as a duplicate of an already known name. :param identity_id: A string Identity ID or Identity Name (a.k.a. "username") to add :type identity_id: str """ if identity_id in self._cache: return False if is_username(identity_id): if identity_id in self.unresolved_usernames: return False else: self.unresolved_usernames.add(identity_id) return True if identity_id in self.unresolved_ids: return False self.unresolved_ids.add(identity_id) return True def get(self, key, default=None): """ A dict-like get() method which accepts a default value. """ try: return self[key] except KeyError: return default def __getitem__(self, key): """ ``IdentityMap`` supports dict-like lookups with ``map[key]`` """ if key not in self._cache: self._fetch_batch_including(key) return self._cache[key] def __delitem__(self, key): """ ``IdentityMap`` supports ``del map[key]``. Note that this only removes lookup values from the cache and will not impact the set of unresolved/pending IDs. """ del self._cache[key]
globusonline/globus-sdk-python
globus_sdk/auth/identity_map.py
Python
apache-2.0
7,931
#!/usr/bin/python import logging import logging.handlers def setupLogger(log_path, verbose): logger = logging.getLogger('hive') logger.setLevel(logging.DEBUG) logger.propagate = False fh = logging.handlers.TimedRotatingFileHandler(log_path, when="midnight", backupCount=5) fh.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) if verbose: ch.setLevel(logging.DEBUG) else: ch.setLevel(logging.ERROR) # create formatter and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) fh.setFormatter(formatter) # Add the handlers to the logger logger.addHandler(fh) logger.addHandler(ch)
krcooke/hive-home
bin/utils/logger.py
Python
apache-2.0
803
from django import forms from aat.models import RecognizerPreTrainedData class DefaultDetectionForm(forms.Form): title = "Please specify the directory containing your videos" #video = forms.FileField(required=True, widget=forms.ClearableFileInput()) video = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}), required=True) detection = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) recognizer = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) objdetection = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) transcription = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) class ComplexDetectionForm(forms.Form): CHOICES = [('Yes', 'Yes'), ('No', 'No')] title = "Please upload your video in zip format" #video = forms.FileField(required=True, widget=forms.ClearableFileInput()) video = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}), required=True) detection = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) recognizer = forms.ChoiceField(choices=[('LBPH', 'Local Binary Patterns Histogram'), ('EF', 'Eighen Faces'), ('FF', 'Fisher Faces'), #('KNN', 'LBPH using K-Nearest Neighbor'), ('false', 'Do not recognize faces')], widget=forms.Select(attrs={'class': 'form-control ' 'select select-primary', 'data-toggle': 'select'})) faces_database = forms.ModelChoiceField(queryset= RecognizerPreTrainedData.objects.values_list('name', flat=True), to_field_name='facedb', empty_label='(Nothing)') objdetection = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) transcription = forms.CharField(widget=forms.HiddenInput(), required=True, initial=False) #iszip = forms.ChoiceField(choices=CHOICES, # widget=forms.RadioSelect(attrs={'data-toggle': 'radio'})) scale = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control', 'step': '0.1', 'placeholder': '1.3'})) neighbors = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '5'})) min_x_dimension = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '10'})) min_y_dimension = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '10'})) bounding_boxes = forms.BooleanField(required=False, initial=True) # facesdb = forms.FileField(required=False, widget=forms.ClearableFileInput())
fedjo/thesis
project/aat/forms.py
Python
apache-2.0
3,217
def init_actions_(service, args): """ this needs to returns an array of actions representing the depencies between actions. Looks at ACTION_DEPS in this module for an example of what is expected """ # some default logic for simple actions return { 'test': ['install'] } def test(job): """ Tests parsing of a bp with/without default values """ import sys RESULT_OK = 'OK : %s' RESULT_FAILED = 'FAILED : %s' RESULT_ERROR = 'ERROR : %s %%s' % job.service.name model = job.service.model model.data.result = RESULT_OK % job.service.name test_repo_path = j.sal.fs.joinPaths(j.dirs.varDir, 'tmp', 'test_validate_model') sample_bp_path = j.sal.fs.joinPaths('/opt/code/github/jumpscale/jumpscale_core8/tests/samples/test_validate_delete_model_sample.yaml') try: if j.sal.fs.exists(test_repo_path): j.sal.fs.removeDirTree(test_repo_path) test_repo = j.atyourservice.repoCreate(test_repo_path, 'git@github.com:0-complexity/ays_automatic_cockpit_based_testing.git') bp_path = j.sal.fs.joinPaths(test_repo.path, 'blueprints', 'test_validate_delete_model_sample.yaml') j.sal.fs.copyFile(j.sal.fs.joinPaths(sample_bp_path), j.sal.fs.joinPaths(test_repo.path, 'blueprints')) test_repo.blueprintExecute(bp_path) action = 'install' role = 'sshkey' instance = 'main' for service in test_repo.servicesFind(actor="%s.*" % role, name=instance): service.scheduleAction(action=action, period=None, log=True, force=False) run = test_repo.runCreate(profile=False, debug=False) run.execute() test_repo.destroy() if j.sal.fs.exists(j.sal.fs.joinPaths(test_repo.path, "actors")): model.data.result = RESULT_FAILED % ('Actors directory is not deleted') if j.sal.fs.exists(j.sal.fs.joinPaths(test_repo.path, "services")): model.data.result = RESULT_FAILED % ('Services directory is not deleted') if j.sal.fs.exists(j.sal.fs.joinPaths(test_repo.path, "recipes")): model.data.result = RESULT_FAILED % ('Recipes directory is not deleted') if test_repo.actors: model.data.result = RESULT_FAILED % ('Actors model is not removed') if test_repo.services: model.data.result = RESULT_FAILED % ('Services model is not removed') if not j.core.jobcontroller.db.runs.find(repo=test_repo.model.key): model.data.result = RESULT_FAILED % ('Jobs are deleted after repository destroy') except: model.data.result = RESULT_ERROR % str(sys.exc_info()[:2]) finally: job.service.save()
Jumpscale/ays_jumpscale8
tests/test_services/test_validate_delete_models/actions.py
Python
apache-2.0
2,695
from python_cowbull_server import error_handler from flask_helpers.check_kwargs import check_kwargs class GameMode(object): """ A representation of a game mode (complexity, number of digits, guesses allowed, etc.). The mode contains the following information: * mode <str> A text name for the mode. * priority <int> An integer of the priority in terms of returning a list. * digits <int> An integer representing the number of digits used in this mode. * digit_type <int> An integer representing the type of digit used, e.g. Hex or Digit * guesses_allowed <int> An integer representing the number of guesses that can be made * instruction_text <str> A free form string for instructions on the mode * help_text <str> A free form string offering help text for the mode """ # Simplify method as per http://sonarqube:9000/project/issues?id=cowbull_server&issues=AWiRMJ-OaAhZ-jY-ujHk&open=AWiRMJ-OaAhZ-jY-ujHk def __init__( self, **kwargs ): """ Constructor to create a new mode. :param mode: <str> A text name for the mode. :param priority: <int> priority of modes (in terms of returning a list) :param digits: <int> number of digits used in this mode. :param digit_type: <int> type of digit, e.g. DigitWord.HEXDIGIT or DigitWord.DIGIT :param guesses_allowed: <int> Number of guesses permitted. :param instruction_text: <str> Instruction text (dependent upon caller to show) :param help_text: <str> Help text (dependent upon caller to show) """ check_kwargs( parameter_list=[ "mode", "priority", "digits", "digit_type", "guesses_allowed", "instruction_text", "help_text" ], caller="GameMode__init__", **kwargs ) mode=kwargs.get("mode", None) priority=kwargs.get("priority", None) digits=kwargs.get("digits", None) digit_type=kwargs.get("digit_type", None) guesses_allowed=kwargs.get("guesses_allowed", None) instruction_text=kwargs.get("instruction_text", None) help_text=kwargs.get("help_text", None) # execute_load error handler # self.handler = ErrorHandler(module="GameMode", method="__init__") self.handler = error_handler self.handler.module = "GameMode" self.handler.method = "__init__" # Initialize variables self.handler.log(message="Initializing variables") self._mode = None self._priority = None self._digits = None self._digit_type = None self._guesses_allowed = None self._instruction_text = None self._help_text = None # NOTICE: Properties are used to set 'private' fields (e.g. _mode) to handle # data validation in one place. When adding a new parameter to __init__ ensure # that the property is created (following the existing code) and set the # property not the 'internal' variable. # self.handler.log(message="Creating mode {}".format(mode)) self.mode = mode self.priority = priority self.digits = digits self.digit_type = digit_type self.guesses_allowed = guesses_allowed self.instruction_text = instruction_text self.help_text = help_text self.handler.log(message="Mode {} created: {}".format(mode, self.dump())) # # Overrides # def __str__(self): """ Override of __str__ method. :return: <str> representation of the GameMode """ return str(self.dump()) def __repr__(self): """ Override of __repr__ method. :return: <str> representation of object showing mode name """ return "<GameObject: mode: {}>".format(self._mode) # # Properties # @property def mode(self): """ The name of the mode. :return: <str> """ return self._mode @mode.setter def mode(self, value): self._mode = self._property_setter( keyword="mode", required=True, datatype=str, value=value ) @property def priority(self): """ The priority of the mode when collected in a list. For example: priority 10 is less than 20, so 10 will come before 20 in a list of GameMode objects. This is useful because other modules might return a sorted list of GameMode objects to their callers and priority provides a simple means to sort and sequence a collection of GameMode objects. :return: <int> """ return self._priority @priority.setter def priority(self, value): self._priority = self._property_setter( keyword="priority", required=True, datatype=int, value=value ) @property def digits(self): """ The number of digits used by the DigitWord used in this mode; e.g. a value of 3 would indicate there are three digits (e.g. 1, 2, and 3), while a value of 5 would indicate five values (e.g. 0, 1, 2, 3, 4). :return: <int> """ return self._digits @digits.setter def digits(self, value): self._digits = self._property_setter( keyword="digits", required=False, default=4, datatype=int, value=value ) @property def digit_type(self): """ The digit_type is a flag used to specify the type of digit to be used; for example, a digit (DigitWord.DIGIT) enables a single digit between 0 and 9, while a hex digit (DigitWord.HEXDIGIT) enables a single digit between 0 and F. :return: <int> """ return self._digit_type @digit_type.setter def digit_type(self, value): self._digit_type = self._property_setter( keyword="digit_type", required=False, default=0, datatype=int, value=value ) @property def guesses_allowed(self): """ The number of guesses the mode is allowed; for example an easy mode might allow 20 guesses while a hard mode only allowed 7. :return: <int> """ return self._guesses_allowed @guesses_allowed.setter def guesses_allowed(self, value): self._guesses_allowed = self._property_setter( keyword="guesses_allowed", required=False, default=10, datatype=int, value=value ) @property def instruction_text(self): """ Instructions on how to use the mode (if present). :return: <str> """ return self._instruction_text @instruction_text.setter def instruction_text(self, value): self._instruction_text = self._property_setter( keyword="instruction_text", required=False, datatype=str, value=value ) @property def help_text(self): """ Help text intended to guide the user on how to use and interact with the game mode. :return: <str> """ return self._help_text @help_text.setter def help_text(self, value): self._help_text = self._property_setter( keyword="help_text", required=False, datatype=str, value=value ) # # 'public' methods # def dump(self): """ Dump (convert to a dict) the GameMode object :return: <dict> """ return { "mode": self._mode, "priority": self._priority, "digits": self._digits, "digit_type": self._digit_type, "guesses_allowed": self._guesses_allowed, "instruction_text": self._instruction_text, "help_text": self._help_text } # # 'private' methods # def _property_setter( self, keyword=None, required=None, default=None, datatype=None, value=None, ): if datatype == str: _value = str(value) # To handle unicode to str conversion in Python 2.7 else: _value = value if required and not _value and not default: self.handler.log(method="_property_setter", message="Required property {} not provided".format(keyword, _value)) raise KeyError("GameMode: '{}' not provided to __init__ and no default provided (or allowed).".format(keyword)) if not _value and default is not None: _value = default if _value and not isinstance(_value, datatype): self.handler.log(method="_property_setter", message="**ERROR** Set property {}:{} TypeError".format(keyword, _value)) raise TypeError("{} is of type {} where {} was expected.".format(keyword, type(_value), datatype)) return _value
dsandersAzure/python_cowbull_server
Game/GameMode.py
Python
apache-2.0
9,034
# Copyright (C) 2016 Matt Griswold <grizz@20c.com> # # This file is part of bgpfu # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import collections.abc import ipaddress from bgpfu.prefixlist import PrefixListBase def _try_combine(aggregate, current): "try combining and replacing the last element on the aggregate list" if aggregate and aggregate[-1]: supernet = aggregate[-1].supernet() if supernet == current.supernet(): aggregate[-1] = supernet return True return False def _do_aggregate(prefixlist): if len(prefixlist) <= 1: return prefixlist prefixlist = sorted(prefixlist) # TODO check for default and skip it? aggregate = [] while True: current = None for pfx in prefixlist: if not current: current = pfx continue if current.overlaps(pfx): continue # try joining 2 supernet = current.supernet() if supernet == pfx.supernet(): current = supernet continue # nothing to combine, shift aggregate.append(current) current = pfx if current: if not _try_combine(aggregate, current): aggregate.append(current) if len(aggregate) == len(prefixlist): return aggregate prefixlist = aggregate aggregate = [] class SimplePrefixList(PrefixListBase, collections.abc.MutableSequence): """ Simple PrefixList implemenatation using collections *NOTE* loses prefix length info on aggregate """ def __init__(self, prefixes=None): if prefixes: self._prefixes = list(map(ipaddress.ip_network, list(map(str, prefixes)))) else: self._prefixes = [] def __getitem__(self, i): return self._prefixes[i] def __setitem__(self, i, v): self._prefixes[i] = self.check_val(v) def insert(self, i, v): self._prefixes.insert(i, self.check_val(v)) def iter_add(self, it): for v in it: self._prefixes.append(self.check_val(v)) def __delitem__(self, i): del self._prefixes[i] def __len__(self): return len(self._prefixes) def __eq__(self, other): if isinstance(other, self.__class__): return self._prefixes == other._prefixes raise TypeError("object not PrefixList type") def __ne__(self, other): return not self == other def __str__(self): return str(self._prefixes) @property def ipv4(self): return [p for p in self._prefixes if p.version == 4] @property def ipv6(self): return [p for p in self._prefixes if p.version == 6] def str_list(self): return list(map(str, self._prefixes)) def aggregate(self): "returns a PrefixList containing the result of aggregating the list" if len(self._prefixes) == 1: return self.__class__(self._prefixes) # v4 = sorted(self._prefixes) v4 = [p for p in self._prefixes if p.version == 4] v6 = [p for p in self._prefixes if p.version == 6] v4 = _do_aggregate(v4) v6 = _do_aggregate(v6) return self.__class__(v4 + v6)
bgpfu/bgpfu
src/bgpfu/prefixlist/simple.py
Python
apache-2.0
3,810
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################### # Copyright Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### import cherrypy import mako import mimetypes import os import six import girder.events from girder import constants, logprint, __version__ from girder.utility import plugin_utilities, model_importer from girder.utility import config from . import webroot with open(os.path.join(os.path.dirname(__file__), 'error.mako')) as f: _errorTemplate = f.read() def _errorDefault(status, message, *args, **kwargs): """ This is used to render error pages outside of the normal Girder app, such as 404's. This overrides the default cherrypy error pages. """ return mako.template.Template(_errorTemplate).render(status=status, message=message) def configureServer(test=False, plugins=None, curConfig=None): """ Function to setup the cherrypy server. It configures it, but does not actually start it. :param test: Set to True when running in the tests. :type test: bool :param plugins: If you wish to start the server with a custom set of plugins, pass this as a list of plugins to load. Otherwise, will use the PLUGINS_ENABLED setting value from the db. :param curConfig: The configuration dictionary to update. """ if curConfig is None: curConfig = config.getConfig() routeTable = loadRouteTable() appconf = { '/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), 'request.show_tracebacks': test, 'request.methods_with_bodies': ('POST', 'PUT', 'PATCH'), 'response.headers.server': 'Girder %s' % __version__, 'error_page.default': _errorDefault } } # Add MIME types for serving Fontello files from staticdir; # these may be missing or incorrect in the OS mimetypes.add_type('application/vnd.ms-fontobject', '.eot') mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('application/font-woff', '.woff') if test: appconf['/src'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/src', } appconf['/test'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients/web/test', } appconf['/clients'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'clients' } appconf['/plugins'] = { 'tools.staticdir.on': True, 'tools.staticdir.root': constants.STATIC_ROOT_DIR, 'tools.staticdir.dir': 'plugins', } curConfig.update(appconf) if test: # Force some config params in testing mode curConfig.update({'server': { 'mode': 'testing', 'api_root': 'api/v1', 'static_root': 'static', 'api_static_root': '../static' }}) mode = curConfig['server']['mode'].lower() logprint.info('Running in mode: ' + mode) cherrypy.config['engine.autoreload.on'] = mode == 'development' # Don't import this until after the configs have been read; some module # initialization code requires the configuration to be set up. from girder.api import api_main root = webroot.Webroot() api_main.addApiToNode(root) cherrypy.engine.subscribe('start', girder.events.daemon.start) cherrypy.engine.subscribe('stop', girder.events.daemon.stop) if plugins is None: settings = model_importer.ModelImporter().model('setting') plugins = settings.get(constants.SettingKey.PLUGINS_ENABLED, default=()) plugins = list(plugin_utilities.getToposortedPlugins(plugins, ignoreMissing=True)) root.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': os.path.relpath(routeTable[constants.GIRDER_STATIC_ROUTE_ID], routeTable[constants.GIRDER_ROUTE_ID]), 'plugins': plugins }) # Make the staticRoot relative to the api_root, if possible. The api_root # could be relative or absolute, but it needs to be in an absolute form for # relpath to behave as expected. We always expect the api_root to # contain at least two components, but the reference from static needs to # be from only the first component. apiRootBase = os.path.split(os.path.join('/', curConfig['server']['api_root']))[0] root.api.v1.updateHtmlVars({ 'apiRoot': curConfig['server']['api_root'], 'staticRoot': os.path.relpath(routeTable[constants.GIRDER_STATIC_ROUTE_ID], apiRootBase) }) root, appconf, _ = plugin_utilities.loadPlugins( plugins, root, appconf, root.api.v1, buildDag=False) return root, appconf def loadRouteTable(reconcileRoutes=False): """ Retrieves the route table from Girder and reconciles the state of it with the current application state. Reconciliation ensures that every enabled plugin has a route by assigning default routes for plugins that have none, such as newly-enabled plugins. :returns: The non empty routes (as a dict of name -> route) to be mounted by CherryPy during Girder's setup phase. """ pluginWebroots = plugin_utilities.getPluginWebroots() setting = model_importer.ModelImporter().model('setting') routeTable = setting.get(constants.SettingKey.ROUTE_TABLE) def reconcileRouteTable(routeTable): hasChanged = False for name in pluginWebroots.keys(): if name not in routeTable: routeTable[name] = os.path.join('/', name) hasChanged = True if hasChanged: setting.set(constants.SettingKey.ROUTE_TABLE, routeTable) return routeTable if reconcileRoutes: routeTable = reconcileRouteTable(routeTable) return {name: route for (name, route) in six.viewitems(routeTable) if route} def setup(test=False, plugins=None, curConfig=None): """ Configure and mount the Girder server and plugins under the appropriate routes. See ROUTE_TABLE setting. :param test: Whether to start in test mode. :param plugins: List of plugins to enable. :param curConfig: The config object to update. """ pluginWebroots = plugin_utilities.getPluginWebroots() girderWebroot, appconf = configureServer(test, plugins, curConfig) routeTable = loadRouteTable(reconcileRoutes=True) # Mount Girder application = cherrypy.tree.mount(girderWebroot, str(routeTable[constants.GIRDER_ROUTE_ID]), appconf) # Mount static files cherrypy.tree.mount(None, routeTable[constants.GIRDER_STATIC_ROUTE_ID], {'/': {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.join(constants.STATIC_ROOT_DIR, 'clients/web/static'), 'request.show_tracebacks': appconf['/']['request.show_tracebacks'], 'response.headers.server': 'Girder %s' % __version__, 'error_page.default': _errorDefault}}) # Mount API (special case) # The API is always mounted at /api AND at api relative to the Girder root cherrypy.tree.mount(girderWebroot.api, '/api', appconf) # Mount everything else in the routeTable for (name, route) in six.viewitems(routeTable): if name != constants.GIRDER_ROUTE_ID and name in pluginWebroots: cherrypy.tree.mount(pluginWebroots[name], route, appconf) if test: application.merge({'server': {'mode': 'testing'}}) return application class _StaticFileRoute(object): exposed = True def __init__(self, path, contentType=None): self.path = os.path.abspath(path) self.contentType = contentType def GET(self): return cherrypy.lib.static.serve_file(self.path, content_type=self.contentType) def staticFile(path, contentType=None): """ Helper function to serve a static file. This should be bound as the route object, i.e. info['serverRoot'].route_name = staticFile('...') :param path: The path of the static file to serve from this route. :type path: str :param contentType: The MIME type of the static file. If set to None, the content type wll be guessed by the file extension of the 'path' argument. """ return _StaticFileRoute(path, contentType)
sutartmelson/girder
girder/utility/server.py
Python
apache-2.0
9,533
# Lint as: python3 # Copyright 2021 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Base class for all models. The model solely consists of the network, while the task combines one or several models with one or several learners/optimizers. """ from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union import jax from jax import numpy as jnp from lingvo.jax import base_input from lingvo.jax import base_layer from lingvo.jax import layers from lingvo.jax import metric_utils from lingvo.jax import py_utils from lingvo.jax import train_states NestedMap = py_utils.NestedMap JTensor = base_layer.JTensor InstantiableParams = py_utils.InstantiableParams Predictions = Union[JTensor, NestedMap, Dict[str, Any]] Metrics = Dict[str, Tuple[JTensor, JTensor]] TrainState = train_states.TrainState def _compute_xent_loss_helper( predictions: NestedMap, input_batch: NestedMap, return_predictions: bool) -> Tuple[Metrics, Dict[str, Any]]: """Helper for computing the xent loss for Language model and Sequence model. Args: predictions: A `.NestedMap` containing the keys `per_example_argmax`, `total_loss`, `avg_xent`, `aux_loss`, `total_weight` which corresponds to the output of the Softmax layer. input_batch: A `.NestedMap` object containing input tensors which contains the keys `labels` and `weights` which corresponds to the labels and the `weights` for each token in the sequence. return_predictions: Whether to return predictions, which can be more expensive. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to correspond to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. The base class just returns an empty dict. """ if 'tgt' in input_batch: labels = input_batch.tgt.labels if 'paddings' in input_batch.tgt: weights = 1.0 - input_batch.tgt.paddings else: weights = jnp.not_equal(input_batch.tgt.segment_ids, 0) weights = weights.astype(labels.dtype) else: labels = input_batch.labels weights = input_batch.weights predicted_labels = predictions.per_example_argmax.astype(labels.dtype) num_preds = predictions.total_weight mean_acc = jnp.sum( (labels == predicted_labels) * weights) / jnp.maximum(num_preds, 1) metric_weight = jnp.array(num_preds, predictions.avg_xent.dtype) if hasattr(predictions, 'avg_xent_weight'): avg_xent_weight = predictions.avg_xent_weight else: avg_xent_weight = metric_weight metrics = NestedMap( total_loss=(predictions.total_loss, metric_weight), avg_xent=(predictions.avg_xent, avg_xent_weight), aux_loss=(predictions.aux_loss, jnp.array(1.0, predictions.aux_loss.dtype)), log_pplx=(predictions.avg_xent, avg_xent_weight), fraction_of_correct_next_step_preds=(mean_acc, metric_weight), num_predictions=(num_preds, jnp.array(1.0, num_preds.dtype)), ) per_example_output = NestedMap() if return_predictions: per_example_output = predictions return metrics, per_example_output def greedy_decode(extend_step_fn: Callable[[NestedMap, JTensor], Tuple[NestedMap, JTensor]], decoder_state: NestedMap, target_ids: JTensor, target_paddings: JTensor, seq_len: int, max_decode_steps: Optional[int] = None, prefix_lengths: Optional[JTensor] = None, eos_id: Optional[int] = None) -> NestedMap: """Greedy decode the input batch. Args: extend_step_fn: A function that takes in `states` and the decoded sequence at the current time step (with shape [B] or [B, P] where B corresponds to the batch size and P corresponds to a possible prefix) and returns a tuple of (`NestedMap`, `JTensor`), where the first `NestedMap` corresponds to the `new_states` and the second `JTensor` corresponds to the logits of the next step. decoder_state: The initialized cache for autoregressive cached decoding. target_ids: The token ids that correspond to the target sequence. target_paddings: The paddings corresponding to the target sequence, with a 1 denoting padding token and 0 denoting non-padding tokens. seq_len: The output sequence length to decode to. max_decode_steps: Python int or None, the max decode step to run after the prefix (if any). Since the prefixes might be of unequal lengths, this value is not equivalent with `seq_len` above. When None, decode steps is only limited by `seq_len` above. prefix_lengths: Optional argument supplying a prefix sizes to initialize the model to decode from a certain target prefix for each position in the batch. This can either be None or a JTensor of shape [batch] signifying the prefix length for each sequence in the batch. eos_id: Optional EOS id which to terminate the decoding early. Returns: A NestedMap with `.prefix_lengths` (indicating the lengths of prefixes for each target sequence), `.output_ids` (matrix of int ids with the decoded output), `.decode_lengths` (vector of ints indicating the lengths of non-padding tokens in `.output_ids`, which includes the prefix), and `.logprobs` (the log probability of selected tokens, including the prefix, where a positive value of 1.0 is used to indicate padded positions). """ if seq_len <= 0: raise ValueError('The sequence length for decoding must be > 0, ' f'current value = {seq_len}.') max_decode_steps = max_decode_steps or seq_len batch_size = target_ids.shape[0] # If prefix length is not specified set it to 0. if prefix_lengths is None: prefix_lengths = jnp.zeros([batch_size], dtype=jnp.int32) output_ids = jnp.zeros(shape=(batch_size, seq_len), dtype=jnp.int32) output_ids = output_ids.at[:, 0].set(target_ids[:, 0]) val = NestedMap() val.state = decoder_state val.step = 0 val.output_ids = output_ids # Shape [batch_size], whether each row has terminated and should stop. val.done = jnp.zeros(shape=batch_size, dtype=jnp.bool_) val.decode_lengths = jnp.ones_like(prefix_lengths) * seq_len # We use a positive value of 1.0 to indicate blank or padded positions. val.logprobs = jnp.ones_like(output_ids, dtype=jnp.float32) def cond_func(val): """Whether the while loop should continue.""" # We continue the greedy search iff both: # (1) We have yet to exceed the max steps set by p.decoder.seqlen, AND; # (2) At least one row in the batch has not terminated. length_ok = val.step < seq_len - 1 all_rows_done = jnp.all(val.done) return jnp.logical_and(length_ok, jnp.logical_not(all_rows_done)) def loop_body(val): """From ids at `step`, update output ids at `step + 1`.""" step = val.step decoder_state, logits = extend_step_fn(val.state, val.output_ids[:, step]) logprobs = jax.nn.log_softmax(logits.astype(jnp.float32)) val.state = decoder_state # When step becomes prefix_length - 1, the new output has index beyond # the known prefix. # If prefix_length is 0, the condition is always False, so we take the # decoded output rather than the prefix. new_ids = jnp.where(step < prefix_lengths - 1, target_ids[:, step + 1], jnp.argmax(logits, axis=1)) prev_done = val.done new_ids = jnp.where(prev_done, jnp.zeros_like(new_ids), new_ids) if eos_id is not None: val.done = jnp.logical_or(prev_done, jnp.equal(new_ids, eos_id)) max_decoding_steps_reached = (jnp.ones_like(prefix_lengths) * (step + 2) - prefix_lengths) >= max_decode_steps val.done = jnp.logical_or(val.done, max_decoding_steps_reached) done_at_this_step = jnp.logical_and(jnp.logical_not(prev_done), val.done) val.decode_lengths = jnp.where( done_at_this_step, jnp.ones_like(val.decode_lengths) * (step + 2), val.decode_lengths) val.output_ids = val.output_ids.at[:, step + 1].set(new_ids) logprobs_at_new_ids = logprobs.at[jnp.arange(batch_size), new_ids].get() logprobs_at_new_ids = jnp.where(prev_done, jnp.ones_like(logprobs_at_new_ids), logprobs_at_new_ids) val.logprobs = val.logprobs.at[:, step + 1].set(logprobs_at_new_ids) val.step += 1 return val result = jax.lax.while_loop(cond_func, loop_body, val) result.prefix_lengths = prefix_lengths result.original_lengths = jnp.sum( 1.0 - target_paddings, axis=1).astype(jnp.int32) prefix_ids = target_ids # We manually pad out the ids not belonging to the prefix because some # tokenizers tested do not always obey the lengths arg. indices = jnp.tile(jnp.arange(prefix_ids.shape[1]), (prefix_ids.shape[0], 1)) prefix_lengths_2d = jnp.tile(prefix_lengths[:, None], (1, prefix_ids.shape[1])) prefix_ids = jnp.where(indices < prefix_lengths_2d, prefix_ids, jnp.zeros_like(prefix_ids)) result.prefix_ids = prefix_ids del result.state, result.step, result.done return result class BaseModel(base_layer.BaseLayer): """An API that every model should be derived from.""" def compute_predictions(self, input_batch: NestedMap) -> Predictions: """Computes predictions for `input_batch`. This method must be defined in a concrete derived class. The output can be in the form of probablistic distributions, e.g., softmax logits for discrete outputs, mixture of logistics for continuous values, or regression values. For training/evaluation, the output will be used for computing loss and gradient updates, including comparing predicted distributions between teacher and student for distillation. During inference the output can be used to compute final outputs, perhaps with sampling. Args: input_batch: A `.NestedMap` object containing input tensors. Returns: Predictions, either a single Tensor, a `.NestedMap`, or a namedtuple. """ raise NotImplementedError('Abstract method') def compute_loss(self, predictions: Union[JTensor, NestedMap], input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: """Computes the loss and other metrics for the given predictions. This method must be defined in a concrete derived class. Args: predictions: The output of `compute_predictions`. input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to corresponds to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. """ raise NotImplementedError('Abstract method') def fprop(self, input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: """Forward propagation through one tower of the model. Args: input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: (dict, dict): - A dict containing str keys and (metric, weight) pairs as values, where one of the keys is expected to be 'loss'. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. """ with py_utils.AuxLossContext(): predictions = self.compute_predictions(input_batch) return self.compute_loss(predictions, input_batch) def decode(self, input_batch: NestedMap) -> Tuple[NestedMap, NestedMap]: """Decodes input_batch. Args: input_batch: The input batch. A `NestedMap` of tensors. Or, if input batch spiltting is used, a list of `NestedMap`, one for each split. Returns: - metrics, a NestedMap containing str keys and (metric, weight) pairs for the current batch (a tuple of two scalars). - results, a `.NestedMap` as decoder output. """ raise NotImplementedError('Abstract method') def process_decode_out( self, input_obj: base_input.BaseInput, decode_out: NestedMap) -> Tuple[NestedMap, Sequence[Tuple[str, Any]]]: """Processes one batch of decoded outputs. Args: input_obj: The input object where a tokenizer is accessible. decode_out: The output from decode(). May have an extra leading axis. Returns: - metrics, a NestedMap containing str keys and (metric, weight) pairs for the current batch (a tuple of two scalars). - A list of tuples where each element corresponds to a row in the batch. Each tuple is a key value pair. """ raise NotImplementedError('Abstract method') class ClassificationMLPModel(BaseModel): """Language Model task with a simple MLP model.""" @classmethod def Params(cls) -> InstantiableParams: p = super().Params() p.Define('mlp_tpl', layers.linears.MLPBlock.Params(), 'MLP model parameters.') p.Define('softmax_tpl', layers.SingleShardSharedEmbeddingSoftmax.Params(), 'Input softmax embedding lookup layer.') return p def __init__(self, params: InstantiableParams) -> None: super().__init__(params) p = self.params self.create_children('mlp_layers', p.mlp_tpl.Copy()) self.create_child('softmax', p.softmax_tpl.Copy()) def compute_predictions(self, input_batch: NestedMap) -> Predictions: input_emb = self.softmax.emb_lookup(input_batch.ids) output = self.mlp_layers.fprop(input_emb) predictions = self.softmax.fprop( inputs=output, class_weights=input_batch.weights[:, :, jnp.newaxis], class_ids=input_batch.ids[:, :, jnp.newaxis]) return predictions def compute_loss(self, predictions: NestedMap, input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: labels = input_batch.labels weights = input_batch.weights class_weights = weights[:, :, jnp.newaxis] num_preds = jnp.sum(class_weights) predicted_labels = predictions.per_example_argmax.astype(labels.dtype) mean_acc = jnp.sum( (labels == predicted_labels) * weights) / jnp.maximum(num_preds, 1) metrics = NestedMap(total_loss=(mean_acc, mean_acc),) return metrics, NestedMap() class LanguageModel(BaseModel): """Language Model base task.""" @classmethod def Params(cls) -> InstantiableParams: p = super().Params() p.Define('lm', layers.TransformerLm.Params(), 'LM layer.') p.Define( 'return_predictions', False, 'Whether to return predictions during' 'eval. Returning predictions is more expensive, but may be useful' 'for debugging.') greedy_search_p = py_utils.Params() greedy_search_p.Define('seqlen', 0, 'Maximum output sequence length.') greedy_search_p.Define( 'min_prefix_len', 5, 'Minimum number of tokens picked to be used as decoding prefix.') greedy_search_p.Define( 'eos_id', 2, 'The id of EOS token indicating the termination of greedy search.') greedy_search_p.Define( 'max_decode_steps', None, 'If not None, the max decode steps for each example. If None, this ' 'is set to `seqlen`, which contains prefix.') p.Define('decoder', greedy_search_p, 'Decoder param.') return p def __init__(self, params: InstantiableParams) -> None: super().__init__(params) p = self.params # Construct the model. lm_p = p.lm.Copy() self.create_child('lm', lm_p) def compute_predictions(self, input_batch: NestedMap) -> Predictions: """Computes predictions for `input_batch`.""" p = self.params if 'tgt' in input_batch: input_batch = input_batch.tgt if 'paddings' in input_batch: paddings = input_batch.paddings else: paddings = jnp.equal(input_batch.segment_ids, 0).astype(self.fprop_dtype) if 'weights' in input_batch: weights = input_batch.weights else: weights = 1.0 - paddings weights = weights.astype(self.fprop_dtype) input_batch.weights = weights inputs = input_batch.ids labels = NestedMap(class_ids=input_batch.labels, class_weights=weights) if p.lm.packed_input: packed_input_kwargs = { 'segment_ids': input_batch.segment_ids, 'segment_pos': input_batch.segment_pos, } else: packed_input_kwargs = {} return self.lm.fprop( inputs=inputs, paddings=paddings, labels=labels, **packed_input_kwargs) def compute_loss(self, predictions: NestedMap, input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: """Computes the loss and other metrics for the given predictions. Args: predictions: The output of `compute_predictions`. input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to corresponds to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. """ return _compute_xent_loss_helper(predictions, input_batch, self.params.return_predictions) def decode(self, input_batch: NestedMap) -> Tuple[NestedMap, NestedMap]: """Greedy decodes the input_batch. Args: input_batch: The input batch, with fields like `.ids`. Returns: - metrics, a NestedMap containing str keys and (metrics, weight) pairs. - A NestedMap like `input_batch`, with `.prefix_lengths` (vector of randomly generated ints indicating the lengths of prefixes for each row), and `.output_ids` (matrix of int ids with the decoded output). """ p = self.params if p.decoder.seqlen <= 0: raise ValueError('Must set p.decoder.seqlen > 0, current value = ' f'{p.decoder.seqlen}') batch_size = input_batch.ids.shape[0] maxval = jnp.sum(1 - input_batch.paddings, axis=1).astype(jnp.int32) minval = jnp.minimum(maxval, p.decoder.min_prefix_len) prefix_lengths = jax.random.randint(base_layer.next_prng_key(), [batch_size], minval, maxval + 1, input_batch.ids.dtype) decoder_state = self.lm.init_states( target_batch_size=batch_size, target_max_length=p.decoder.seqlen) global_step = base_layer.cur_global_step() lm_theta = self.lm.local_theta() def extend_step_fn(states, ids): with base_layer.JaxContext.new_context( prng_key=base_layer.next_prng_key(), global_step=global_step) as jax_context: jax_context.bind(self.lm, self.lm.vars_to_flax_vars(lm_theta), [base_layer.SCOPE_AUX_LOSS]) new_states, xent = self.lm.extend_step(states, ids) return new_states, xent.logits result = greedy_decode( extend_step_fn, decoder_state, input_batch.ids, input_batch.paddings, p.decoder.seqlen, max_decode_steps=p.decoder.max_decode_steps, prefix_lengths=prefix_lengths, eos_id=p.decoder.eos_id) result.update(input_batch) metrics = NestedMap( num_decoded=(jnp.array(0.0, jnp.float32), jnp.array(batch_size, jnp.float32))) return metrics, result def process_decode_out( self, input_obj: base_input.BaseInput, decode_out: NestedMap) -> Tuple[NestedMap, Sequence[Tuple[str, Any]]]: """Processes one batch of decoded outputs. Args: input_obj: The input object where a tokenizer is accessible. decode_out: The output from decode(). May have an extra leading axis. Returns: - metrics, a NestedMap containing str keys and (metric, weight) pairs for the current batch (a tuple of two scalars). - A list of dict where each entry corresponds to a row in the batch. The keys should be unique across the entire decode dataset. """ decoded_strs = input_obj.ids_to_strings(decode_out.output_ids, decode_out.decode_lengths) original_strs = input_obj.ids_to_strings(decode_out.ids, decode_out.original_lengths) prefix_strs = input_obj.ids_to_strings(decode_out.prefix_ids, decode_out.prefix_lengths) ret = list() for idx, decoded_str in enumerate(decoded_strs): ret.append((prefix_strs[idx], { 'prefix': prefix_strs[idx], 'decoded': decoded_str, 'original': original_strs[idx], 'ids': decode_out.output_ids[idx], 'logprobs': decode_out.logprobs[idx], 'prefix_length': decode_out.prefix_lengths[idx], 'decode_length': decode_out.decode_lengths[idx], })) decoded_lengths = jnp.average(decode_out.decode_lengths).astype(jnp.float32) metrics = NestedMap( decoded_length=(decoded_lengths, jnp.array(1.0, jnp.float32))) return metrics, ret class SequenceModel(BaseModel): """Sequence Model base task.""" @classmethod def Params(cls) -> InstantiableParams: p = super().Params() p.Define('model', layers.TransformerEncoderDecoder.Params(), 'Sequence model layer for this task.') p.Define( 'return_predictions', False, 'Whether to return predictions during' 'eval. Returning predictions is more expensive, but may be useful' 'for debugging.') decoder_p = py_utils.Params() decoder_p.Define('seqlen', 0, 'Maximum output sequence length.') decoder_p.Define( 'eos_id', 2, 'The id of EOS token indicating the termination of decoding.') p.Define('decoder', decoder_p, 'Decoder params.') p.Define( 'label_smoothing_prob', 0.0, 'If > 0.0, smooth out one-hot prob by spreading this amount of' ' prob mass to all other tokens.') return p def __init__(self, params: InstantiableParams) -> None: super().__init__(params) p = self.params # Construct the model. model_p = p.model.Copy() self.create_child('model', model_p) def compute_predictions(self, input_batch): """Computes predictions for `input_batch`.""" p = self.params if p.model.packed_input: packed_input_kwargs = { 'input_segment_ids': input_batch.src.segment_ids, 'input_segment_pos': input_batch.src.segment_pos, 'target_segment_ids': input_batch.tgt.segment_ids, 'target_segment_pos': input_batch.tgt.segment_pos, } else: packed_input_kwargs = {} labels = NestedMap( class_ids=input_batch.tgt.labels, class_weights=input_batch.tgt.weights) if p.label_smoothing_prob > 0.0: vocab_size = p.model.softmax_tpl.num_classes class_probabilities = jax.nn.one_hot(labels.class_ids, vocab_size) fill_prob = p.label_smoothing_prob / (vocab_size - 1) class_probabilities = ( (1.0 - p.label_smoothing_prob) * class_probabilities + fill_prob * (1.0 - class_probabilities)).astype(self.fprop_dtype) labels.class_probabilities = class_probabilities return self.model.fprop( inputs=input_batch.src.ids, input_paddings=input_batch.src.paddings, targets=input_batch.tgt.ids, target_paddings=input_batch.tgt.paddings, labels=labels, **packed_input_kwargs) def compute_loss(self, predictions, input_batch): """Computes the loss and other metrics for the given predictions. Args: predictions: The output of `ComputePredictions`. input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to corresponds to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. """ return _compute_xent_loss_helper(predictions, input_batch.tgt, self.params.return_predictions) def decode(self, input_batch: NestedMap) -> Tuple[NestedMap, NestedMap]: """Decodes input_batch. Args: input_batch: The input batch, with a field `.src` and `.tgt` corresponding to source and target, which itself contains the `.ids` and `.paddings.` Returns: - metrics, a nestedmap of metrics. - results, a NestedMap like `input_batch`, with `.output_ids` (matrix of int ids with the decoded output) as well as the decoded length. """ p = self.params model_theta = self.model.local_theta() if p.decoder.seqlen <= 0: raise ValueError('Must set p.decoder.seqlen > 0, current value = ' f'{p.decoder.seqlen}') batch_size = input_batch.tgt.ids.shape[0] decoder_state = self.model.init_states( inputs=input_batch.src.ids, input_paddings=input_batch.src.paddings, target_batch_size=batch_size, target_max_length=p.decoder.seqlen) global_step = base_layer.cur_global_step() def extend_step_fn(states, ids): with base_layer.JaxContext.new_context( prng_key=base_layer.next_prng_key(), global_step=global_step) as jax_context: jax_context.bind(self.model, self.model.vars_to_flax_vars(model_theta), [base_layer.SCOPE_AUX_LOSS]) new_states, xent = self.model.extend_step(states, ids) return new_states, xent.logits result = greedy_decode( extend_step_fn, decoder_state, input_batch.tgt.ids, input_batch.tgt.paddings, p.decoder.seqlen, eos_id=p.decoder.eos_id) # Prefix lengths are not needed for sequence model decoding. del result.prefix_lengths result.update(input_batch) metrics = NestedMap( num_decoded=(jnp.array(0.0, jnp.float32), jnp.array(batch_size, jnp.float32))) return metrics, result def process_decode_out( self, input_obj: base_input.BaseInput, decode_out: NestedMap) -> Tuple[NestedMap, Sequence[Tuple[str, Any]]]: """Processes one batch of decoded outputs. Args: input_obj: The input object where a tokenizer is accessible. decode_out: The output from decode(). May have an extra leading axis. Returns: - metrics, a NestedMap containing str keys and (metric, weight) pairs for the current batch (a tuple of two scalars). - A list of dict where each entry corresponds to a row in the batch. The keys should be unique across the entire decode dataset. """ decoded_strs = input_obj.ids_to_strings( decode_out.output_ids, decode_out.decode_lengths, key='tgt') source_lengths = jnp.sum( 1.0 - decode_out.src.paddings, axis=1).astype(jnp.int32) source_strs = input_obj.ids_to_strings( decode_out.src.ids, source_lengths, key='src') target_strs = input_obj.ids_to_strings( decode_out.tgt.ids, decode_out.original_lengths, key='tgt') ret = list() for idx, decoded_str in enumerate(decoded_strs): ret.append((source_strs[idx], { 'source': source_strs[idx], 'decoded': decoded_str, 'target': target_strs[idx], 'ids': decode_out.output_ids[idx], 'logprobs': decode_out.logprobs[idx], 'decode_length': decode_out.decode_lengths[idx], })) decode_lengths = jnp.average(decode_out.decode_lengths).astype(jnp.float32) metrics = NestedMap( decode_length=(decode_lengths, jnp.array(1.0, jnp.float32))) return metrics, ret class ClassificationModel(BaseModel): """Classification task for images and video.""" @classmethod def Params(cls) -> InstantiableParams: p = super().Params() p.Define('network', layers.ResNet.Params(), 'The classifier network, which is ResNet-50 by default.') p.Define('softmax', layers.SingleShardFullSoftmax.Params(), 'The softmax layer used for the classification.') p.Define( 'input_field', 'image', 'The input field which contains the image or video features to' 'pass to the classification network.') return p def __init__(self, params: InstantiableParams) -> None: super().__init__(params) p = self.params self.create_child('network', p.network) self.create_child('softmax', p.softmax) def compute_predictions(self, input_batch: NestedMap) -> Predictions: """Computes predictions for `input_batch`. Args: input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A NestedMap containing str keys and features, softmax output and the class weights as values. """ p = self.params inputs = input_batch.Get(p.input_field) features = self.network.fprop(inputs) batch_size = inputs.shape[0] example_weights = jnp.ones([batch_size]) if 'weight' in input_batch: example_weights = input_batch.weight if example_weights.shape != (batch_size,): raise ValueError( f'Shape of example weights should be ({batch_size},), but instead' f'is {example_weights.shape}') # Softmax expects weights to be of shape [..., 1]. softmax_output = self.softmax.fprop( inputs=features, class_weights=example_weights[:, jnp.newaxis], class_probabilities=input_batch.label_probs) return NestedMap( features=features, softmax_output=softmax_output, example_weights=example_weights) def compute_loss(self, predictions: NestedMap, input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: """Computes the loss and other metrics for the given predictions. Args: predictions: The output of `compute_predictions`. input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to correspond to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. The base class just returns an empty dict. """ avg_xent = predictions.softmax_output.avg_xent total_weight = predictions.softmax_output.total_weight metrics = NestedMap( avg_xent=(avg_xent, total_weight), num_predictions=(total_weight, jnp.array(1.0, total_weight.dtype))) # Compute top-1 and top-5 accuracy and add summary. acc1 = metric_utils.top_k_accuracy( 1, predictions.softmax_output.logits, label_probs=input_batch.label_probs, weights=predictions.example_weights) acc5 = metric_utils.top_k_accuracy( 5, predictions.softmax_output.logits, label_probs=input_batch.label_probs, weights=predictions.example_weights) metrics.update( accuracy=(acc1, predictions.softmax_output.total_weight), acc5=(acc5, predictions.softmax_output.total_weight), error=(1.0 - acc1, predictions.softmax_output.total_weight), error5=(1.0 - acc5, predictions.softmax_output.total_weight)) # Add top-1 and top-5 accuracies to summaries. base_layer.add_summary('acc1', acc1) base_layer.add_summary('acc5', acc5) return metrics, {} class BertModel(BaseModel): """Bert Model base task.""" @classmethod def Params(cls) -> InstantiableParams: p = super().Params() p.Define('lm', layers.TransformerLm.Params(), 'Bert lm layer.') p.Define( 'label_smoothing_prob', 0.0, 'If > 0.0, smooth out one-hot prob by spreading this amount of' ' prob mass to all other tokens.') p.Define('mask_token_id', 0, 'Mask token id') return p def __init__(self, params: InstantiableParams) -> None: super().__init__(params) p = self.params assert p.lm.masked_lm assert p.lm.packed_input self.create_child('lm', p.lm) mlm_augment_p = layers.MaskedLmDataAugmenter.Params() mlm_augment_p.vocab_size = p.lm.vocab_size mlm_augment_p.mask_token_id = p.mask_token_id self.create_child('mlm_augmenter', mlm_augment_p) def compute_predictions(self, input_batch: NestedMap) -> Predictions: """Computes predictions for `input_batch`.""" p = self.params assert p.lm.packed_input segment_ids = input_batch.segment_ids segment_pos = input_batch.segment_pos paddings = input_batch.paddings # Note that internal BertTransformer uses input_batch.ids instead. labels = input_batch.labels if 'masked_ids' in input_batch: # Input data already has masking done. augmented_labels = input_batch.masked_ids augmented_pos = input_batch.masked_pos else: augmented_labels, augmented_pos = self.mlm_augmenter.fprop( labels, paddings) if p.label_smoothing_prob > 0.0: class_probabilities = jax.nn.one_hot(labels, p.lm.vocab_size) fill_prob = p.label_smoothing_prob / (p.lm.vocab_size - 1) class_probabilities = ( (1.0 - p.label_smoothing_prob) * class_probabilities + fill_prob * (1.0 - class_probabilities)).astype(self.fprop_dtype) # Only compute loss on masked pos. labels = NestedMap( class_probabilities=class_probabilities, class_weights=augmented_pos) else: # Only compute loss on masked pos. labels = NestedMap(class_ids=labels, class_weights=augmented_pos) lm_out = self.lm.fprop( inputs=augmented_labels, paddings=paddings, labels=labels, segment_ids=segment_ids, segment_pos=segment_pos) lm_out.augmented_labels = augmented_labels lm_out.augmented_pos = augmented_pos return lm_out def compute_loss(self, predictions: NestedMap, input_batch: NestedMap) -> Tuple[Metrics, Dict[str, Any]]: """Computes the loss and other metrics for the given predictions. Args: predictions: The output of `compute_predictions`. input_batch: A `.NestedMap` object containing input tensors to this tower. Returns: - A dict or NestedMap containing str keys and (metric, weight) pairs as values, where one of the entries is expected to corresponds to the loss. - A dict containing arbitrary tensors describing something about each training example, where the first dimension of each tensor is the batch index. """ labels = input_batch.labels num_tokens = jnp.sum(1.0 - input_batch.paddings.astype(jnp.float32)) num_seqs = jnp.sum( jnp.amax(input_batch.segment_ids.astype(jnp.float32), axis=1)) weights = predictions.augmented_pos.astype(jnp.float32) predicted_labels = predictions.per_example_argmax.astype(labels.dtype) num_preds = predictions.total_weight.astype(jnp.float32) mean_acc = jnp.sum( (labels == predicted_labels) * weights) / jnp.maximum(num_preds, 1) metric_weight = jnp.array(num_preds, predictions.avg_xent.dtype) metrics = py_utils.NestedMap( total_loss=(predictions.total_loss, metric_weight), avg_xent=(predictions.avg_xent, metric_weight), aux_loss=(predictions.aux_loss, metric_weight), log_pplx=(predictions.avg_xent, metric_weight), fraction_of_correct_preds=(mean_acc, jnp.array(num_preds, mean_acc.dtype)), num_predictions=(num_preds, jnp.array(1.0, num_preds.dtype)), num_tokens=(num_tokens, jnp.array(1.0, num_tokens.dtype)), num_seqs=(num_seqs, jnp.array(1.0, num_seqs.dtype)), ) per_example_output = py_utils.NestedMap() return metrics, per_example_output
tensorflow/lingvo
lingvo/jax/base_model.py
Python
apache-2.0
37,124
# # Copyright (c) 2008-2015 Citrix Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_resource from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_response from nssrc.com.citrix.netscaler.nitro.service.options import options from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception from nssrc.com.citrix.netscaler.nitro.util.nitro_util import nitro_util class auditmessages(base_resource) : """ Configuration for audit message resource. """ def __init__(self) : self._loglevel = [] self._numofmesgs = 0 self._value = "" self.___count = 0 @property def loglevel(self) : """Audit log level filter, which specifies the types of events to display. The following loglevels are valid: * ALL - All events. * EMERGENCY - Events that indicate an immediate crisis on the server. * ALERT - Events that might require action. * CRITICAL - Events that indicate an imminent server crisis. * ERROR - Events that indicate some type of error. * WARNING - Events that require action in the near future. * NOTICE - Events that the administrator should know about. * INFORMATIONAL - All but low-level events. * DEBUG - All events, in extreme detail.<br/>Possible values = ALL, EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL, DEBUG. """ try : return self._loglevel except Exception as e: raise e @loglevel.setter def loglevel(self, loglevel) : """Audit log level filter, which specifies the types of events to display. The following loglevels are valid: * ALL - All events. * EMERGENCY - Events that indicate an immediate crisis on the server. * ALERT - Events that might require action. * CRITICAL - Events that indicate an imminent server crisis. * ERROR - Events that indicate some type of error. * WARNING - Events that require action in the near future. * NOTICE - Events that the administrator should know about. * INFORMATIONAL - All but low-level events. * DEBUG - All events, in extreme detail.<br/>Possible values = ALL, EMERGENCY, ALERT, CRITICAL, ERROR, WARNING, NOTICE, INFORMATIONAL, DEBUG """ try : self._loglevel = loglevel except Exception as e: raise e @property def numofmesgs(self) : """Number of log messages to be displayed.<br/>Default value: 20<br/>Minimum length = 1<br/>Maximum length = 256. """ try : return self._numofmesgs except Exception as e: raise e @numofmesgs.setter def numofmesgs(self, numofmesgs) : """Number of log messages to be displayed.<br/>Default value: 20<br/>Minimum length = 1<br/>Maximum length = 256 """ try : self._numofmesgs = numofmesgs except Exception as e: raise e @property def value(self) : """The Audit message. """ try : return self._value except Exception as e: raise e def _get_nitro_response(self, service, response) : """ converts nitro response into object and returns the object array in case of get request. """ try : result = service.payload_formatter.string_to_resource(auditmessages_response, response, self.__class__.__name__) if(result.errorcode != 0) : if (result.errorcode == 444) : service.clear_session(self) if result.severity : if (result.severity == "ERROR") : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) else : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) return result.auditmessages except Exception as e : raise e def _get_object_name(self) : """ Returns the value of object identifier argument """ try : return None except Exception as e : raise e @classmethod def get(cls, client, name="", option_="") : """ Use this API to fetch all the auditmessages resources that are configured on netscaler. """ try : if not name : obj = auditmessages() response = obj.get_resources(client, option_) return response except Exception as e : raise e @classmethod def get_args(cls, client, args) : """ Use this API to fetch all the auditmessages resources that are configured on netscaler. # This uses auditmessages_args which is a way to provide additional arguments while fetching the resources. """ try : obj = auditmessages() option_ = options() option_.args = nitro_util.object_to_string_withoutquotes(args) response = obj.get_resources(client, option_) return response except Exception as e : raise e @classmethod def get_filtered(cls, client, filter_) : """ Use this API to fetch filtered set of auditmessages resources. filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = auditmessages() option_ = options() option_.filter = filter_ response = obj.getfiltered(client, option_) return response except Exception as e : raise e @classmethod def count(cls, client) : """ Use this API to count the auditmessages resources configured on NetScaler. """ try : obj = auditmessages() option_ = options() option_.count = True response = obj.get_resources(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e @classmethod def count_filtered(cls, client, filter_) : """ Use this API to count filtered the set of auditmessages resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = auditmessages() option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e class Loglevel: ALL = "ALL" EMERGENCY = "EMERGENCY" ALERT = "ALERT" CRITICAL = "CRITICAL" ERROR = "ERROR" WARNING = "WARNING" NOTICE = "NOTICE" INFORMATIONAL = "INFORMATIONAL" DEBUG = "DEBUG" class auditmessages_response(base_response) : def __init__(self, length=1) : self.auditmessages = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.auditmessages = [auditmessages() for _ in range(length)]
mahabs/nitro
nssrc/com/citrix/netscaler/nitro/resource/config/audit/auditmessages.py
Python
apache-2.0
6,791
# Copyright 2013 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from tempest.api.network import base from tempest.common.utils import net_utils from tempest import config from tempest.lib import decorators from tempest import test CONF = config.CONF class FloatingIPTestJSON(base.BaseNetworkTest): """Tests the following operations in the Neutron API: Create a Floating IP Update a Floating IP Delete a Floating IP List all Floating IPs Show Floating IP details Associate a Floating IP with a port and then delete that port Associate a Floating IP with a port and then with a port on another router v2.0 of the Neutron API is assumed. It is also assumed that the following options are defined in the [network] section of etc/tempest.conf: public_network_id which is the id for the external network present """ @classmethod def skip_checks(cls): super(FloatingIPTestJSON, cls).skip_checks() if not test.is_extension_enabled('router', 'network'): msg = "router extension not enabled." raise cls.skipException(msg) if not CONF.network.public_network_id: msg = "The public_network_id option must be specified." raise cls.skipException(msg) if not CONF.network_feature_enabled.floating_ips: raise cls.skipException("Floating ips are not available") @classmethod def resource_setup(cls): super(FloatingIPTestJSON, cls).resource_setup() cls.ext_net_id = CONF.network.public_network_id # Create network, subnet, router and add interface cls.network = cls.create_network() cls.subnet = cls.create_subnet(cls.network, enable_dhcp=False) cls.router = cls.create_router(external_network_id=cls.ext_net_id) cls.create_router_interface(cls.router['id'], cls.subnet['id']) # Create two ports one each for Creation and Updating of floatingIP for i in range(2): cls.create_port(cls.network) @decorators.attr(type='smoke') @decorators.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e8718') def test_create_list_show_update_delete_floating_ip(self): # Creates a floating IP body = self.floating_ips_client.create_floatingip( floating_network_id=self.ext_net_id, port_id=self.ports[0]['id']) created_floating_ip = body['floatingip'] self.addCleanup(self.floating_ips_client.delete_floatingip, created_floating_ip['id']) self.assertIsNotNone(created_floating_ip['id']) self.assertIsNotNone(created_floating_ip['tenant_id']) self.assertIsNotNone(created_floating_ip['floating_ip_address']) self.assertEqual(created_floating_ip['port_id'], self.ports[0]['id']) self.assertEqual(created_floating_ip['floating_network_id'], self.ext_net_id) self.assertIn(created_floating_ip['fixed_ip_address'], [ip['ip_address'] for ip in self.ports[0]['fixed_ips']]) # Verifies the details of a floating_ip floating_ip = self.floating_ips_client.show_floatingip( created_floating_ip['id']) shown_floating_ip = floating_ip['floatingip'] self.assertEqual(shown_floating_ip['id'], created_floating_ip['id']) self.assertEqual(shown_floating_ip['floating_network_id'], self.ext_net_id) self.assertEqual(shown_floating_ip['tenant_id'], created_floating_ip['tenant_id']) self.assertEqual(shown_floating_ip['floating_ip_address'], created_floating_ip['floating_ip_address']) self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id']) # Verify the floating ip exists in the list of all floating_ips floating_ips = self.floating_ips_client.list_floatingips() floatingip_id_list = list() for f in floating_ips['floatingips']: floatingip_id_list.append(f['id']) self.assertIn(created_floating_ip['id'], floatingip_id_list) # Associate floating IP to the other port floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], port_id=self.ports[1]['id']) updated_floating_ip = floating_ip['floatingip'] self.assertEqual(updated_floating_ip['port_id'], self.ports[1]['id']) self.assertEqual(updated_floating_ip['fixed_ip_address'], self.ports[1]['fixed_ips'][0]['ip_address']) self.assertEqual(updated_floating_ip['router_id'], self.router['id']) # Disassociate floating IP from the port floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], port_id=None) updated_floating_ip = floating_ip['floatingip'] self.assertIsNone(updated_floating_ip['port_id']) self.assertIsNone(updated_floating_ip['fixed_ip_address']) self.assertIsNone(updated_floating_ip['router_id']) @decorators.idempotent_id('e1f6bffd-442f-4668-b30e-df13f2705e77') def test_floating_ip_delete_port(self): # Create a floating IP body = self.floating_ips_client.create_floatingip( floating_network_id=self.ext_net_id) created_floating_ip = body['floatingip'] self.addCleanup(self.floating_ips_client.delete_floatingip, created_floating_ip['id']) # Create a port port = self.ports_client.create_port(network_id=self.network['id']) created_port = port['port'] floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], port_id=created_port['id']) # Delete port self.ports_client.delete_port(created_port['id']) # Verifies the details of the floating_ip floating_ip = self.floating_ips_client.show_floatingip( created_floating_ip['id']) shown_floating_ip = floating_ip['floatingip'] # Confirm the fields are back to None self.assertEqual(shown_floating_ip['id'], created_floating_ip['id']) self.assertIsNone(shown_floating_ip['port_id']) self.assertIsNone(shown_floating_ip['fixed_ip_address']) self.assertIsNone(shown_floating_ip['router_id']) @decorators.idempotent_id('1bb2f731-fe5a-4b8c-8409-799ade1bed4d') def test_floating_ip_update_different_router(self): # Associate a floating IP to a port on a router body = self.floating_ips_client.create_floatingip( floating_network_id=self.ext_net_id, port_id=self.ports[1]['id']) created_floating_ip = body['floatingip'] self.addCleanup(self.floating_ips_client.delete_floatingip, created_floating_ip['id']) self.assertEqual(created_floating_ip['router_id'], self.router['id']) network2 = self.create_network() subnet2 = self.create_subnet(network2) router2 = self.create_router(external_network_id=self.ext_net_id) self.create_router_interface(router2['id'], subnet2['id']) port_other_router = self.create_port(network2) # Associate floating IP to the other port on another router floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], port_id=port_other_router['id']) updated_floating_ip = floating_ip['floatingip'] self.assertEqual(updated_floating_ip['router_id'], router2['id']) self.assertEqual(updated_floating_ip['port_id'], port_other_router['id']) self.assertIsNotNone(updated_floating_ip['fixed_ip_address']) @decorators.attr(type='smoke') @decorators.idempotent_id('36de4bd0-f09c-43e3-a8e1-1decc1ffd3a5') def test_create_floating_ip_specifying_a_fixed_ip_address(self): body = self.floating_ips_client.create_floatingip( floating_network_id=self.ext_net_id, port_id=self.ports[1]['id'], fixed_ip_address=self.ports[1]['fixed_ips'][0]['ip_address']) created_floating_ip = body['floatingip'] self.addCleanup(self.floating_ips_client.delete_floatingip, created_floating_ip['id']) self.assertIsNotNone(created_floating_ip['id']) self.assertEqual(created_floating_ip['fixed_ip_address'], self.ports[1]['fixed_ips'][0]['ip_address']) floating_ip = self.floating_ips_client.update_floatingip( created_floating_ip['id'], port_id=None) self.assertIsNone(floating_ip['floatingip']['port_id']) @decorators.idempotent_id('45c4c683-ea97-41ef-9c51-5e9802f2f3d7') def test_create_update_floatingip_with_port_multiple_ip_address(self): # Find out ips that can be used for tests list_ips = net_utils.get_unused_ip_addresses( self.ports_client, self.subnets_client, self.subnet['network_id'], self.subnet['id'], 2) fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}] # Create port body = self.ports_client.create_port(network_id=self.network['id'], fixed_ips=fixed_ips) port = body['port'] self.addCleanup(self.ports_client.delete_port, port['id']) # Create floating ip body = self.floating_ips_client.create_floatingip( floating_network_id=self.ext_net_id, port_id=port['id'], fixed_ip_address=list_ips[0]) floating_ip = body['floatingip'] self.addCleanup(self.floating_ips_client.delete_floatingip, floating_ip['id']) self.assertIsNotNone(floating_ip['id']) self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0]) # Update floating ip body = self.floating_ips_client.update_floatingip( floating_ip['id'], port_id=port['id'], fixed_ip_address=list_ips[1]) update_floating_ip = body['floatingip'] self.assertEqual(update_floating_ip['fixed_ip_address'], list_ips[1])
vedujoshi/tempest
tempest/api/network/test_floating_ips.py
Python
apache-2.0
10,882
# coding=utf-8 # Copyright 2022 The Uncertainty Baselines Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # pylint: disable=line-too-long r"""ViT-B/16 finetuning on CIFAR. """ # pylint: enable=line-too-long import ml_collections # TODO(dusenberrymw): Open-source remaining imports. def get_sweep(hyper): # Below shows an example for how to sweep hyperparameters. # lr_grid = [1e-4, 3e-4, 6e-4, 1e-3, 1.3e-3, 1.6e-3, 2e-3] return hyper.product([ # hyper.sweep('config.lr.base', lr_grid), ]) def get_config(): """Config for training a patch-transformer on JFT.""" config = ml_collections.ConfigDict() # Fine-tuning dataset config.dataset = 'cifar100' config.val_split = 'train[98%:]' config.train_split = 'train[:98%]' config.num_classes = 100 BATCH_SIZE = 512 # pylint: disable=invalid-name config.batch_size = BATCH_SIZE config.total_steps = 10_000 INPUT_RES = 384 # pylint: disable=invalid-name pp_common = '|value_range(-1, 1)' # pp_common += f'|onehot({config.num_classes})' # To use ancestor 'smearing', use this line instead: pp_common += f'|onehot({config.num_classes}, key="label", key_result="labels")' # pylint: disable=line-too-long pp_common += '|keep(["image", "labels"])' config.pp_train = f'decode|inception_crop({INPUT_RES})|flip_lr' + pp_common config.pp_eval = f'decode|resize({INPUT_RES})' + pp_common # OOD eval # ood_split is the data split for both the ood_dataset and the dataset. config.ood_datasets = ['cifar10', 'svhn_cropped'] config.ood_num_classes = [10, 10] config.ood_split = 'test' config.ood_methods = ['msp', 'entropy', 'maha', 'rmaha'] pp_eval_ood = [] for num_classes in config.ood_num_classes: if num_classes > config.num_classes: # Note that evaluation_fn ignores the entries with all zero labels for # evaluation. When num_classes > n_cls, we should use onehot{num_classes}, # otherwise the labels that are greater than n_cls will be encoded with # all zeros and then be ignored. pp_eval_ood.append( config.pp_eval.replace(f'onehot({config.num_classes}', f'onehot({num_classes}')) else: pp_eval_ood.append(config.pp_eval) config.pp_eval_ood = pp_eval_ood config.shuffle_buffer_size = 50_000 # Per host, so small-ish is ok. config.log_training_steps = 10 config.log_eval_steps = 100 # NOTE: eval is very fast O(seconds) so it's fine to run it often. config.checkpoint_steps = 1000 config.checkpoint_timeout = 1 config.prefetch_to_device = 2 config.trial = 0 # Model section # pre-trained model ckpt file # !!! The below section should be modified per experiment config.model_init = '/path/to/pretrained_model_ckpt.npz' # Model definition to be copied from the pre-training config config.model = ml_collections.ConfigDict() config.model.patches = ml_collections.ConfigDict() config.model.patches.size = [16, 16] config.model.hidden_size = 768 config.model.transformer = ml_collections.ConfigDict() config.model.transformer.attention_dropout_rate = 0. config.model.transformer.dropout_rate = 0. config.model.transformer.mlp_dim = 3072 config.model.transformer.num_heads = 12 config.model.transformer.num_layers = 12 config.model.classifier = 'token' # Or 'gap' # This is "no head" fine-tuning, which we use by default config.model.representation_size = None # Optimizer section config.optim_name = 'Momentum' config.optim = ml_collections.ConfigDict() config.grad_clip_norm = 1.0 config.weight_decay = None # No explicit weight decay config.loss = 'softmax_xent' # or 'sigmoid_xent' config.lr = ml_collections.ConfigDict() config.lr.base = 0.002 config.lr.warmup_steps = 500 config.lr.decay_type = 'cosine' return config
google/uncertainty-baselines
baselines/jft/experiments/jft300m_vit_base16_finetune_cifar100.py
Python
apache-2.0
4,319
__all__ = ["Transition"] class Transition(object): def __init__(self, startState, nextState, word, suffix, marked): self.startState = startState self.nextState = nextState self.word = word self.suffix = suffix self.marked = False def similarTransitions(self, transitions): for transition in transitions: if (self.startState == transition.startState and self.nextState == transition.nextState): yield transition
otuncelli/turkish-stemmer-python
TurkishStemmer/transitions/__init__.py
Python
apache-2.0
516
# Copyright 2014 Huawei Technologies Co. Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Compass Appliance Mac module.""" from compass.hdsdiscovery import base from compass.utils import setting_wrapper as setting from compass.utils import util import logging CLASS_NAME = "Mac" class Mac(base.BaseSnmpMacPlugin): """Processes MAC address.""" def __init__(self, host, credential): self.host = host # self.credential = credential # return def scan(self): """Implemnets the scan method in BasePlugin class. .. note:: Dummy scan function for compass appliance. Returns fixed mac addresses. """ mac_list = None machine_lists = util.load_configs(setting.MACHINE_LIST_DIR) for items in machine_lists: for item in items['MACHINE_LIST']: for k, v in item.items(): if k == self.host: mac_list = v return mac_list
baigk/compass-core
compass/hdsdiscovery/vendors/appliance/plugins/mac.py
Python
apache-2.0
1,508
import os import time from collections import Counter from re import findall from unittest import skip from cassandra import ConsistencyLevel from ccmlib.common import is_win from ccmlib.node import Node from nose.plugins.attrib import attr from assertions import assert_almost_equal, assert_one from dtest import Tester, debug from tools import insert_c1c2, known_failure, since class TestIncRepair(Tester): def __init__(self, *args, **kwargs): kwargs['cluster_options'] = {'start_rpc': 'true'} # Ignore these log patterns: self.ignore_log_patterns = [ r'Can\'t send migration request: node.*is down', ] Tester.__init__(self, *args, **kwargs) def sstable_marking_test(self): """ * Launch a three node cluster * Stop node3 * Write 10K rows with stress * Start node3 * Issue an incremental repair, and wait for it to finish * Run sstablemetadata on every node, assert that all sstables are marked as repaired """ cluster = self.cluster # hinted handoff can create SSTable that we don't need after node3 restarted cluster.set_configuration_options(values={'hinted_handoff_enabled': False}) cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() node3.stop(gently=True) node1.stress(['write', 'n=10K', 'no-warmup', '-schema', 'replication(factor=3)']) node1.flush() node2.flush() node3.start(wait_other_notice=True) if node3.get_cassandra_version() < '2.2': log_file = 'system.log' else: log_file = 'debug.log' node3.watch_log_for("Initializing keyspace1.standard1", filename=log_file) # wait for things to settle before starting repair time.sleep(1) if cluster.version() >= "2.2": node3.repair() else: node3.nodetool("repair -par -inc") with open('sstables.txt', 'w') as f: node1.run_sstablemetadata(output_file=f, keyspace='keyspace1') node2.run_sstablemetadata(output_file=f, keyspace='keyspace1') node3.run_sstablemetadata(output_file=f, keyspace='keyspace1') with open("sstables.txt", 'r') as r: output = r.read().replace('\n', '') self.assertNotIn('Repaired at: 0', output) os.remove('sstables.txt') @known_failure(failure_source='test', jira_url='https://issues.apache.org/jira/browse/CASSANDRA-11268', flaky=True, notes='windows') def multiple_repair_test(self): """ * Launch a three node cluster * Create a keyspace with RF 3 and a table * Insert 49 rows * Stop node3 * Insert 50 more rows * Restart node3 * Issue an incremental repair on node3 * Stop node2 * Insert a final50 rows * Restart node2 * Issue an incremental repair on node2 * Replace node3 with a new node * Verify data integrity # TODO: Several more verifications of data need to be interspersed throughout the test. The final assertion is insufficient. @jira_ticket CASSANDRA-10644 """ cluster = self.cluster cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) self.create_cf(session, 'cf', read_repair=0.0, columns={'c1': 'text', 'c2': 'text'}) debug("insert data") insert_c1c2(session, keys=range(1, 50), consistency=ConsistencyLevel.ALL) node1.flush() debug("bringing down node 3") node3.flush() node3.stop(gently=False) debug("inserting additional data into node 1 and 2") insert_c1c2(session, keys=range(50, 100), consistency=ConsistencyLevel.TWO) node1.flush() node2.flush() debug("restarting and repairing node 3") node3.start(wait_for_binary_proto=True) if cluster.version() >= "2.2": node3.repair() else: node3.nodetool("repair -par -inc") # wait stream handlers to be closed on windows # after session is finished (See CASSANDRA-10644) if is_win: time.sleep(2) debug("stopping node 2") node2.stop(gently=False) debug("inserting data in nodes 1 and 3") insert_c1c2(session, keys=range(100, 150), consistency=ConsistencyLevel.TWO) node1.flush() node3.flush() debug("start and repair node 2") node2.start(wait_for_binary_proto=True) if cluster.version() >= "2.2": node2.repair() else: node2.nodetool("repair -par -inc") debug("replace node and check data integrity") node3.stop(gently=False) node5 = Node('node5', cluster, True, ('127.0.0.5', 9160), ('127.0.0.5', 7000), '7500', '0', None, ('127.0.0.5', 9042)) cluster.add(node5, False) node5.start(replace_address='127.0.0.3', wait_other_notice=True) assert_one(session, "SELECT COUNT(*) FROM ks.cf LIMIT 200", [149]) @known_failure(failure_source='test', jira_url='https://issues.apache.org/jira/browse/CASSANDRA-12006', flaky=True) def sstable_repairedset_test(self): """ * Launch a two node cluster * Insert data with stress * Stop node2 * Run sstablerepairedset against node2 * Start node2 * Run sstablemetadata on both nodes, pipe to a file * Verify the output of sstablemetadata shows no repairs have occurred * Stop node1 * Insert more data with stress * Start node1 * Issue an incremental repair * Run sstablemetadata on both nodes again, pipe to a new file * Verify repairs occurred and repairedAt was updated """ cluster = self.cluster cluster.set_configuration_options(values={'hinted_handoff_enabled': False}) cluster.populate(2).start() node1, node2 = cluster.nodelist() node1.stress(['write', 'n=10K', 'no-warmup', '-schema', 'replication(factor=2)', 'compaction(strategy=SizeTieredCompactionStrategy,enabled=false)', '-rate', 'threads=50']) node1.flush() node2.flush() node2.stop(gently=False) node2.run_sstablerepairedset(keyspace='keyspace1') node2.start(wait_for_binary_proto=True) with open('initial.txt', 'w') as f: node2.run_sstablemetadata(output_file=f, keyspace='keyspace1') node1.run_sstablemetadata(output_file=f, keyspace='keyspace1') with open('initial.txt', 'r') as r: initialoutput = r.read() matches = findall('(?<=Repaired at:).*', initialoutput) debug("Repair timestamps are: {}".format(matches)) uniquematches = set(matches) matchcount = Counter(matches) self.assertGreaterEqual(len(uniquematches), 2, uniquematches) self.assertGreaterEqual(max(matchcount), 1, matchcount) self.assertIn('Repaired at: 0', initialoutput) node1.stop() node2.stress(['write', 'n=15K', 'no-warmup', '-schema', 'replication(factor=2)']) node2.flush() node1.start(wait_for_binary_proto=True) if cluster.version() >= "2.2": node1.repair() else: node1.nodetool("repair -par -inc") with open('final.txt', 'w') as h: node1.run_sstablemetadata(output_file=h, keyspace='keyspace1') node2.run_sstablemetadata(output_file=h, keyspace='keyspace1') with open('final.txt', 'r') as r: finaloutput = r.read() matches = findall('(?<=Repaired at:).*', finaloutput) debug(matches) uniquematches = set(matches) matchcount = Counter(matches) self.assertGreaterEqual(len(uniquematches), 2) self.assertGreaterEqual(max(matchcount), 2) self.assertNotIn('Repaired at: 0', finaloutput) os.remove('initial.txt') os.remove('final.txt') def compaction_test(self): """ Test we can major compact after an incremental repair * Launch a three node cluster * Create a keyspace with RF 3 and a table * Stop node3 * Insert 100 rows * Restart node3 * Issue an incremental repair * Insert 50 more rows * Perform a major compaction on node3 * Verify all data is present # TODO: I have no idea what this is testing. The assertions do not verify anything meaningful. # TODO: Fix all the string formatting """ cluster = self.cluster cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() session = self.patient_cql_connection(node1) self.create_ks(session, 'ks', 3) session.execute("create table tab(key int PRIMARY KEY, val int);") node3.stop() for x in range(0, 100): session.execute("insert into tab(key,val) values(" + str(x) + ",0)") node1.flush() node3.start(wait_for_binary_proto=True) if cluster.version() >= "2.2": node3.repair() else: node3.nodetool("repair -par -inc") for x in range(0, 150): session.execute("insert into tab(key,val) values(" + str(x) + ",1)") cluster.flush() node3.nodetool('compact') for x in range(0, 150): assert_one(session, "select val from tab where key =" + str(x), [1]) @since("2.2") def multiple_full_repairs_lcs_test(self): """ @jira_ticket CASSANDRA-11172 - repeated full repairs should not cause infinite loop in getNextBackgroundTask """ cluster = self.cluster cluster.populate(2).start(wait_for_binary_proto=True) node1, node2 = cluster.nodelist() for x in xrange(0, 10): node1.stress(['write', 'n=100k', 'no-warmup', '-rate', 'threads=10', '-schema', 'compaction(strategy=LeveledCompactionStrategy,sstable_size_in_mb=10)', 'replication(factor=2)']) cluster.flush() cluster.wait_for_compactions() node1.nodetool("repair -full keyspace1 standard1") @attr('long') @skip('hangs CI') def multiple_subsequent_repair_test(self): """ @jira_ticket CASSANDRA-8366 There is an issue with subsequent inc repairs increasing load size. So we perform several repairs and check that the expected amount of data exists. * Launch a three node cluster * Write 5M rows with stress * Wait for minor compactions to finish * Issue an incremental repair on each node, sequentially * Issue major compactions on each node * Sleep for a while so load size can be propagated between nodes * Verify the correct amount of data is on each node """ cluster = self.cluster cluster.populate(3).start() node1, node2, node3 = cluster.nodelist() debug("Inserting data with stress") node1.stress(['write', 'n=5M', 'no-warmup', '-rate', 'threads=10', '-schema', 'replication(factor=3)']) debug("Flushing nodes") cluster.flush() debug("Waiting compactions to finish") cluster.wait_for_compactions() if self.cluster.version() >= '2.2': debug("Repairing node1") node1.nodetool("repair") debug("Repairing node2") node2.nodetool("repair") debug("Repairing node3") node3.nodetool("repair") else: debug("Repairing node1") node1.nodetool("repair -par -inc") debug("Repairing node2") node2.nodetool("repair -par -inc") debug("Repairing node3") node3.nodetool("repair -par -inc") # Using "print" instead of debug() here is on purpose. The compactions # take a long time and don't print anything by default, which can result # in the test being timed out after 20 minutes. These print statements # prevent it from being timed out. print "compacting node1" node1.compact() print "compacting node2" node2.compact() print "compacting node3" node3.compact() # wait some time to be sure the load size is propagated between nodes debug("Waiting for load size info to be propagated between nodes") time.sleep(45) load_size_in_kb = float(sum(map(lambda n: n.data_size(), [node1, node2, node3]))) load_size = load_size_in_kb / 1024 / 1024 debug("Total Load size: {}GB".format(load_size)) # There is still some overhead, but it's lot better. We tolerate 25%. expected_load_size = 4.5 # In GB assert_almost_equal(load_size, expected_load_size, error=0.25) def sstable_marking_test_not_intersecting_all_ranges(self): """ @jira_ticket CASSANDRA-10299 * Launch a four node cluster * Insert data with stress * Issue an incremental repair on each node sequentially * Assert no extra, unrepaired sstables are generated """ cluster = self.cluster cluster.populate(4).start(wait_for_binary_proto=True) node1, node2, node3, node4 = cluster.nodelist() debug("Inserting data with stress") node1.stress(['write', 'n=3', 'no-warmup', '-rate', 'threads=1', '-schema', 'replication(factor=3)']) debug("Flushing nodes") cluster.flush() repair_options = '' if self.cluster.version() >= '2.2' else '-inc -par' debug("Repairing node 1") node1.nodetool("repair {}".format(repair_options)) debug("Repairing node 2") node2.nodetool("repair {}".format(repair_options)) debug("Repairing node 3") node3.nodetool("repair {}".format(repair_options)) debug("Repairing node 4") node4.nodetool("repair {}".format(repair_options)) with open("final.txt", "w") as h: node1.run_sstablemetadata(output_file=h, keyspace='keyspace1') node2.run_sstablemetadata(output_file=h, keyspace='keyspace1') node3.run_sstablemetadata(output_file=h, keyspace='keyspace1') node4.run_sstablemetadata(output_file=h, keyspace='keyspace1') with open("final.txt", "r") as r: output = r.read() self.assertNotIn('Repaired at: 0', output) os.remove('final.txt')
thobbs/cassandra-dtest
repair_tests/incremental_repair_test.py
Python
apache-2.0
14,693
# -*- coding: utf-8 -*- """Test Request Module This module contains the tests for the OpenRecords `/request` endpoint. """ import pytest from app.models import Requests
CityOfNewYork/NYCOpenRecords
tests/functional/test_requests.py
Python
apache-2.0
170
import os, types, collections class EmptyLine(Exception) : """Raised when an empty or comment line is found (dealt with internally)""" def __init__(self, lineNumber) : message = "Empty line: #%d" % lineNumber Exception.__init__(self, message) self.message = message def __str__(self) : return self.message def removeDuplicates(inFileName, outFileName) : """removes duplicated lines from a 'inFileName' CSV file, the results are witten in 'outFileName'""" f = open(inFileName) legend = f.readline() data = '' h = {} h[legend] = 0 lines = f.readlines() for l in lines : if l not in h : h[l] = 0 data += l f.flush() f.close() f = open(outFileName, 'w') f.write(legend+data) f.flush() f.close() def catCSVs(folder, ouputFileName, removeDups = False) : """Concatenates all csv in 'folder' and wites the results in 'ouputFileName'. My not work on non Unix systems""" strCmd = r"""cat %s/*.csv > %s""" %(folder, ouputFileName) os.system(strCmd) if removeDups : removeDuplicates(ouputFileName, ouputFileName) def joinCSVs(csvFilePaths, column, ouputFileName, separator = ',') : """csvFilePaths should be an iterable. Joins all CSVs according to the values in the column 'column'. Write the results in a new file 'ouputFileName' """ res = '' legend = [] csvs = [] for f in csvFilePaths : c = CSVFile() c.parse(f) csvs.append(c) legend.append(separator.join(list(c.legend.keys()))) legend = separator.join(legend) lines = [] for i in range(len(csvs[0])) : val = csvs[0].get(i, column) line = separator.join(csvs[0][i]) for c in csvs[1:] : for j in range(len(c)) : if val == c.get(j, column) : line += separator + separator.join(c[j]) lines.append( line ) res = legend + '\n' + '\n'.join(lines) f = open(ouputFileName, 'w') f.write(res) f.flush() f.close() return res class CSVEntry(object) : """A single entry in a CSV file""" def __init__(self, csvFile, lineNumber = None) : self.csvFile = csvFile self.data = [] if lineNumber != None : self.lineNumber = lineNumber tmpL = csvFile.lines[lineNumber].replace('\r', '\n').replace('\n', '') if len(tmpL) == 0 or tmpL[0] in ["#", "\r", "\n", csvFile.lineSeparator] : raise EmptyLine(lineNumber) tmpData = tmpL.split(csvFile.separator) # tmpDatum = [] i = 0 while i < len(tmpData) : # for d in tmpData : d = tmpData[i] sd = d.strip() if len(sd) > 0 and sd[0] == csvFile.stringSeparator : more = [] for i in range(i, len(tmpData)) : more.append(tmpData[i]) i+=1 if more[-1][-1] == csvFile.stringSeparator : break self.data.append(",".join(more)[1:-1]) # if len(tmpDatum) > 0 or (len(sd) > 0 and sd[0] == csvFile.stringSeparator) : # tmpDatum.append(sd) # if len(sd) > 0 and sd[-1] == csvFile.stringSeparator : # self.data.append(csvFile.separator.join(tmpDatum)) # tmpDatum = [] else : self.data.append(sd) i += 1 else : self.lineNumber = len(csvFile) for i in range(len(self.csvFile.legend)) : self.data.append('') def commit(self) : """commits the line so it is added to a file stream""" self.csvFile.commitLine(self) def __iter__(self) : self.currentField = -1 return self def __next__(self) : self.currentField += 1 if self.currentField >= len(self.csvFile.legend) : raise StopIteration k = list(self.csvFile.legend.keys())[self.currentField] v = self.data[self.currentField] return k, v def __getitem__(self, key) : """Returns the value of field 'key'""" try : indice = self.csvFile.legend[key.lower()] except KeyError : raise KeyError("CSV File has no column: '%s'" % key) return self.data[indice] def __setitem__(self, key, value) : """Sets the value of field 'key' to 'value' """ try : field = self.csvFile.legend[key.lower()] except KeyError : self.csvFile.addField(key) field = self.csvFile.legend[key.lower()] self.data.append(str(value)) else : try: self.data[field] = str(value) except Exception as e: for i in range(field-len(self.data)+1) : self.data.append("") self.data[field] = str(value) def toStr(self) : return self.csvFile.separator.join(self.data) def __repr__(self) : r = {} for k, v in self.csvFile.legend.items() : r[k] = self.data[v] return "<line %d: %s>" %(self.lineNumber, str(r)) def __str__(self) : return repr(self) class CSVFile(object) : """ Represents a whole CSV file:: #reading f = CSVFile() f.parse('hop.csv') for line in f : print(line['ref']) #writing, legend can either be a list of a dict {field : column number} f = CSVFile(legend = ['name', 'email']) l = f.newLine() l['name'] = 'toto' l['email'] = "hop@gmail.com" for field, value in l : print(field, value) f.save('myCSV.csv') """ def __init__(self, legend = [], separator = ',', lineSeparator = '\n') : self.legend = collections.OrderedDict() for i in range(len(legend)) : if legend[i].lower() in self.legend : raise ValueError("%s is already in the legend" % legend[i].lower()) self.legend[legend[i].lower()] = i self.strLegend = separator.join(legend) self.filename = "" self.lines = [] self.separator = separator self.lineSeparator = lineSeparator self.currentPos = -1 self.streamFile = None self.writeRate = None self.streamBuffer = None self.keepInMemory = True def addField(self, field) : """add a filed to the legend""" if field.lower() in self.legend : raise ValueError("%s is already in the legend" % field.lower()) self.legend[field.lower()] = len(self.legend) if len(self.strLegend) > 0 : self.strLegend += self.separator + field else : self.strLegend += field def parse(self, filePath, skipLines=0, separator = ',', stringSeparator = '"', lineSeparator = '\n') : """Loads a CSV file""" self.filename = filePath f = open(filePath) if lineSeparator == '\n' : lines = f.readlines() else : lines = f.read().split(lineSeparator) f.flush() f.close() lines = lines[skipLines:] self.lines = [] self.comments = [] for l in lines : if len(l) != 0 and l[0] != "#" : self.lines.append(l) elif l[0] == "#" : self.comments.append(l) self.separator = separator self.lineSeparator = lineSeparator self.stringSeparator = stringSeparator self.legend = collections.OrderedDict() i = 0 for c in self.lines[0].lower().replace(stringSeparator, '').split(separator) : legendElement = c.strip() if legendElement not in self.legend : self.legend[legendElement] = i i+=1 self.strLegend = self.lines[0].replace('\r', '\n').replace('\n', '') self.lines = self.lines[1:] # sk = skipLines+1 # for l in self.lines : # if l[0] == "#" : # sk += 1 # else : # break # self.header = self.lines[:sk] # self.lines = self.lines[sk:] def streamToFile(self, filename, keepInMemory = False, writeRate = 1) : """Starts a stream to a file. Every line must be committed (l.commit()) to be appended in to the file. If keepInMemory is set to True, the parser will keep a version of the whole CSV in memory, writeRate is the number of lines that must be committed before an automatic save is triggered. """ if len(self.legend) < 1 : raise ValueError("There's no legend defined") try : os.remove(filename) except : pass self.streamFile = open(filename, "a") self.writeRate = writeRate self.streamBuffer = [] self.keepInMemory = keepInMemory self.streamFile.write(self.strLegend + "\n") def commitLine(self, line) : """Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") self.streamBuffer.append(line) if len(self.streamBuffer) % self.writeRate == 0 : for i in range(len(self.streamBuffer)) : self.streamBuffer[i] = str(self.streamBuffer[i]) self.streamFile.write("%s\n" % ('\n'.join(self.streamBuffer))) self.streamFile.flush() self.streamBuffer = [] def closeStreamToFile(self) : """Appends the remaining commited lines and closes the stream. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") for i in range(len(self.streamBuffer)) : self.streamBuffer[i] = str(self.streamBuffer[i]) self.streamFile.write('\n'.join(self.streamBuffer)) self.streamFile.close() self.streamFile = None self.writeRate = None self.streamBuffer = None self.keepInMemory = True def _developLine(self, line) : stop = False while not stop : try : if self.lines[line].__class__ is not CSVEntry : devL = CSVEntry(self, line) stop = True else : devL = self.lines[line] stop = True except EmptyLine as e : del(self.lines[line]) self.lines[line] = devL def get(self, line, key) : self._developLine(line) return self.lines[line][key] def set(self, line, key, val) : self._developLine(line) self.lines[line][key] = val def newLine(self) : """Appends an empty line at the end of the CSV and returns it""" l = CSVEntry(self) if self.keepInMemory : self.lines.append(l) return l def insertLine(self, i) : """Inserts an empty line at position i and returns it""" self.data.insert(i, CSVEntry(self)) return self.lines[i] def save(self, filePath) : """save the CSV to a file""" self.filename = filePath f = open(filePath, 'w') f.write(self.toStr()) f.flush() f.close() def toStr(self) : """returns a string version of the CSV""" s = [self.strLegend] for l in self.lines : s.append(l.toStr()) return self.lineSeparator.join(s) def __iter__(self) : self.currentPos = -1 return self def __next__(self) : self.currentPos += 1 if self.currentPos >= len(self) : raise StopIteration self._developLine(self.currentPos) return self.lines[self.currentPos] def __getitem__(self, line) : try : if self.lines[line].__class__ is not CSVEntry : self._developLine(line) except AttributeError : start = line.start if start is None : start = 0 for l in range(len(self.lines[line])) : self._developLine(l + start) # start, stop = line.start, line.stop # if start is None : # start = 0 # if stop is None : # stop = 0 # for l in xrange(start, stop) : # self._developLine(l) return self.lines[line] def __len__(self) : return len(self.lines)
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
Python
apache-2.0
10,715
# # Copyright (c) 2008-2015 Citrix Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License") # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_resource from nssrc.com.citrix.netscaler.nitro.resource.base.base_resource import base_response from nssrc.com.citrix.netscaler.nitro.service.options import options from nssrc.com.citrix.netscaler.nitro.exception.nitro_exception import nitro_exception from nssrc.com.citrix.netscaler.nitro.util.nitro_util import nitro_util class appflowcollector(base_resource) : """ Configuration for AppFlow collector resource. """ def __init__(self) : self._name = "" self._ipaddress = "" self._port = 0 self._netprofile = "" self._newname = "" self.___count = 0 @property def name(self) : """Name for the collector. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. Only four collectors can be configured. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my appflow collector" or 'my appflow collector').<br/>Minimum length = 1<br/>Maximum length = 127. """ try : return self._name except Exception as e: raise e @name.setter def name(self, name) : """Name for the collector. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at (@), equals (=), and hyphen (-) characters. Only four collectors can be configured. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my appflow collector" or 'my appflow collector').<br/>Minimum length = 1<br/>Maximum length = 127 """ try : self._name = name except Exception as e: raise e @property def ipaddress(self) : """IPv4 address of the collector. """ try : return self._ipaddress except Exception as e: raise e @ipaddress.setter def ipaddress(self, ipaddress) : """IPv4 address of the collector. """ try : self._ipaddress = ipaddress except Exception as e: raise e @property def port(self) : """UDP port on which the collector listens.<br/>Default value: 4739. """ try : return self._port except Exception as e: raise e @port.setter def port(self, port) : """UDP port on which the collector listens.<br/>Default value: 4739 """ try : self._port = port except Exception as e: raise e @property def netprofile(self) : """Netprofile to associate with the collector. The IP address defined in the profile is used as the source IP address for AppFlow traffic for this collector. If you do not set this parameter, the NetScaler IP (NSIP) address is used as the source IP address.<br/>Maximum length = 128. """ try : return self._netprofile except Exception as e: raise e @netprofile.setter def netprofile(self, netprofile) : """Netprofile to associate with the collector. The IP address defined in the profile is used as the source IP address for AppFlow traffic for this collector. If you do not set this parameter, the NetScaler IP (NSIP) address is used as the source IP address.<br/>Maximum length = 128 """ try : self._netprofile = netprofile except Exception as e: raise e @property def newname(self) : """New name for the collector. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at(@), equals (=), and hyphen (-) characters. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my appflow coll" or 'my appflow coll').<br/>Minimum length = 1. """ try : return self._newname except Exception as e: raise e @newname.setter def newname(self, newname) : """New name for the collector. Must begin with an ASCII alphabetic or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at(@), equals (=), and hyphen (-) characters. The following requirement applies only to the NetScaler CLI: If the name includes one or more spaces, enclose the name in double or single quotation marks (for example, "my appflow coll" or 'my appflow coll').<br/>Minimum length = 1 """ try : self._newname = newname except Exception as e: raise e def _get_nitro_response(self, service, response) : """ converts nitro response into object and returns the object array in case of get request. """ try : result = service.payload_formatter.string_to_resource(appflowcollector_response, response, self.__class__.__name__) if(result.errorcode != 0) : if (result.errorcode == 444) : service.clear_session(self) if result.severity : if (result.severity == "ERROR") : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) else : raise nitro_exception(result.errorcode, str(result.message), str(result.severity)) return result.appflowcollector except Exception as e : raise e def _get_object_name(self) : """ Returns the value of object identifier argument """ try : if (self.name) : return str(self.name) return None except Exception as e : raise e @classmethod def add(cls, client, resource) : """ Use this API to add appflowcollector. """ try : if type(resource) is not list : addresource = appflowcollector() addresource.name = resource.name addresource.ipaddress = resource.ipaddress addresource.port = resource.port addresource.netprofile = resource.netprofile return addresource.add_resource(client) else : if (resource and len(resource) > 0) : addresources = [ appflowcollector() for _ in range(len(resource))] for i in range(len(resource)) : addresources[i].name = resource[i].name addresources[i].ipaddress = resource[i].ipaddress addresources[i].port = resource[i].port addresources[i].netprofile = resource[i].netprofile result = cls.add_bulk_request(client, addresources) return result except Exception as e : raise e @classmethod def delete(cls, client, resource) : """ Use this API to delete appflowcollector. """ try : if type(resource) is not list : deleteresource = appflowcollector() if type(resource) != type(deleteresource): deleteresource.name = resource else : deleteresource.name = resource.name return deleteresource.delete_resource(client) else : if type(resource[0]) != cls : if (resource and len(resource) > 0) : deleteresources = [ appflowcollector() for _ in range(len(resource))] for i in range(len(resource)) : deleteresources[i].name = resource[i] else : if (resource and len(resource) > 0) : deleteresources = [ appflowcollector() for _ in range(len(resource))] for i in range(len(resource)) : deleteresources[i].name = resource[i].name result = cls.delete_bulk_request(client, deleteresources) return result except Exception as e : raise e @classmethod def rename(cls, client, resource, new_name) : """ Use this API to rename a appflowcollector resource. """ try : renameresource = appflowcollector() if type(resource) == cls : renameresource.name = resource.name else : renameresource.name = resource return renameresource.rename_resource(client,new_name) except Exception as e : raise e @classmethod def get(cls, client, name="", option_="") : """ Use this API to fetch all the appflowcollector resources that are configured on netscaler. """ try : if not name : obj = appflowcollector() response = obj.get_resources(client, option_) else : if type(name) != cls : if type(name) is not list : obj = appflowcollector() obj.name = name response = obj.get_resource(client, option_) else : if name and len(name) > 0 : response = [appflowcollector() for _ in range(len(name))] obj = [appflowcollector() for _ in range(len(name))] for i in range(len(name)) : obj[i] = appflowcollector() obj[i].name = name[i] response[i] = obj[i].get_resource(client, option_) return response except Exception as e : raise e @classmethod def get_filtered(cls, client, filter_) : """ Use this API to fetch filtered set of appflowcollector resources. filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = appflowcollector() option_ = options() option_.filter = filter_ response = obj.getfiltered(client, option_) return response except Exception as e : raise e @classmethod def count(cls, client) : """ Use this API to count the appflowcollector resources configured on NetScaler. """ try : obj = appflowcollector() option_ = options() option_.count = True response = obj.get_resources(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e @classmethod def count_filtered(cls, client, filter_) : """ Use this API to count filtered the set of appflowcollector resources. Filter string should be in JSON format.eg: "port:80,servicetype:HTTP". """ try : obj = appflowcollector() option_ = options() option_.count = True option_.filter = filter_ response = obj.getfiltered(client, option_) if response : return response[0].__dict__['___count'] return 0 except Exception as e : raise e class appflowcollector_response(base_response) : def __init__(self, length=1) : self.appflowcollector = [] self.errorcode = 0 self.message = "" self.severity = "" self.sessionid = "" self.appflowcollector = [appflowcollector() for _ in range(length)]
mahabs/nitro
nssrc/com/citrix/netscaler/nitro/resource/config/appflow/appflowcollector.py
Python
apache-2.0
10,726
# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from unittest import mock from heat.common import exception from heat.common import service_utils from heat.engine import stack_lock from heat.objects import stack as stack_object from heat.objects import stack_lock as stack_lock_object from heat.tests import common from heat.tests import utils class StackLockTest(common.HeatTestCase): def setUp(self): super(StackLockTest, self).setUp() self.context = utils.dummy_context() self.stack_id = "aae01f2d-52ae-47ac-8a0d-3fde3d220fea" self.engine_id = service_utils.generate_engine_id() stack = mock.MagicMock() stack.id = self.stack_id stack.name = "test_stack" stack.action = "CREATE" self.mock_get_by_id = self.patchobject( stack_object.Stack, 'get_by_id', return_value=stack) class TestThreadLockException(Exception): pass def test_successful_acquire_new_lock(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) slock.acquire() mock_create.assert_called_once_with( self.context, self.stack_id, self.engine_id) def test_failed_acquire_existing_lock_current_engine(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value=self.engine_id) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.assertRaises(exception.ActionInProgress, slock.acquire) self.mock_get_by_id.assert_called_once_with( self.context, self.stack_id, show_deleted=True, eager_load=False) mock_create.assert_called_once_with( self.context, self.stack_id, self.engine_id) def test_successful_acquire_existing_lock_engine_dead(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value='fake-engine-id') mock_steal = self.patchobject(stack_lock_object.StackLock, 'steal', return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.patchobject(service_utils, 'engine_alive', return_value=False) slock.acquire() mock_create.assert_called_once_with( self.context, self.stack_id, self.engine_id) mock_steal.assert_called_once_with( self.context, self.stack_id, 'fake-engine-id', self.engine_id) def test_failed_acquire_existing_lock_engine_alive(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value='fake-engine-id') slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.patchobject(service_utils, 'engine_alive', return_value=True) self.assertRaises(exception.ActionInProgress, slock.acquire) self.mock_get_by_id.assert_called_once_with( self.context, self.stack_id, show_deleted=True, eager_load=False) mock_create.assert_called_once_with( self.context, self.stack_id, self.engine_id) def test_failed_acquire_existing_lock_engine_dead(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value='fake-engine-id') mock_steal = self.patchobject(stack_lock_object.StackLock, 'steal', return_value='fake-engine-id2') slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.patchobject(service_utils, 'engine_alive', return_value=False) self.assertRaises(exception.ActionInProgress, slock.acquire) self.mock_get_by_id.assert_called_once_with( self.context, self.stack_id, show_deleted=True, eager_load=False) mock_create.assert_called_once_with( self.context, self.stack_id, self.engine_id) mock_steal.assert_called_once_with( self.context, self.stack_id, 'fake-engine-id', self.engine_id) def test_successful_acquire_with_retry(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value='fake-engine-id') mock_steal = self.patchobject(stack_lock_object.StackLock, 'steal', side_effect=[True, None]) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.patchobject(service_utils, 'engine_alive', return_value=False) slock.acquire() mock_create.assert_has_calls( [mock.call(self.context, self.stack_id, self.engine_id)] * 2) mock_steal.assert_has_calls( [mock.call(self.context, self.stack_id, 'fake-engine-id', self.engine_id)] * 2) def test_failed_acquire_one_retry_only(self): mock_create = self.patchobject(stack_lock_object.StackLock, 'create', return_value='fake-engine-id') mock_steal = self.patchobject(stack_lock_object.StackLock, 'steal', return_value=True) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) self.patchobject(service_utils, 'engine_alive', return_value=False) self.assertRaises(exception.ActionInProgress, slock.acquire) self.mock_get_by_id.assert_called_with( self.context, self.stack_id, show_deleted=True, eager_load=False) mock_create.assert_has_calls( [mock.call(self.context, self.stack_id, self.engine_id)] * 2) mock_steal.assert_has_calls( [mock.call(self.context, self.stack_id, 'fake-engine-id', self.engine_id)] * 2) def test_context_mgr_exception(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) def check_lock(): with slock: self.assertEqual(1, stack_lock_object.StackLock.create.call_count) raise self.TestThreadLockException self.assertRaises(self.TestThreadLockException, check_lock) self.assertEqual(1, stack_lock_object.StackLock.release.call_count) def test_context_mgr_noexception(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) with slock: self.assertEqual(1, stack_lock_object.StackLock.create.call_count) self.assertEqual(1, stack_lock_object.StackLock.release.call_count) def test_thread_lock_context_mgr_exception_acquire_success(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) def check_thread_lock(): with slock.thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) raise self.TestThreadLockException self.assertRaises(self.TestThreadLockException, check_thread_lock) self.assertEqual(1, stack_lock_object.StackLock.release.call_count) def test_thread_lock_context_mgr_exception_acquire_fail(self): stack_lock_object.StackLock.create = mock.Mock( return_value=self.engine_id) stack_lock_object.StackLock.release = mock.Mock() slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) def check_thread_lock(): with slock.thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) raise exception.ActionInProgress self.assertRaises(exception.ActionInProgress, check_thread_lock) self.assertFalse(stack_lock_object.StackLock.release.called) def test_thread_lock_context_mgr_no_exception(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) with slock.thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) self.assertFalse(stack_lock_object.StackLock.release.called) def test_try_thread_lock_context_mgr_exception(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) def check_thread_lock(): with slock.try_thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) raise self.TestThreadLockException self.assertRaises(self.TestThreadLockException, check_thread_lock) self.assertEqual(1, stack_lock_object.StackLock.release.call_count) def test_try_thread_lock_context_mgr_no_exception(self): stack_lock_object.StackLock.create = mock.Mock(return_value=None) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) with slock.try_thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) self.assertFalse(stack_lock_object.StackLock.release.called) def test_try_thread_lock_context_mgr_existing_lock(self): stack_lock_object.StackLock.create = mock.Mock(return_value=1234) stack_lock_object.StackLock.release = mock.Mock(return_value=None) slock = stack_lock.StackLock(self.context, self.stack_id, self.engine_id) def check_thread_lock(): with slock.try_thread_lock(): self.assertEqual(1, stack_lock_object.StackLock.create.call_count) raise self.TestThreadLockException self.assertRaises(self.TestThreadLockException, check_thread_lock) self.assertFalse(stack_lock_object.StackLock.release.called)
openstack/heat
heat/tests/test_stack_lock.py
Python
apache-2.0
12,477
import sys def dictContains(D, key): if sys.version_info[0] == 2: return D.has_key(key) elif sys.version_info[0] == 3: return key in D else: raise Exception("No support for self.__dictContains for python major " + "version: {}".format(sys.version_info[0]))
Quva/sparkplug
sparkplug/helpers/helpers.py
Python
apache-2.0
339
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== r"""Benchmarks for low-level eager execution primitives. To run CPU benchmarks: bazel run -c opt benchmarks_test -- --benchmarks=. To run GPU benchmarks: bazel run --config=cuda -c opt --copt="-mavx" benchmarks_test -- \ --benchmarks=. To run a subset of benchmarks using --benchmarks flag. --benchmarks: the list of benchmarks to run. The specified value is interpreted as a regular expression and any benchmark whose name contains a partial match to the regular expression is executed. e.g. --benchmarks=".*matmul*." will run all matmul related benchmarks. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import time import numpy as np import six from six.moves import xrange # pylint: disable=redefined-builtin from tensorflow.python import pywrap_tfe from tensorflow.python.eager import backprop # pylint: disable=unused-import from tensorflow.python.eager import benchmarks_test_base from tensorflow.python.eager import context from tensorflow.python.eager import core from tensorflow.python.eager import def_function from tensorflow.python.eager import forwardprop from tensorflow.python.eager import function from tensorflow.python.eager import test from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import tensor_spec from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import functional_ops from tensorflow.python.ops import gen_array_ops from tensorflow.python.ops import gen_math_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import resource_variable_ops from tensorflow.python.util import nest from tensorflow.python.util import tf_inspect CPU = "/device:CPU:0" GPU = "/device:GPU:0" GLOBAL_TEST_VALUE = None def c_tfe_py_fastpath_execute(a, b, transpose_a=False, transpose_b=False, name=None): ctx = context.context() assert ctx.executing_eagerly( ), "The prototype doesn't contain C code for graph construction" try: return pywrap_tfe.TFE_Py_FastPathExecute(ctx, "MatMul", name, a, b, "transpose_a", transpose_a, "transpose_b", transpose_b) except core._NotOkStatusException as e: if name is not None: message = e.message + " name: " + name else: message = e.message six.raise_from(core._status_to_exception(e.code, message), None) def run_benchmark(func, num_iters, execution_mode=None): ctx = context.context() with context.execution_mode(execution_mode): # call func to warm up func() if execution_mode == context.ASYNC: ctx.executor.wait() start = time.time() for _ in xrange(num_iters): func() if execution_mode == context.ASYNC: ctx.executor.wait() end = time.time() return end - start class MicroBenchmarks(benchmarks_test_base.MicroBenchmarksBase): def __init__(self): # used for multiply benchmarks self._m_2 = random_ops.random_uniform([2]) # used for matmul benchmarks self._m_2_by_2 = random_ops.random_uniform((2, 2)) self._m_100_by_784 = random_ops.random_uniform((100, 784)) self._num_iters_2_by_2 = 30000 self._num_iters_100_by_784 = 30000 # used for conv2d benchmarks self._m_8_28_28_3 = random_ops.random_uniform((8, 28, 28, 3)) self._m_1_3_3_1 = random_ops.random_uniform((1, 3, 3, 1)) def _get_benchmark_name(self): """Mostly copied from benchmark.py _get_name().""" stack = tf_inspect.stack() name = None for frame in stack[::-1]: f_locals = frame[0].f_locals f_self = f_locals.get("self", None) if isinstance(f_self, test.Benchmark): name = frame[3] # Get the method name # This is a hack to get around the fact that some methods might have a # disable_tfrt decorator around them. In that case a function called # 'decorated' wraps the real called function underneath and so we # peek one deeper into the stack to get the real name. if name == "decorated": continue else: break if name is None: raise ValueError("Unable to determine calling Benchmark function.") if context.is_tfrt_enabled(): name = name + "_tfrt" return name def _run(self, func, num_iters, execution_mode=None): self.run_report(run_benchmark, func, num_iters, execution_mode) def benchmark_create_np_array(self): func = lambda: np.array([3.0]) self._run(func, 30000) def _benchmark_create_tensor(self, value, dtype, device): """Benchmark overheads of creating a Tensor object.""" if device == GPU: # Warmup the GPU ops.EagerTensor(value, device=device) def func(): ops.EagerTensor(value, device=device, dtype=dtype) self._run(func, 30000) def _benchmark_create_constant(self, value, dtype, cached=True): global GLOBAL_TEST_VALUE GLOBAL_TEST_VALUE = value def cached_func(): constant_op.constant(value, dtype=dtype) def uncached_func(): global GLOBAL_TEST_VALUE GLOBAL_TEST_VALUE += 1 constant_op.constant(GLOBAL_TEST_VALUE, dtype=dtype) func = cached_func if cached else uncached_func with ops.device("GPU:0" if context.num_gpus() else "CPU:0"): for _ in range(1000): func() # Warmup. self._run(func, 3000) def benchmark_create_float_constant(self): self._benchmark_create_constant(42.0, dtype=None) def benchmark_create_float_constant_uncached(self): self._benchmark_create_constant(42.0, dtype=None, cached=False) def benchmark_create_int32_constant(self): if context.num_gpus(): return # int32 constants are always allocated on CPU. self._benchmark_create_constant(42, dtype=dtypes.int32) def benchmark_create_int32_constant_uncached(self): if context.num_gpus(): return # int32 constants are always allocated on CPU. self._benchmark_create_constant(42, dtype=dtypes.int32, cached=False) def _benchmark_add(self, a, b): def func(): return memoryview(math_ops.add_v2(a, b)) with ops.device("GPU:0" if context.num_gpus() else "CPU:0"): for _ in range(1000): func() # Warmup. self._run(func, 30000) def _benchmark_add_operator_overload(self, a, b): def func(): return memoryview(a + b) with ops.device("GPU:0" if context.num_gpus() else "CPU:0"): for _ in range(1000): func() # Warmup. self._run(func, 30000) def benchmark_add_float_scalars(self): self._benchmark_add(42.0, 24.0) def benchmark_add_int32_scalars(self): self._benchmark_add(42, 24) def benchmark_add_float_scalar_tensor(self): tensor_a = constant_op.constant(42.0) tensor_b = constant_op.constant(24.0) self._benchmark_add(tensor_a, tensor_b) def benchmark_add_float_scalar_tensor_overloaded_operator(self): tensor_a = constant_op.constant(42.0) tensor_b = constant_op.constant(24.0) self._benchmark_add_operator_overload(tensor_a, tensor_b) def benchmark_add_int32_scalar_tensor(self): tensor_a = constant_op.constant(42) tensor_b = constant_op.constant(24) self._benchmark_add(tensor_a, tensor_b) def benchmark_add_float_dense_tensor(self): tensor_a = constant_op.constant([[42.0, 42.0], [42.0, 42.0]]) tensor_b = constant_op.constant([[24.0, 24.0], [24.0, 24.0]]) self._benchmark_add(tensor_a, tensor_b) def benchmark_add_int32_dense_tensor(self): tensor_a = constant_op.constant([[42, 42], [42, 42]]) tensor_b = constant_op.constant([[24, 24], [24, 24]]) self._benchmark_add(tensor_a, tensor_b) def benchmark_create_float_tensor_from_list_CPU(self): self._benchmark_create_tensor([[3.0]], dtypes.float32.as_datatype_enum, CPU) def benchmark_create_float_tensor_from_np_array_CPU(self): self._benchmark_create_tensor( np.array([[3.0]], dtype=np.float32), dtypes.float32.as_datatype_enum, CPU) def benchmark_create_int32_tensor_from_list_CPU(self): self._benchmark_create_tensor([[3]], dtypes.int32.as_datatype_enum, CPU) def benchmark_create_int32_tensor_from_np_array_CPU(self): self._benchmark_create_tensor( np.array([[3]], dtype=np.int32), dtypes.int32.as_datatype_enum, CPU) def benchmark_create_float_tensor_from_list_GPU(self): if not context.num_gpus(): return self._benchmark_create_tensor([[3.0]], dtypes.float32.as_datatype_enum, GPU) def benchmark_create_float_tensor_from_np_array_GPU(self): if not context.num_gpus(): return self._benchmark_create_tensor( np.array([[3.0]], dtype=np.float32), dtypes.float32.as_datatype_enum, GPU) def benchmark_create_int32_tensor_from_list_GPU(self): # int32's are kept on host memory even when executing on GPU. if not context.num_gpus(): return self._benchmark_create_tensor([[3]], dtypes.int32.as_datatype_enum, GPU) def benchmark_create_int32_tensor_from_np_array_GPU(self): # int32's are kept on host memory even when executing on GPU. if not context.num_gpus(): return self._benchmark_create_tensor( np.array([[3]], dtype=np.int32), dtypes.int32.as_datatype_enum, GPU) def benchmark_index_tensor_with_literal(self): func = lambda: constant_op.constant([3.0])[0] self._run(func, 30000) def benchmark_index_tensor_with_tensor(self): func = lambda idx=constant_op.constant(0): constant_op.constant([3.0])[idx] self._run(func, 30000) def benchmark_index_tensor_with_np_array(self): func = lambda idx=np.array(0): constant_op.constant([3.0])[idx] self._run(func, 30000) def _benchmark_np_multiply(self, m, num_iters): a = m.cpu().numpy() func = lambda: a * a self._run(func, num_iters) def _benchmark_tf_multiply(self, m, num_iters): func = lambda: m * m self._run(func, num_iters) def _benchmark_tf_conv2d(self, m1, m2, num_iters): func = lambda: nn_ops.conv2d(m1, m2, strides=[1, 1, 1, 1], padding="VALID") self._run(func, num_iters) def _benchmark_tf_multiply_op(self, m, num_iters): func = lambda: math_ops.multiply(m, m) self._run(func, num_iters) def benchmark_np_multiply(self): self._benchmark_np_multiply(self._m_2, 30000) def benchmark_tf_multiply_CPU(self): with context.device(CPU): m = self._m_2.cpu() self._benchmark_tf_multiply(m, 30000) def benchmark_tf_multiply_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2.gpu() self._benchmark_tf_multiply(m, 30000) def benchmark_tf_multiply_op_CPU(self): with context.device(CPU): m = self._m_2.cpu() self._benchmark_tf_multiply_op(m, 30000) def benchmark_tf_multiply_op_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2.gpu() self._benchmark_tf_multiply_op(m, 30000) def benchmark_tf_conv2d_CPU(self): with context.device(CPU): m1 = self._m_8_28_28_3.cpu() m2 = self._m_1_3_3_1.cpu() self._benchmark_tf_conv2d(m1, m2, 30000) def benchmark_tf_conv2d_GPU(self): if not context.num_gpus(): return with context.device(GPU): m1 = self._m_8_28_28_3.gpu() m2 = self._m_1_3_3_1.gpu() self._benchmark_tf_conv2d(m1, m2, 30000) def benchmark_tf_identity(self): m = self._m_2 self._run(lambda: gen_array_ops.identity(m), 30000) def benchmark_slowpath_tf_identity(self): self._run(lambda: gen_array_ops.identity(1), 30000) def benchmark_tfe_py_execute_identity(self): m = self._m_2 ctx_handle = context.context()._handle attrs = ("T", self._m_2.dtype.as_datatype_enum) inputs = [m] def f(): pywrap_tfe.TFE_Py_Execute(ctx_handle, None, "Identity", inputs, attrs, 1) self._run(f, 30000) def benchmark_tf_gradient_function_identity(self): with context.device(CPU): m = gen_array_ops.identity(self._m_2) self._run( lambda: backprop.gradients_function(gen_array_ops.identity, [0])(m), 30000) def benchmark_tf_gradient_forward_identity(self): with backprop.GradientTape() as tape: m = self._m_2 tape.watch(m) self._run(lambda: gen_array_ops.identity(m), 30000) def benchmark_tf_gradient_tape_push_pop(self): def f(): with backprop.GradientTape(): pass self._run(f, 30000) def benchmark_tf_gradient_function_no_op(self): with context.device(CPU): m = gen_array_ops.identity(self._m_2) self._run(lambda: backprop.gradients_function(lambda x: x, [0])(m), 30000) def _benchmark_np_matmul(self, m, transpose_b, num_iters): a = m.cpu().numpy() b = a.T if transpose_b else a func = lambda: np.dot(a, b) self._run(func, num_iters) def _benchmark_tf_matmul(self, m, transpose_b, num_iters, execution_mode=None): func = lambda: math_ops.matmul(m, m, transpose_b=transpose_b) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_gen_math_ops_matmul(self, m, transpose_b, num_iters): def func(): gen_math_ops.mat_mul(m, m, transpose_b=transpose_b) self._run(func, num_iters) def _benchmark_tfe_py_fastpath_execute_matmul(self, m, transpose_b, num_iters): def func(): c_tfe_py_fastpath_execute(m, m, transpose_b=transpose_b) self._run(func, num_iters) def _benchmark_tfe_py_execute_matmul(self, m, transpose_b, num_iters): inputs = [m, m] # pylint: disable=protected-access ctx_handle = context.context()._handle # pylint: enable=protected-access device = context.context().device_name attrs = ("transpose_a", False, "transpose_b", transpose_b, "T", m.dtype.as_datatype_enum) def func(): pywrap_tfe.TFE_Py_Execute(ctx_handle, device, "MatMul", inputs, attrs, 1) self._run(func, num_iters) def _benchmark_defun_matmul(self, m, transpose_b, num_iters, execution_mode=None): f = function.defun(math_ops.matmul) func = lambda: f(m, m, transpose_b=transpose_b) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_defun_matmul_with_signature(self, m, num_iters, execution_mode=None): @def_function.function( input_signature=[tensor_spec.TensorSpec([2, 2], dtypes.float32)]) def defun_matmul(m): return math_ops.matmul(m, m) func = lambda: defun_matmul(m) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_defun_matmul_relaxed_shape(self, m, num_iters, execution_mode=None): @def_function.function(experimental_relax_shapes=True) def defun_matmul(m): return math_ops.matmul(m, m) m_3_by_3 = random_ops.random_uniform((3, 3)) defun_matmul(m_3_by_3) func = lambda: defun_matmul(m) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_defun_args_matmul(self, m, num_iters, execution_mode=None): @def_function.function def defun_matmul(m): return math_ops.matmul(m, m) func = lambda: defun_matmul(m) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_nested_defun_matmul(self, m, transpose_b, num_iters): inner = function.defun(math_ops.matmul) @function.defun def outer(a, b, c, transpose_b): return math_ops.matmul(inner(a, b, transpose_b=transpose_b), c) func = lambda: outer(m, m, m, transpose_b=transpose_b) # Warmup before benchmark for _ in range(1000): func() self._run(func, num_iters) def _benchmark_defun_matmul_forward_backward(self, m, transpose_b, num_iters, execution_mode=None): f = def_function.function(math_ops.matmul) def func(): with backprop.GradientTape() as gt: gt.watch(m) y = f(m, m, transpose_b=transpose_b) _ = gt.gradient(y, m) self._run(func, num_iters, execution_mode=execution_mode) def _benchmark_read_variable(self, m, num_iters): self._run(m.value, num_iters) def _benchmark_matmul_read_variable(self, m, num_iters): self._benchmark_gen_math_ops_matmul( m, transpose_b=False, num_iters=num_iters) def _benchmark_matmul_read_variable_with_tape(self, m, num_iters): with backprop.GradientTape() as tape: tape.watch(m) self._benchmark_gen_math_ops_matmul( m, transpose_b=False, num_iters=num_iters) def _benchmark_read_variable_with_tape(self, m, num_iters): with backprop.GradientTape() as tape: tape.watch(m) self._run(m.value, num_iters) # Benchmarks for A^2, A of dimension 2 by 2. def benchmark_np_matmul_2_by_2(self): self._benchmark_np_matmul( self._m_2_by_2, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tf_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_tf_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tf_matmul_2_by_2_CPU_async(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_tf_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2, execution_mode=context.ASYNC) def benchmark_gen_math_ops_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_gen_math_ops_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tfe_py_fastpath_execute_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_tfe_py_fastpath_execute_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tfe_py_execute_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_tfe_py_execute_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_with_signature_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul_with_signature( m, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_relaxed_shape_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul_relaxed_shape( m, num_iters=self._num_iters_2_by_2) def benchmark_defun_args_matmul_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_args_matmul(m, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_CPU_async(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2, execution_mode=context.ASYNC) def _benchmark_matmul_forward_backward_2_by_2_CPU(self, run_eager=False): def_function.run_functions_eagerly(run_eager) with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul_forward_backward( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def_function.run_functions_eagerly(False) def _benchmark_matmul_forward_backward_2_by_2_CPU_async( self, run_eager=False): def_function.run_functions_eagerly(run_eager) with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_defun_matmul_forward_backward( m, transpose_b=False, num_iters=self._num_iters_2_by_2, execution_mode=context.ASYNC) def benchmark_defun_matmul_forward_backward_2_by_2_CPU(self): self._benchmark_matmul_forward_backward_2_by_2_CPU(False) def benchmark_defun_matmul_forward_backward_2_by_2_CPU_async(self): self._benchmark_matmul_forward_backward_2_by_2_CPU_async(False) def benchmark_defun_eager_matmul_forward_backward_2_by_2_CPU(self): self._benchmark_matmul_forward_backward_2_by_2_CPU(True) def benchmark_defun_eager_matmul_forward_backward_2_by_2_CPU_async(self): self._benchmark_matmul_forward_backward_2_by_2_CPU_async(True) def benchmark_tf_matmul_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_tf_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tf_matmul_2_by_2_GPU_async(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_tf_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2, execution_mode=context.ASYNC) def benchmark_gen_math_ops_matmul_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_gen_math_ops_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_tfe_py_execute_matmul_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_tfe_py_execute_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_defun_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_with_signature_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_defun_matmul_with_signature( m, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_relaxed_shape_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_defun_matmul_relaxed_shape( m, num_iters=self._num_iters_2_by_2) def benchmark_defun_args_matmul_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_defun_args_matmul(m, num_iters=self._num_iters_2_by_2) def benchmark_defun_matmul_2_by_2_GPU_async(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_defun_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2, execution_mode=context.ASYNC) def benchmark_nested_defun_matmul_2_by_2(self): m = self._m_2_by_2.cpu() self._benchmark_nested_defun_matmul( m, transpose_b=False, num_iters=self._num_iters_2_by_2) # Benchmarks for AA.T, A of dimension 100 by 784. def benchmark_np_matmul_100_by_784(self): self._benchmark_np_matmul( self._m_100_by_784, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tf_matmul_100_by_784_CPU(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_tf_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tf_matmul_100_by_784_CPU_async(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_tf_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784, execution_mode=context.ASYNC) def benchmark_gen_math_ops_matmul_100_by_784_CPU(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_gen_math_ops_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tfe_py_fastpath_execute_matmul_100_by_784_CPU(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_tfe_py_fastpath_execute_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tfe_py_execute_matmul_100_by_784_CPU(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_tfe_py_execute_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_defun_matmul_100_by_784_CPU(self): with context.device(CPU): m = self._m_100_by_784.cpu() self._benchmark_defun_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tf_matmul_100_by_784_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_100_by_784.gpu() self._benchmark_tf_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tf_matmul_100_by_784_GPU_async(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_100_by_784.gpu() self._benchmark_tf_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784, execution_mode=context.ASYNC) def benchmark_gen_math_ops_matmul_100_by_784_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_100_by_784.gpu() self._benchmark_gen_math_ops_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_tfe_py_execute_matmul_100_by_784_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_100_by_784.gpu() self._benchmark_tfe_py_execute_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def benchmark_defun_matmul_100_by_784_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = self._m_100_by_784.gpu() self._benchmark_defun_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) @test_util.disable_tfrt( "b/169371527: Support inserting transfer op in lowering.") def benchmark_nested_defun_matmul_100_by_784_GPU(self): m = self._m_100_by_784.gpu() self._benchmark_nested_defun_matmul( m, transpose_b=True, num_iters=self._num_iters_100_by_784) def _benchmark_forwardprop_matmul_CPU(self, shape): with ops.device(CPU): m = random_ops.random_uniform(shape).cpu() tangent = random_ops.random_uniform(shape).cpu() def func(): with forwardprop.ForwardAccumulator(m, tangent) as acc: result = math_ops.matmul(m, m, transpose_b=True) return result, acc.jvp(result) # Warmup before benchmark for _ in range(100): func() self._run(func, 3000) def _benchmark_forwardprop_in_defun_matmul_CPU(self, shape): with ops.device(CPU): @def_function.function def compiled_function(x, tangent): with forwardprop.ForwardAccumulator(x, tangent) as acc: result = math_ops.matmul(x, x, transpose_b=True) return result, acc.jvp(result) m = random_ops.random_uniform(shape).cpu() tangent = random_ops.random_uniform(shape).cpu() func = lambda: compiled_function(m, tangent) # Warmup before benchmark for _ in range(100): func() self._run(func, 3000) def _benchmark_forwardprop_in_defun_of_defun_matmul_CPU(self, shape): with ops.device(CPU): matmul = def_function.function(math_ops.matmul) @def_function.function() def compiled_function(x, tangent): with forwardprop.ForwardAccumulator(x, tangent) as acc: result = matmul(x, x, transpose_b=True) return result, acc.jvp(result) m = random_ops.random_uniform(shape).cpu() tangent = random_ops.random_uniform(shape).cpu() func = lambda: compiled_function(m, tangent) # Warmup before benchmark for _ in range(100): func() self._run(func, 3000) def _benchmark_forwardprop_of_defun_matmul_CPU(self, shape): with ops.device(CPU): m = random_ops.random_uniform(shape).cpu() tangent = random_ops.random_uniform(shape).cpu() matmul = def_function.function(math_ops.matmul) def func(): with forwardprop.ForwardAccumulator(m, tangent) as acc: result = matmul(m, m, transpose_b=True) return result, acc.jvp(result) # Warmup before benchmark for _ in range(100): func() self._run(func, 3000) def benchmark_forwardprop_matmul_256_by_2096_CPU(self): self._benchmark_forwardprop_matmul_CPU(shape=(256, 2096)) def benchmark_forwardprop_in_defun_matmul_256_by_2096_CPU(self): self._benchmark_forwardprop_in_defun_matmul_CPU(shape=(256, 2096)) def benchmark_forwardprop_in_defun_of_defun_matmul_256_by_2096_CPU(self): self._benchmark_forwardprop_in_defun_of_defun_matmul_CPU(shape=(256, 2096)) def benchmark_forwardprop_of_defun_matmul_256_by_2096_CPU(self): self._benchmark_forwardprop_of_defun_matmul_CPU(shape=(256, 2096)) def benchmark_forwardprop_matmul_100_by_784_CPU(self): self._benchmark_forwardprop_matmul_CPU(shape=(100, 784)) def benchmark_forwardprop_in_defun_matmul_100_by_784_CPU(self): self._benchmark_forwardprop_in_defun_matmul_CPU(shape=(100, 784)) def benchmark_forwardprop_in_defun_of_defun_matmul_100_by_784_CPU(self): self._benchmark_forwardprop_in_defun_of_defun_matmul_CPU(shape=(100, 784)) def benchmark_forwardprop_of_defun_matmul_100_by_784_CPU(self): self._benchmark_forwardprop_of_defun_matmul_CPU(shape=(100, 784)) def _benchmark_tf_reduce_logsumexp(self, device=CPU, execution_mode=None, defunc=False, xla_compile=False): with context.device(device): x = constant_op.constant([[1, 0.], [0., 0.]]) if defunc: reduce_func = def_function.function( math_ops.reduce_logsumexp, experimental_compile=xla_compile) func = lambda: reduce_func(x) else: func = lambda: math_ops.reduce_logsumexp(x) self._run(func, 3000, execution_mode=execution_mode) def benchmark_tf_reduce_logsumexp_CPU(self): self._benchmark_tf_reduce_logsumexp() def benchmark_tf_reduce_logsumexp_CPU_async(self): self._benchmark_tf_reduce_logsumexp(execution_mode=context.ASYNC) def benchmark_tf_reduce_logsumexp_GPU(self): self._benchmark_tf_reduce_logsumexp(device=GPU) def benchmark_tf_reduce_logsumexp_GPU_async(self): self._benchmark_tf_reduce_logsumexp(device=GPU, execution_mode=context.ASYNC) @test_util.disable_tfrt( "b/169371527: Support inserting transfer op in lowering.") def benchmark_tf_reduce_logsumexp_CPU_defunc(self): self._benchmark_tf_reduce_logsumexp(defunc=True) @test_util.disable_tfrt( "b/169371527: Support inserting transfer op in lowering.") def benchmark_tf_reduce_logsumexp_CPU_async_defun(self): self._benchmark_tf_reduce_logsumexp( execution_mode=context.ASYNC, defunc=True) def benchmark_tf_reduce_logsumexp_GPU_defun(self): self._benchmark_tf_reduce_logsumexp(device=GPU, defunc=True) def benchmark_tf_reduce_logsumexp_GPU_async_defun(self): self._benchmark_tf_reduce_logsumexp( device=GPU, execution_mode=context.ASYNC, defunc=True) def benchmark_tf_reduce_logsumexp_GPU_defun_compile(self): self._benchmark_tf_reduce_logsumexp( device=GPU, defunc=True, xla_compile=True) def benchmark_tf_reduce_logsumexp_GPU_async_defun_compile(self): self._benchmark_tf_reduce_logsumexp( device=GPU, execution_mode=context.ASYNC, defunc=True, xla_compile=True) def _benchmark_tf_tensordot(self, device=CPU, execution_mode=None): with context.device(device): a = array_ops.ones((2, 2)) b = array_ops.ones((2, 2)) func = lambda: math_ops.tensordot(a, b, [[1], [0]]) self._run(func, 30000, execution_mode=execution_mode) def benchmark_tf_tensordot_CPU(self): self._benchmark_tf_tensordot() def benchmark_tf_tensordot_CPU_async(self): self._benchmark_tf_tensordot(execution_mode=context.ASYNC) def benchmark_tf_tensordot_GPU(self): self._benchmark_tf_tensordot(device=GPU) def benchmark_tf_tensordot_GPU_async(self): self._benchmark_tf_tensordot(device=GPU, execution_mode=context.ASYNC) def _benchmark_tf_zeros(self, shape, dtype, device=CPU): with context.device(device): func = lambda: array_ops.zeros(shape, dtype) self._run(func, 3000) def benchmark_tf_zeros_2_by_2_float32_CPU(self): self._benchmark_tf_zeros((2, 2), dtypes.float32) def benchmark_tf_zeros_2_by_2_bool_CPU(self): self._benchmark_tf_zeros((2, 2), dtypes.bool) def benchmark_tf_zeros_2_by_2_string_CPU(self): self._benchmark_tf_zeros((2, 2), dtypes.string) def benchmark_tf_zeros_2_by_2_float32_GPU(self): self._benchmark_tf_zeros((2, 2), dtypes.float32, device=GPU) def benchmark_tf_zeros_2_by_2_bool_GPU(self): self._benchmark_tf_zeros((2, 2), dtypes.bool, device=GPU) def benchmark_tf_zeros_30_by_30_float32_CPU(self): self._benchmark_tf_zeros((30, 30), dtypes.float32) def benchmark_tf_zeros_30_by_30_bool_CPU(self): self._benchmark_tf_zeros((30, 30), dtypes.bool) def benchmark_tf_zeros_30_by_30_string_CPU(self): self._benchmark_tf_zeros((30, 30), dtypes.string) def benchmark_tf_zeros_30_by_30_float32_GPU(self): self._benchmark_tf_zeros((30, 30), dtypes.float32, device=GPU) def benchmark_tf_zeros_30_by_30_bool_GPU(self): self._benchmark_tf_zeros((30, 30), dtypes.bool, device=GPU) def benchmark_tf_zeros_100_by_100_float32_CPU(self): self._benchmark_tf_zeros((100, 100), dtypes.float32) def benchmark_tf_zeros_100_by_100_bool_CPU(self): self._benchmark_tf_zeros((100, 100), dtypes.bool) def benchmark_tf_zeros_100_by_100_string_CPU(self): self._benchmark_tf_zeros((100, 100), dtypes.string) def benchmark_tf_zeros_100_by_100_float32_GPU(self): self._benchmark_tf_zeros((100, 100), dtypes.float32, device=GPU) def benchmark_tf_zeros_100_by_100_bool_GPU(self): self._benchmark_tf_zeros((100, 100), dtypes.bool, device=GPU) def _benchmark_tf_zeros_like(self, m, device=CPU): with context.device(device): func = lambda: array_ops.zeros_like(m) self._run(func, 3000) def benchmark_tf_zeros_like_CPU(self): self._benchmark_tf_zeros_like(self._m_2_by_2) def benchmark_tf_zeros_like_GPU(self): self._benchmark_tf_zeros_like(self._m_2_by_2, device=GPU) def benchmark_tf_zeros_like_variable_CPU(self): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_tf_zeros_like(m) def benchmark_tf_zeros_like_variable_GPU(self): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_tf_zeros_like(m, device=GPU) def _benchmark_tf_random_uniform_2_by_2(self, shape=(2, 2), dtype=dtypes.int32, device=CPU): with context.device(device): def func(): return random_ops.random_uniform(shape, maxval=3, dtype=dtype) self._run(func, num_iters=self._num_iters_2_by_2) def benchmark_tf_random_uniform_2_by_2_integer_CPU(self): self._benchmark_tf_random_uniform_2_by_2() def benchmark_tf_random_uniform_2_by_2_integer_GPU(self): self._benchmark_tf_random_uniform_2_by_2(device=GPU) def benchmark_tf_random_uniform_2_by_2_float_CPU(self): self._benchmark_tf_random_uniform_2_by_2(dtype=dtypes.float32) def benchmark_tf_random_uniform_2_by_2_float_GPU(self): self._benchmark_tf_random_uniform_2_by_2( dtype=dtypes.float32, device=GPU) def benchmark_tf_random_uniform_2_by_2_default_setting_CPU(self): with context.device(CPU): func = lambda: random_ops.random_uniform((2, 2)) self._run(func, num_iters=self._num_iters_2_by_2) def benchmark_tf_random_uniform_2_by_2_default_setting_GPU(self): with context.device(GPU): func = lambda: random_ops.random_uniform((2, 2)) self._run(func, num_iters=self._num_iters_2_by_2) def _benchmark_tf_dropout_2_by_2(self, is_rate_tensor=True, noise_shape=None, device=CPU): if is_rate_tensor: rate = constant_op.constant(0.5, dtype=dtypes.float32) else: rate = 0.5 with context.device(device): def func(): return nn_ops.dropout( self._m_2_by_2, rate=rate, noise_shape=noise_shape) self._run(func, num_iters=self._num_iters_2_by_2) def benchmark_tf_dropout_scalar_rate_2_by_2_CPU(self): self._benchmark_tf_dropout_2_by_2(is_rate_tensor=False) def benchmark_tf_dropout_scalar_rate_2_by_2_GPU(self): self._benchmark_tf_dropout_2_by_2(is_rate_tensor=False, device=GPU) def benchmark_tf_dropout_2_by_2_CPU(self): self._benchmark_tf_dropout_2_by_2() def benchmark_tf_dropout_2_by_2_GPU(self): self._benchmark_tf_dropout_2_by_2(device=GPU) def _benchmark_transpose(self, m, num_iters, perm=None, conjugate=False, execution_mode=None): func = lambda: array_ops.transpose(m, perm, conjugate) self._run(func, num_iters, execution_mode=execution_mode) def benchmark_tf_transpose_2_by_2_CPU(self): with context.device(CPU): m = self._m_2_by_2.cpu() self._benchmark_transpose(m, num_iters=self._num_iters_2_by_2) def benchmark_tf_transpose_2_by_2_GPU(self): with context.device(GPU): m = self._m_2_by_2.gpu() self._benchmark_transpose(m, num_iters=self._num_iters_2_by_2) def benchmark_tf_transpose_variable_2_by_2_CPU(self): with context.device(CPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_transpose(m, num_iters=self._num_iters_2_by_2) def benchmark_tf_transpose_variable_2_by_2_GPU(self): with context.device(GPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_transpose(m, num_iters=self._num_iters_2_by_2) def benchmark_defun_without_signature(self): def func(t1, t2, t3, t4, t5, t6, t7, t8): del t1, t2, t3, t4, t5, t6, t7, t8 return None defined = function.defun(func) t = constant_op.constant(0.0) cache_computation = lambda: defined(t, t, t, t, t, t, t, t) self._run(cache_computation, 30000) def benchmark_defun_without_signature_and_with_kwargs(self): def func(t1, t2, t3, t4, t5, t6, t7, t8): del t1, t2, t3, t4, t5, t6, t7, t8 return None defined = function.defun(func) t = constant_op.constant(0.0) def cache_computation(): return defined(t1=t, t2=t, t3=t, t4=t, t5=t, t6=t, t7=t, t8=t) self._run(cache_computation, 30000) def benchmark_defun_with_signature(self): def func(t1, t2, t3, t4, t5, t6, t7, t8): del t1, t2, t3, t4, t5, t6, t7, t8 return None defined = function.defun( func, input_signature=[tensor_spec.TensorSpec([], dtypes.float32)] * 8) t = constant_op.constant(0.0) signature_computation = lambda: defined(t, t, t, t, t, t, t, t) self._run(signature_computation, 30000) def benchmark_defun_with_signature_and_kwargs(self): def func(t1, t2, t3, t4, t5, t6, t7, t8): del t1, t2, t3, t4, t5, t6, t7, t8 return None defined = function.defun( func, input_signature=[tensor_spec.TensorSpec([], dtypes.float32)] * 8) t = constant_op.constant(0.0) def signature_computation(): return defined(t1=t, t2=t, t3=t, t4=t, t5=t, t6=t, t7=t, t8=t) self._run(signature_computation, 30000) def benchmark_matmul_read_variable_op_2_by_2_CPU(self): with context.device(CPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_matmul_read_variable(m, num_iters=self._num_iters_2_by_2) def benchmark_matmul_read_variable_op_with_tape_2_by_2_CPU(self): with context.device(CPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_matmul_read_variable_with_tape( m, num_iters=self._num_iters_2_by_2) def benchmark_read_variable_op_2_by_2_CPU(self): with context.device(CPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_read_variable(m, num_iters=self._num_iters_2_by_2) def benchmark_read_variable_op_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2.gpu()) self._benchmark_read_variable(m, num_iters=self._num_iters_2_by_2) def benchmark_read_variable_op_with_tape_2_by_2_CPU(self): with context.device(CPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2) self._benchmark_read_variable_with_tape( m, num_iters=self._num_iters_2_by_2) def benchmark_read_variable_op_with_tape_2_by_2_GPU(self): if not context.num_gpus(): return with context.device(GPU): m = resource_variable_ops.ResourceVariable(self._m_2_by_2.gpu()) self._benchmark_read_variable_with_tape( m, num_iters=self._num_iters_2_by_2) def benchmarkScan(self): elems = math_ops.range(1600) def scan(): return functional_ops.scan( lambda a, x: a + x, elems, parallel_iterations=1) self._run(scan, 100) @test_util.disable_tfrt("tf.While not supported RTFB tensor. b/169374895") def benchmarkScanDefun(self): elems = math_ops.range(1600) @function.defun def scan(): return functional_ops.scan( lambda a, x: a + x, elems, parallel_iterations=1) self._run(scan, 100) def benchmark_fastpath_conversion_type_inference(self): c = constant_op.constant(1., dtype=dtypes.float32) def fn(): return gen_math_ops.add(c, 1) self._run(fn, 10000) def benchmark_convert_tensor(self): value = ops.convert_to_tensor(42) def fn(): return ops.convert_to_tensor(value) self._run(fn, 10000) def _benchmark_convert_constant(self, value, cached): global GLOBAL_TEST_VALUE GLOBAL_TEST_VALUE = value def cached_func(): ops.convert_to_tensor(value) def uncached_func(): global GLOBAL_TEST_VALUE GLOBAL_TEST_VALUE += 1 ops.convert_to_tensor(GLOBAL_TEST_VALUE) func = cached_func if cached else uncached_func self._run(func, 10000) def benchmark_convert_python_int(self): self._benchmark_convert_constant(42, cached=True) def benchmark_convert_python_int_uncached(self): self._benchmark_convert_constant(42, cached=False) def benchmark_convert_python_float(self): self._benchmark_convert_constant(42.0, cached=True) def benchmark_convert_python_float_uncached(self): self._benchmark_convert_constant(42.0, cached=False) def benchmark_convert_numpy_int(self): self._benchmark_convert_constant(np.array(42), cached=True) def benchmark_convert_numpy_int_uncached(self): self._benchmark_convert_constant(np.array(42), cached=False) def benchmark_convert_numpy_float(self): self._benchmark_convert_constant(np.array(42.0), cached=True) def benchmark_convert_numpy_float_uncached(self): self._benchmark_convert_constant(np.array(42.0), cached=False) def benchmark_convert_3x_list_to_tensor(self): xs = [1, 2, 3] self._run(lambda: ops.convert_to_tensor(xs), 1000) def benchmark_convert_3x_array_to_tensor(self): xs = np.array([1, 2, 3], dtype=np.int32) self._run(lambda: ops.convert_to_tensor(xs), 1000) def benchmark_constant_40x2_list_to_tensor(self): xs = [[0] * 2] * 40 self._run(lambda: constant_op.constant(xs), 1000) def benchmark_constant_40x2_array_to_tensor(self): xs = np.array([[0] * 2] * 40, dtype=np.int32) self._run(lambda: constant_op.constant(xs), 1000) def benchmark_constant_40x_list_of_2x_arrays_to_tensor(self): xs = [np.array([0] * 2, dtype=np.int32)] * 40 self._run(lambda: constant_op.constant(xs), 1000) def benchmark_constant_20x20x20_double_list_to_float32_tensor(self): xs = [[[np.linspace(0, 1, 21).tolist()] * 20] * 20] self._run(lambda: constant_op.constant(xs, dtype=dtypes.float32), 10000) def benchmark_constant_20x20x20_double_list_to_float64_tensor(self): xs = [[[np.linspace(0, 1, 21).tolist()] * 20] * 20] self._run(lambda: constant_op.constant(xs, dtype=dtypes.float64), 10000) def benchmark_list_of_zeros_to_np_array(self): values = [] for _ in range(1000): values.append(array_ops.zeros(shape=(1000,))) self._run(lambda: np.array([x.numpy() for x in values]), 1000) def benchmark_function_trace(self): def func(x): return x self._run(lambda: (def_function.function(func)(x) for x in range(1000)), 30000) def _benchmarkFunctionWithResourceInputs(self, num_resources, num_iters): @def_function.function def add_all(*args): return math_ops.add_n(*args) with context.device(CPU): resources = [] for _ in range(num_resources): resources.append(resource_variable_ops.ResourceVariable(self._m_2)) self._run(lambda: add_all(resources), num_iters) def benchmarkFunctionWithFiveResourceInputs(self): self._benchmarkFunctionWithResourceInputs(5, 1000) def benchmarkFunctionWithFiveHundredResourceInputs(self): self._benchmarkFunctionWithResourceInputs(500, 100) def _benchmarkResourceReadsInCondInInnerFunc(self, var_count): rvars = [] for _ in range(var_count): rvars.append(resource_variable_ops.ResourceVariable(1.0)) # Note: We want to benchmark the graph building time so we intentionally # add this outer function so that the tf.function gets retraced every time. def benchmark_fn(): @def_function.function def fn_with_many_reads(): @def_function.function def fn_with_many_reads_inner(): def then_branch(): return math_ops.add_n(rvars) def else_branch(): return 0. return control_flow_ops.cond( constant_op.constant(True), then_branch, else_branch) return fn_with_many_reads_inner() return fn_with_many_reads() with context.device(CPU): self._run(benchmark_fn, 10) def benchmarkTenThousandResourceReadsInCondInInnerFunc(self): self._benchmarkResourceReadsInCondInInnerFunc(10000) def benchmarkHundredResourceReadsInCondInInnerFunc(self): self._benchmarkResourceReadsInCondInInnerFunc(100) def benchmarkTenResourceReadsInCondInInnerFunc(self): self._benchmarkResourceReadsInCondInInnerFunc(10) def benchmark_tf_name_scope(self): def fn(): with ops.name_scope_v2("name"): pass self._run(fn, 10000) def benchmark_tf_nest_map_structure(self): nested = {"a": [1, 2, 3], "b": (4, 5, 6)} def fn(): nest.map_structure(lambda x: x, nested) self._run(fn, 10000) def benchmark_tf_nest_pack_sequence_as(self): nested = {"a": [1, 2, 3], "b": (4, 5, 6)} flat = nest.flatten(nested) def fn(): nest.pack_sequence_as(nested, flat) self._run(fn, 10000) def benchmark_tf_nest_flatten_none(self): def fn(): nest.flatten(None) self._run(fn, 100000) def benchmark_tf_nest_flatten(self): nested = {"a": [1, 2, 3], "b": (4, 5, 6)} def fn(): nest.flatten(nested) self._run(fn, 100000) def benchmark_tf_nn_convolution_overhead(self): inputs = array_ops.ones((1, 1, 1, 1)) filters = array_ops.ones((1, 1, 1, 1)) def fn(): nn_ops.convolution_v2(inputs, filters) self._run(fn, 10000) def benchmark_tf_tensor_shape_creation_overhead(self): # A `TensorShape` is created the first time `EagerTensor.shape` is # called, which puts `TensorShape.__init__` on the hotpath. The # `TensorShape` is created from `EagerTensor._shape_tuple`. x = array_ops.ones((1, 1)) shape_tuple = x._shape_tuple() def fn(): tensor_shape.TensorShape(shape_tuple) self._run(fn, 100000) if __name__ == "__main__": test.main()
aam-at/tensorflow
tensorflow/python/eager/benchmarks_test.py
Python
apache-2.0
50,309
"""Check that required Docker images are available.""" import re from pipes import quote from ansible.module_utils import six from openshift_checks import OpenShiftCheck from openshift_checks.mixins import DockerHostMixin NODE_IMAGE_SUFFIXES = ["haproxy-router", "docker-registry", "deployer", "pod"] DEPLOYMENT_IMAGE_INFO = { "origin": { "namespace": "openshift", "name": "origin", "registry_console_prefix": "cockpit/", "registry_console_basename": "kubernetes", "registry_console_default_version": "latest", }, "openshift-enterprise": { "namespace": "openshift3", "name": "ose", "registry_console_prefix": "openshift3/", "registry_console_basename": "registry-console", "registry_console_default_version": "${short_version}", }, } class DockerImageAvailability(DockerHostMixin, OpenShiftCheck): """Check that required Docker images are available. Determine docker images that an install would require and check that they are either present in the host's docker index, or available for the host to pull with known registries as defined in our inventory file (or defaults). """ name = "docker_image_availability" tags = ["preflight"] # we use python-docker-py to check local docker for images, and skopeo # to look for images available remotely without waiting to pull them. dependencies = ["python-docker-py", "skopeo"] # command for checking if remote registries have an image, without docker pull skopeo_command = "timeout 10 skopeo inspect --tls-verify={tls} {creds} docker://{registry}/{image}" skopeo_example_command = "skopeo inspect [--tls-verify=false] [--creds=<user>:<pass>] docker://<registry>/<image>" def __init__(self, *args, **kwargs): super(DockerImageAvailability, self).__init__(*args, **kwargs) self.registries = dict( # set of registries that need to be checked insecurely (note: not accounting for CIDR entries) insecure=set(self.ensure_list("openshift_docker_insecure_registries")), # set of registries that should never be queried even if given in the image blocked=set(self.ensure_list("openshift_docker_blocked_registries")), ) # ordered list of registries (according to inventory vars) that docker will try for unscoped images regs = self.ensure_list("openshift_docker_additional_registries") # currently one of these registries is added whether the user wants it or not. deployment_type = self.get_var("openshift_deployment_type") if deployment_type == "origin" and "docker.io" not in regs: regs.append("docker.io") elif deployment_type == 'openshift-enterprise' and "registry.access.redhat.com" not in regs: regs.append("registry.access.redhat.com") self.registries["configured"] = regs # for the oreg_url registry there may be credentials specified components = self.get_var("oreg_url", default="").split('/') self.registries["oreg"] = "" if len(components) < 3 else components[0] # Retrieve and template registry credentials, if provided self.skopeo_command_creds = "" oreg_auth_user = self.get_var('oreg_auth_user', default='') oreg_auth_password = self.get_var('oreg_auth_password', default='') if oreg_auth_user != '' and oreg_auth_password != '': if self._templar is not None: oreg_auth_user = self._templar.template(oreg_auth_user) oreg_auth_password = self._templar.template(oreg_auth_password) self.skopeo_command_creds = "--creds={}:{}".format(quote(oreg_auth_user), quote(oreg_auth_password)) # record whether we could reach a registry or not (and remember results) self.reachable_registries = {} def is_active(self): """Skip hosts with unsupported deployment types.""" deployment_type = self.get_var("openshift_deployment_type") has_valid_deployment_type = deployment_type in DEPLOYMENT_IMAGE_INFO return super(DockerImageAvailability, self).is_active() and has_valid_deployment_type def run(self): msg, failed = self.ensure_dependencies() if failed: return { "failed": True, "msg": "Some dependencies are required in order to check Docker image availability.\n" + msg } required_images = self.required_images() missing_images = set(required_images) - set(self.local_images(required_images)) # exit early if all images were found locally if not missing_images: return {} available_images = self.available_images(missing_images) unavailable_images = set(missing_images) - set(available_images) if unavailable_images: unreachable = [reg for reg, reachable in self.reachable_registries.items() if not reachable] unreachable_msg = "Failed connecting to: {}\n".format(", ".join(unreachable)) blocked_msg = "Blocked registries: {}\n".format(", ".join(self.registries["blocked"])) msg = ( "One or more required container images are not available:\n {missing}\n" "Checked with: {cmd}\n" "Default registries searched: {registries}\n" "{blocked}" "{unreachable}" ).format( missing=",\n ".join(sorted(unavailable_images)), cmd=self.skopeo_example_command, registries=", ".join(self.registries["configured"]), blocked=blocked_msg if self.registries["blocked"] else "", unreachable=unreachable_msg if unreachable else "", ) return dict(failed=True, msg=msg) return {} def required_images(self): """ Determine which images we expect to need for this host. Returns: a set of required images like 'openshift/origin:v3.6' The thorny issue of determining the image names from the variables is under consideration via https://github.com/openshift/openshift-ansible/issues/4415 For now we operate as follows: * For containerized components (master, node, ...) we look at the deployment type and use openshift/origin or openshift3/ose as the base for those component images. The version is openshift_image_tag as determined by the openshift_version role. * For OpenShift-managed infrastructure (router, registry...) we use oreg_url if it is defined; otherwise we again use the base that depends on the deployment type. Registry is not included in constructed images. It may be in oreg_url or etcd image. """ required = set() deployment_type = self.get_var("openshift_deployment_type") host_groups = self.get_var("group_names") # containerized etcd may not have openshift_image_tag, see bz 1466622 image_tag = self.get_var("openshift_image_tag", default="latest") image_info = DEPLOYMENT_IMAGE_INFO[deployment_type] # template for images that run on top of OpenShift image_url = "{}/{}-{}:{}".format(image_info["namespace"], image_info["name"], "${component}", "${version}") image_url = self.get_var("oreg_url", default="") or image_url if 'oo_nodes_to_config' in host_groups: for suffix in NODE_IMAGE_SUFFIXES: required.add(image_url.replace("${component}", suffix).replace("${version}", image_tag)) if self.get_var("osm_use_cockpit", default=True, convert=bool): required.add(self._registry_console_image(image_tag, image_info)) # images for containerized components if self.get_var("openshift_is_containerized"): components = set() if 'oo_nodes_to_config' in host_groups: components.update(["node", "openvswitch"]) if 'oo_masters_to_config' in host_groups: # name is "origin" or "ose" components.add(image_info["name"]) for component in components: required.add("{}/{}:{}".format(image_info["namespace"], component, image_tag)) if 'oo_etcd_to_config' in host_groups: # special case, note it is the same for origin/enterprise required.add("registry.access.redhat.com/rhel7/etcd") # and no image tag return required def _registry_console_image(self, image_tag, image_info): """Returns image with logic to parallel what happens with the registry-console template.""" # The registry-console is for some reason not prefixed with ose- like the other components. # Nor is it versioned the same. Also a completely different name is used for Origin. prefix = self.get_var( "openshift_cockpit_deployer_prefix", default=image_info["registry_console_prefix"], ) basename = self.get_var( "openshift_cockpit_deployer_basename", default=image_info["registry_console_basename"], ) # enterprise template just uses v3.6, v3.7, etc match = re.match(r'v\d+\.\d+', image_tag) short_version = match.group() if match else image_tag version = image_info["registry_console_default_version"].replace("${short_version}", short_version) version = self.get_var("openshift_cockpit_deployer_version", default=version) return prefix + basename + ':' + version def local_images(self, images): """Filter a list of images and return those available locally.""" found_images = [] for image in images: # docker could have the image name as-is or prefixed with any registry imglist = [image] + [reg + "/" + image for reg in self.registries["configured"]] if self.is_image_local(imglist): found_images.append(image) return found_images def is_image_local(self, image): """Check if image is already in local docker index.""" result = self.execute_module("docker_image_facts", {"name": image}) return bool(result.get("images")) and not result.get("failed") def ensure_list(self, registry_param): """Return the task var as a list.""" # https://bugzilla.redhat.com/show_bug.cgi?id=1497274 # If the result was a string type, place it into a list. We must do this # as using list() on a string will split the string into its characters. # Otherwise cast to a list as was done previously. registry = self.get_var(registry_param, default=[]) if not isinstance(registry, six.string_types): return list(registry) return self.normalize(registry) def available_images(self, images): """Search remotely for images. Returns: list of images found.""" return [ image for image in images if self.is_available_skopeo_image(image) ] def is_available_skopeo_image(self, image): """Use Skopeo to determine if required image exists in known registry(s).""" registries = self.registries["configured"] # If image already includes a registry, only use that. # NOTE: This logic would incorrectly identify images that do not use a namespace, e.g. # registry.access.redhat.com/rhel7 as if the registry were a namespace. # It's not clear that there's any way to distinguish them, but fortunately # the current set of images all look like [registry/]namespace/name[:version]. if image.count("/") > 1: registry, image = image.split("/", 1) registries = [registry] for registry in registries: if registry in self.registries["blocked"]: continue # blocked will never be consulted if registry not in self.reachable_registries: self.reachable_registries[registry] = self.connect_to_registry(registry) if not self.reachable_registries[registry]: continue # do not keep trying unreachable registries args = dict(registry=registry, image=image) args["tls"] = "false" if registry in self.registries["insecure"] else "true" args["creds"] = self.skopeo_command_creds if registry == self.registries["oreg"] else "" result = self.execute_module_with_retries("command", {"_raw_params": self.skopeo_command.format(**args)}) if result.get("rc", 0) == 0 and not result.get("failed"): return True if result.get("rc") == 124: # RC 124 == timed out; mark unreachable self.reachable_registries[registry] = False return False def connect_to_registry(self, registry): """Use ansible wait_for module to test connectivity from host to registry. Returns bool.""" # test a simple TCP connection host, _, port = registry.partition(":") port = port or 443 args = dict(host=host, port=port, state="started", timeout=30) result = self.execute_module("wait_for", args) return result.get("rc", 0) == 0 and not result.get("failed")
zhiwliu/openshift-ansible
roles/openshift_health_checker/openshift_checks/docker_image_availability.py
Python
apache-2.0
13,335
#!/usr/bin/env python3 # Copyright 2019 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from grafanalib import core as g import defaults as d NETWORK_PROGRAMMING_PANEL = [ d.Graph( title="SLI: Network programming latency", description=( "NetworkProgrammingLatency is defined as the time it took to " + "program the network - from the time the service or pod has " + "changed to the time the change was propagated and the proper " + "kube-proxy rules were synced. Exported for each endpoints object " + "that were part of the rules sync." ), targets=d.show_quantiles( ( "quantile_over_time(" + "0.99, " + 'kubeproxy:kubeproxy_network_programming_duration:histogram_quantile{{quantile="{quantile}"}}[24h])' ), legend="{{quantile}}", ), yAxes=g.single_y_axis(format=g.SECONDS_FORMAT), ), d.Graph( title="Network programming latency", description=( "NetworkProgrammingLatency is defined as the time it took to " + "program the network - from the time the service or pod has " + "changed to the time the change was propagated and the proper " + "kube-proxy rules were synced. Exported for each endpoints object " + "that were part of the rules sync." ), targets=d.show_quantiles( 'kubeproxy:kubeproxy_network_programming_duration:histogram_quantile{{quantile="{quantile}"}}', legend="{{quantile}}", ), yAxes=g.single_y_axis(format=g.SECONDS_FORMAT), ), d.Graph( title="kube-proxy: sync rules duation", description="Latency of one round of kube-proxy syncing proxy rules.", targets=d.show_quantiles( "histogram_quantile({quantile}, sum(rate(kubeproxy_sync_proxy_rules_duration_seconds_bucket[5m])) by (le))" ), yAxes=g.single_y_axis(format=g.SECONDS_FORMAT), ), d.simple_graph( "kube-proxy: rate of service changes", "sum(rate(kubeproxy_sync_proxy_rules_service_changes_total[5m]))", description="Rate of service changes that the proxy has seen over 5m", legend="rate", ), d.simple_graph( "kube-proxy: pending service changes", "sum(kubeproxy_sync_proxy_rules_service_changes_pending)", description="Number of pending service changes that have not yet been synced to the proxy.", legend="pending changes", ), d.simple_graph( "kube-proxy: rate of endpoint changes", "sum(rate(kubeproxy_sync_proxy_rules_endpoint_changes_total[5m]))", description="Rate of endpoint changes that the proxy has seen over 5m", legend="rate", ), d.simple_graph( "kube-proxy: pending endpoint changes", "sum(kubeproxy_sync_proxy_rules_endpoint_changes_pending)", description="Number of pending endpoint changes that have not yet been synced to the proxy.", legend="pending changes", ), ] NETWORK_LATENCY_PANEL = [ d.Graph( title="Network latency", targets=d.show_quantiles( 'probes:in_cluster_network_latency:histogram_quantile{{quantile="{quantile}"}}', legend="{{quantile}}", ), yAxes=g.single_y_axis(format=g.SECONDS_FORMAT), nullPointMode="null", ), d.Graph( title="probes: ping rate", targets=[ d.Target( expr='sum(rate(probes_in_cluster_network_latency_ping_count{namespace="probes", job="ping-client"}[1m])) by (job)', legendFormat="rate", ), d.Target( expr='sum(rate(probes_in_cluster_network_latency_error{namespace="probes", job="ping-client"}[1m])) by (job)', legendFormat="error rate", ), ], nullPointMode="null", ), d.Graph( title="probe: # running", targets=[ d.TargetWithInterval( expr='count(container_memory_usage_bytes{namespace="probes", container=~"ping-client|ping-server"}) by (container, namespace)' ) ], nullPointMode="null", ), d.Graph( title="probes: memory usage", targets=[ d.Target( expr='min(container_memory_usage_bytes{namespace="probes", container=~"ping-client|ping-server"}) by (container)', legendFormat="min {{container}}", ), d.Target( expr='avg(container_memory_usage_bytes{namespace="probes", container=~"ping-client|ping-server"}) by (container)', legendFormat="avg {{container}}", ), d.Target( expr='max(container_memory_usage_bytes{namespace="probes", container=~"ping-client|ping-server"}) by (container)', legendFormat="max {{container}}", ), ], nullPointMode="null", ), ] dashboard = d.Dashboard( title="Network", rows=[ d.Row(title="Network progamming latency", panels=NETWORK_PROGRAMMING_PANEL), d.Row(title="In-cluster network latency", panels=NETWORK_LATENCY_PANEL), ], ).auto_panel_ids()
kubernetes/perf-tests
clusterloader2/pkg/prometheus/manifests/dashboards/network.dashboard.py
Python
apache-2.0
5,840
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('printy', '0001_initial'), ] operations = [ migrations.CreateModel( name='PostItModel', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('width', models.FloatField()), ('height', models.FloatField()), ], ), migrations.AlterField( model_name='postit', name='print_page', field=models.ForeignKey(related_name='posts', to='printy.PrintPage'), ), migrations.AddField( model_name='printpage', name='post_it_model', field=models.ForeignKey(default=1, to='printy.PostItModel'), preserve_default=False, ), ]
jdsolucoes/Ppostit
printy/migrations/0002_auto_20150921_2215.py
Python
apache-2.0
967
# Copyright 2012 NetApp # Copyright 2015 Mirantis inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Drivers for shares. """ import re import time from oslo_config import cfg from oslo_log import log import six from manila import exception from manila.i18n import _, _LE from manila import network from manila.share import utils as share_utils from manila import utils LOG = log.getLogger(__name__) share_opts = [ # NOTE(rushiagr): Reasonable to define this option at only one place. cfg.IntOpt( 'num_shell_tries', default=3, help='Number of times to attempt to run flakey shell commands.'), cfg.IntOpt( 'reserved_share_percentage', default=0, help='The percentage of backend capacity reserved.'), cfg.StrOpt( 'share_backend_name', default=None, help='The backend name for a given driver implementation.'), cfg.StrOpt( 'network_config_group', default=None, help="Name of the configuration group in the Manila conf file " "to look for network config options." "If not set, the share backend's config group will be used." "If an option is not found within provided group, then" "'DEFAULT' group will be used for search of option."), cfg.BoolOpt( 'driver_handles_share_servers', help="There are two possible approaches for share drivers in Manila. " "First is when share driver is able to handle share-servers and " "second when not. Drivers can support either both or only one " "of these approaches. So, set this opt to True if share driver " "is able to handle share servers and it is desired mode else set " "False. It is set to None by default to make this choice " "intentional."), cfg.FloatOpt( 'max_over_subscription_ratio', default=20.0, help='Float representation of the over subscription ratio ' 'when thin provisioning is involved. Default ratio is ' '20.0, meaning provisioned capacity can be 20 times ' 'the total physical capacity. If the ratio is 10.5, it ' 'means provisioned capacity can be 10.5 times the ' 'total physical capacity. A ratio of 1.0 means ' 'provisioned capacity cannot exceed the total physical ' 'capacity. A ratio lower than 1.0 is invalid.'), cfg.StrOpt( 'migration_tmp_location', default='/tmp/', help="Temporary path to create and mount shares during migration."), cfg.ListOpt( 'migration_ignore_files', default=['lost+found'], help="List of files and folders to be ignored when migrating shares. " "Items should be names (not including any path)."), cfg.IntOpt( 'migration_wait_access_rules_timeout', default=90, help="Time to wait for access rules to be allowed/denied on backends " "when migrating shares using generic approach (seconds)."), cfg.IntOpt( 'migration_create_delete_share_timeout', default=300, help='Timeout for creating and deleting share instances ' 'when performing share migration (seconds).'), cfg.StrOpt( 'migration_mounting_backend_ip', default=None, help="Backend IP in admin network to use for mounting " "shares during migration."), cfg.StrOpt( 'migration_data_copy_node_ip', default=None, help="The IP of the node responsible for copying data during " "migration, such as the data copy service node, reachable by " "the backend."), cfg.StrOpt( 'migration_protocol_mount_command', default=None, help="The command for mounting shares for this backend. Must specify" "the executable and all necessary parameters for the protocol " "supported. It is advisable to separate protocols per backend."), cfg.BoolOpt( 'migration_readonly_support', default=True, help="Specify whether read only access mode is supported in this" "backend."), ] ssh_opts = [ cfg.IntOpt( 'ssh_conn_timeout', default=60, help='Backend server SSH connection timeout.'), cfg.IntOpt( 'ssh_min_pool_conn', default=1, help='Minimum number of connections in the SSH pool.'), cfg.IntOpt( 'ssh_max_pool_conn', default=10, help='Maximum number of connections in the SSH pool.'), ] ganesha_opts = [ cfg.StrOpt('ganesha_config_dir', default='/etc/ganesha', help='Directory where Ganesha config files are stored.'), cfg.StrOpt('ganesha_config_path', default='$ganesha_config_dir/ganesha.conf', help='Path to main Ganesha config file.'), cfg.StrOpt('ganesha_nfs_export_options', default='maxread = 65536, prefread = 65536', help='Options to use when exporting a share using ganesha ' 'NFS server. Note that these defaults can be overridden ' 'when a share is created by passing metadata with key ' 'name export_options. Also note the complete set of ' 'default ganesha export options is specified in ' 'ganesha_utils. (GPFS only.)'), cfg.StrOpt('ganesha_service_name', default='ganesha.nfsd', help='Name of the ganesha nfs service.'), cfg.StrOpt('ganesha_db_path', default='$state_path/manila-ganesha.db', help='Location of Ganesha database file. ' '(Ganesha module only.)'), cfg.StrOpt('ganesha_export_dir', default='$ganesha_config_dir/export.d', help='Path to directory containing Ganesha export ' 'configuration. (Ganesha module only.)'), cfg.StrOpt('ganesha_export_template_dir', default='/etc/manila/ganesha-export-templ.d', help='Path to directory containing Ganesha export ' 'block templates. (Ganesha module only.)'), ] CONF = cfg.CONF CONF.register_opts(share_opts) CONF.register_opts(ssh_opts) CONF.register_opts(ganesha_opts) class ExecuteMixin(object): """Provides an executable functionality to a driver class.""" def init_execute_mixin(self, *args, **kwargs): if self.configuration: self.configuration.append_config_values(ssh_opts) self.set_execute(kwargs.pop('execute', utils.execute)) def set_execute(self, execute): self._execute = execute def _try_execute(self, *command, **kwargs): # NOTE(vish): Volume commands can partially fail due to timing, but # running them a second time on failure will usually # recover nicely. tries = 0 while True: try: self._execute(*command, **kwargs) return True except exception.ProcessExecutionError: tries += 1 if tries >= self.configuration.num_shell_tries: raise LOG.exception(_LE("Recovering from a failed execute. " "Try number %s"), tries) time.sleep(tries ** 2) class GaneshaMixin(object): """Augment derived classes with Ganesha configuration.""" def init_ganesha_mixin(self, *args, **kwargs): if self.configuration: self.configuration.append_config_values(ganesha_opts) class ShareDriver(object): """Class defines interface of NAS driver.""" def __init__(self, driver_handles_share_servers, *args, **kwargs): """Implements base functionality for share drivers. :param driver_handles_share_servers: expected boolean value or tuple/list/set of boolean values. There are two possible approaches for share drivers in Manila. First is when share driver is able to handle share-servers and second when not. Drivers can support either both or only one of these approaches. So, it is allowed to be 'True' when share driver does support handling of share servers and allowed to be 'False' when does support usage of unhandled share-servers that are not tracked by Manila. Share drivers are allowed to work only in one of two possible driver modes, that is why only one should be chosen. """ super(ShareDriver, self).__init__() self.configuration = kwargs.get('configuration', None) self._stats = {} self.pools = [] if self.configuration: self.configuration.append_config_values(share_opts) network_config_group = (self.configuration.network_config_group or self.configuration.config_group) else: network_config_group = None self._verify_share_server_handling(driver_handles_share_servers) if self.driver_handles_share_servers: self.network_api = network.API( config_group_name=network_config_group) if hasattr(self, 'init_execute_mixin'): # Instance with 'ExecuteMixin' self.init_execute_mixin(*args, **kwargs) # pylint: disable=E1101 if hasattr(self, 'init_ganesha_mixin'): # Instance with 'GaneshaMixin' self.init_ganesha_mixin(*args, **kwargs) # pylint: disable=E1101 @property def driver_handles_share_servers(self): if self.configuration: return self.configuration.safe_get('driver_handles_share_servers') return CONF.driver_handles_share_servers def _verify_share_server_handling(self, driver_handles_share_servers): if not isinstance(self.driver_handles_share_servers, bool): raise exception.ManilaException( "Config opt 'driver_handles_share_servers' has improper " "value - '%s'. Please define it as boolean." % self.driver_handles_share_servers) elif isinstance(driver_handles_share_servers, bool): driver_handles_share_servers = [driver_handles_share_servers] elif not isinstance(driver_handles_share_servers, (tuple, list, set)): raise exception.ManilaException( "Improper data provided for 'driver_handles_share_servers' - " "%s" % driver_handles_share_servers) if any(not isinstance(v, bool) for v in driver_handles_share_servers): raise exception.ManilaException( "Provided wrong data: %s" % driver_handles_share_servers) if (self.driver_handles_share_servers not in driver_handles_share_servers): raise exception.ManilaException( "Driver does not support mode 'driver_handles_share_servers=" "%(actual)s'. It can be used only with value '%(allowed)s'." % {'actual': self.driver_handles_share_servers, 'allowed': driver_handles_share_servers}) def migrate_share(self, context, share_ref, host, dest_driver_migration_info): """Is called to perform driver migration. Driver should implement this method if willing to perform migration in an optimized way, useful for when driver understands destination backend. :param context: The 'context.RequestContext' object for the request. :param share_ref: Reference to the share being migrated. :param host: Destination host and its capabilities. :param dest_driver_migration_info: Migration information provided by destination host. :returns: Boolean value indicating if driver migration succeeded. :returns: Dictionary containing a model update. """ return None, None def get_driver_migration_info(self, context, share_instance, share_server): """Is called to provide necessary driver migration logic.""" return None def get_migration_info(self, context, share_instance, share_server): """Is called to provide necessary generic migration logic.""" mount_cmd = self._get_mount_command(context, share_instance, share_server) umount_cmd = self._get_unmount_command(context, share_instance, share_server) access = self._get_access_rule_for_data_copy( context, share_instance, share_server) return {'mount': mount_cmd, 'umount': umount_cmd, 'access': access} def _get_mount_command(self, context, share_instance, share_server): """Is called to delegate mounting share logic.""" mount_cmd = self._get_mount_command_protocol(share_instance, share_server) mount_ip = self._get_mount_ip(share_instance, share_server) mount_cmd.append(mount_ip) mount_path = self.configuration.safe_get( 'migration_tmp_location') + share_instance['id'] mount_cmd.append(mount_path) return mount_cmd def _get_mount_command_protocol(self, share_instance, share_server): mount_cmd = self.configuration.safe_get( 'migration_protocol_mount_command') if mount_cmd: return mount_cmd.split() else: return ['mount', '-t', share_instance['share_proto'].lower()] def _get_mount_ip(self, share_instance, share_server): # Note(ganso): DHSS = true drivers may need to override this method # and use information saved in share_server structure. mount_ip = self.configuration.safe_get('migration_mounting_backend_ip') old_ip = share_instance['export_locations'][0]['path'] if mount_ip: # NOTE(ganso): Does not currently work with hostnames and ipv6. p = re.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}") new_ip = p.sub(mount_ip, old_ip) return new_ip else: return old_ip def _get_unmount_command(self, context, share_instance, share_server): return ['umount', self.configuration.safe_get('migration_tmp_location') + share_instance['id']] def _get_access_rule_for_data_copy( self, context, share_instance, share_server): """Is called to obtain access rule so data copy node can mount.""" # Note(ganso): The current method implementation is intended to work # with Data Copy Service approach. If Manila Node is used for copying, # then DHSS = true drivers may need to override this method. service_ip = self.configuration.safe_get('migration_data_copy_node_ip') return {'access_type': 'ip', 'access_level': 'rw', 'access_to': service_ip} def copy_share_data(self, context, helper, share, share_instance, share_server, new_share_instance, new_share_server, migration_info_src, migration_info_dest): # NOTE(ganso): This method is here because it is debatable if it can # be overridden by a driver or not. Personally I think it should not, # else it would be possible to lose compatibility with generic # migration between backends, but allows the driver to use it on its # own implementation if it wants to. migrated = False mount_path = self.configuration.safe_get('migration_tmp_location') src_access = migration_info_src['access'] dest_access = migration_info_dest['access'] if None in (src_access['access_to'], dest_access['access_to']): msg = _("Access rules not appropriate for mounting share instances" " for migration of share %(share_id)s," " source share access: %(src_ip)s, destination share" " access: %(dest_ip)s. Aborting.") % { 'src_ip': src_access['access_to'], 'dest_ip': dest_access['access_to'], 'share_id': share['id']} raise exception.ShareMigrationFailed(reason=msg) # NOTE(ganso): Removing any previously conflicting access rules, which # would cause the following access_allow to fail for one instance. helper.deny_migration_access(None, src_access, False) helper.deny_migration_access(None, dest_access, False) # NOTE(ganso): I would rather allow access to instances separately, # but I require an access_id since it is a new access rule and # destination manager must receive an access_id. I can either move # this code to manager code so I can create the rule in DB manually, # or ignore duplicate access rule errors for some specific scenarios. try: src_access_ref = helper.allow_migration_access(src_access) except Exception as e: LOG.error(_LE("Share migration failed attempting to allow " "access of %(access_to)s to share " "instance %(instance_id)s.") % { 'access_to': src_access['access_to'], 'instance_id': share_instance['id']}) msg = six.text_type(e) LOG.exception(msg) raise exception.ShareMigrationFailed(reason=msg) try: dest_access_ref = helper.allow_migration_access(dest_access) except Exception as e: LOG.error(_LE("Share migration failed attempting to allow " "access of %(access_to)s to share " "instance %(instance_id)s.") % { 'access_to': dest_access['access_to'], 'instance_id': new_share_instance['id']}) msg = six.text_type(e) LOG.exception(msg) helper.cleanup_migration_access(src_access_ref, src_access) raise exception.ShareMigrationFailed(reason=msg) # NOTE(ganso): From here we have the possibility of not cleaning # anything when facing an error. At this moment, we have the # destination instance in "inactive" state, while we are performing # operations on the source instance. I think it is best to not clean # the instance, leave it in "inactive" state, but try to clean # temporary access rules, mounts, folders, etc, since no additional # harm is done. def _mount_for_migration(migration_info): try: utils.execute(*migration_info['mount'], run_as_root=True) except Exception: LOG.error(_LE("Failed to mount temporary folder for " "migration of share instance " "%(share_instance_id)s " "to %(new_share_instance_id)s") % { 'share_instance_id': share_instance['id'], 'new_share_instance_id': new_share_instance['id']}) helper.cleanup_migration_access( src_access_ref, src_access) helper.cleanup_migration_access( dest_access_ref, dest_access) raise utils.execute('mkdir', '-p', ''.join((mount_path, share_instance['id']))) utils.execute('mkdir', '-p', ''.join((mount_path, new_share_instance['id']))) # NOTE(ganso): mkdir command sometimes returns faster than it # actually runs, so we better sleep for 1 second. time.sleep(1) try: _mount_for_migration(migration_info_src) except Exception as e: LOG.error(_LE("Share migration failed attempting to mount " "share instance %s.") % share_instance['id']) msg = six.text_type(e) LOG.exception(msg) helper.cleanup_temp_folder(share_instance, mount_path) helper.cleanup_temp_folder(new_share_instance, mount_path) raise exception.ShareMigrationFailed(reason=msg) try: _mount_for_migration(migration_info_dest) except Exception as e: LOG.error(_LE("Share migration failed attempting to mount " "share instance %s.") % new_share_instance['id']) msg = six.text_type(e) LOG.exception(msg) helper.cleanup_unmount_temp_folder(share_instance, migration_info_src) helper.cleanup_temp_folder(share_instance, mount_path) helper.cleanup_temp_folder(new_share_instance, mount_path) raise exception.ShareMigrationFailed(reason=msg) try: ignore_list = self.configuration.safe_get('migration_ignore_files') copy = share_utils.Copy(mount_path + share_instance['id'], mount_path + new_share_instance['id'], ignore_list) copy.run() if copy.get_progress()['total_progress'] == 100: migrated = True except Exception as e: LOG.exception(six.text_type(e)) LOG.error(_LE("Failed to copy files for " "migration of share instance %(share_instance_id)s " "to %(new_share_instance_id)s") % { 'share_instance_id': share_instance['id'], 'new_share_instance_id': new_share_instance['id']}) # NOTE(ganso): For some reason I frequently get AMQP errors after # copying finishes, which seems like is the service taking too long to # copy while not replying heartbeat messages, so AMQP closes the # socket. There is no impact, it just shows a big trace and AMQP # reconnects after, although I would like to prevent this situation # without the use of additional threads. Suggestions welcome. utils.execute(*migration_info_src['umount'], run_as_root=True) utils.execute(*migration_info_dest['umount'], run_as_root=True) utils.execute('rmdir', ''.join((mount_path, share_instance['id'])), check_exit_code=False) utils.execute('rmdir', ''.join((mount_path, new_share_instance['id'])), check_exit_code=False) helper.deny_migration_access(src_access_ref, src_access) helper.deny_migration_access(dest_access_ref, dest_access) if not migrated: msg = ("Copying from share instance %(instance_id)s " "to %(new_instance_id)s did not succeed." % { 'instance_id': share_instance['id'], 'new_instance_id': new_share_instance['id']}) raise exception.ShareMigrationFailed(reason=msg) LOG.debug("Copying completed in migration for share %s." % share['id']) def create_share(self, context, share, share_server=None): """Is called to create share.""" raise NotImplementedError() def create_share_from_snapshot(self, context, share, snapshot, share_server=None): """Is called to create share from snapshot.""" raise NotImplementedError() def create_snapshot(self, context, snapshot, share_server=None): """Is called to create snapshot. :param context: Current context :param snapshot: Snapshot model. Share model could be retrieved through snapshot['share']. :param share_server: Share server model or None. """ raise NotImplementedError() def delete_share(self, context, share, share_server=None): """Is called to remove share.""" raise NotImplementedError() def delete_snapshot(self, context, snapshot, share_server=None): """Is called to remove snapshot. :param context: Current context :param snapshot: Snapshot model. Share model could be retrieved through snapshot['share']. :param share_server: Share server model or None. """ raise NotImplementedError() def get_pool(self, share): """Return pool name where the share resides on. :param share: The share hosted by the driver. """ def ensure_share(self, context, share, share_server=None): """Invoked to ensure that share is exported. Driver can use this method to update the list of export locations of the share if it changes. To do that, you should return list with export locations. :return None or list with export locations """ raise NotImplementedError() def allow_access(self, context, share, access, share_server=None): """Allow access to the share.""" raise NotImplementedError() def deny_access(self, context, share, access, share_server=None): """Deny access to the share.""" raise NotImplementedError() def check_for_setup_error(self): """Check for setup error.""" max_ratio = self.configuration.safe_get('max_over_subscription_ratio') if not max_ratio or float(max_ratio) < 1.0: msg = (_("Invalid max_over_subscription_ratio '%s'. " "Valid value should be >= 1.0.") % max_ratio) raise exception.InvalidParameterValue(err=msg) def do_setup(self, context): """Any initialization the share driver does while starting.""" def get_share_stats(self, refresh=False): """Get share status. If 'refresh' is True, run update the stats first. """ if refresh: self._update_share_stats() return self._stats def get_network_allocations_number(self): """Returns number of network allocations for creating VIFs. Drivers that use Nova for share servers should return zero (0) here same as Generic driver does. Because Nova will handle network resources allocation. Drivers that handle networking itself should calculate it according to their own requirements. It can have 1+ network interfaces. """ raise NotImplementedError() def allocate_network(self, context, share_server, share_network, count=None, **kwargs): """Allocate network resources using given network information.""" if count is None: count = self.get_network_allocations_number() if count: kwargs.update(count=count) self.network_api.allocate_network( context, share_server, share_network, **kwargs) def deallocate_network(self, context, share_server_id): """Deallocate network resources for the given share server.""" if self.get_network_allocations_number(): self.network_api.deallocate_network(context, share_server_id) def choose_share_server_compatible_with_share(self, context, share_servers, share, snapshot=None, consistency_group=None): """Method that allows driver to choose share server for provided share. If compatible share-server is not found, method should return None. :param context: Current context :param share_servers: list with share-server models :param share: share model :param snapshot: snapshot model :param consistency_group: ConsistencyGroup model with shares :returns: share-server or None """ # If creating in a consistency group, use its share server if consistency_group: for share_server in share_servers: if (consistency_group.get('share_server_id') == share_server['id']): return share_server return None return share_servers[0] if share_servers else None def choose_share_server_compatible_with_cg(self, context, share_servers, cg_ref, cgsnapshot=None): return share_servers[0] if share_servers else None def setup_server(self, *args, **kwargs): if self.driver_handles_share_servers: return self._setup_server(*args, **kwargs) else: LOG.debug( "Skipping step 'setup share server', because driver is " "enabled with mode when Manila does not handle share servers.") def _setup_server(self, network_info, metadata=None): """Sets up and configures share server with given network parameters. Redefine it within share driver when it is going to handle share servers. """ raise NotImplementedError() def manage_existing(self, share, driver_options): """Brings an existing share under Manila management. If provided share is not valid, then raise a ManageInvalidShare exception, specifying a reason for the failure. The share has a share_type, and the driver can inspect that and compare against the properties of the referenced backend share. If they are incompatible, raise a ManageExistingShareTypeMismatch, specifying a reason for the failure. :param share: Share model :param driver_options: Driver-specific options provided by admin. :return: share_update dictionary with required key 'size', which should contain size of the share. """ raise NotImplementedError() def unmanage(self, share): """Removes the specified share from Manila management. Does not delete the underlying backend share. For most drivers, this will not need to do anything. However, some drivers might use this call as an opportunity to clean up any Manila-specific configuration that they have associated with the backend share. If provided share cannot be unmanaged, then raise an UnmanageInvalidShare exception, specifying a reason for the failure. """ def extend_share(self, share, new_size, share_server=None): """Extends size of existing share. :param share: Share model :param new_size: New size of share (new_size > share['size']) :param share_server: Optional -- Share server model """ raise NotImplementedError() def shrink_share(self, share, new_size, share_server=None): """Shrinks size of existing share. If consumed space on share larger than new_size driver should raise ShareShrinkingPossibleDataLoss exception: raise ShareShrinkingPossibleDataLoss(share_id=share['id']) :param share: Share model :param new_size: New size of share (new_size < share['size']) :param share_server: Optional -- Share server model :raises ShareShrinkingPossibleDataLoss, NotImplementedError """ raise NotImplementedError() def teardown_server(self, *args, **kwargs): if self.driver_handles_share_servers: return self._teardown_server(*args, **kwargs) else: LOG.debug( "Skipping step 'teardown share server', because driver is " "enabled with mode when Manila does not handle share servers.") def _teardown_server(self, server_details, security_services=None): """Tears down share server. Redefine it within share driver when it is going to handle share servers. """ raise NotImplementedError() def _has_redefined_driver_methods(self, methods): """Returns boolean as a result of methods presence and redefinition.""" if not isinstance(methods, (set, list, tuple)): methods = (methods, ) for method_name in methods: method = getattr(type(self), method_name, None) if (not method or method == getattr(ShareDriver, method_name)): return False return True @property def snapshots_are_supported(self): if not hasattr(self, '_snapshots_are_supported'): methods = ( "create_snapshot", "delete_snapshot", "create_share_from_snapshot") # NOTE(vponomaryov): calculate default value for # stat 'snapshot_support' based on implementation of # appropriate methods of this base driver class. self._snapshots_are_supported = self._has_redefined_driver_methods( methods) return self._snapshots_are_supported def _update_share_stats(self, data=None): """Retrieve stats info from share group. :param data: dict -- dict with key-value pairs to redefine common ones. """ LOG.debug("Updating share stats.") backend_name = (self.configuration.safe_get('share_backend_name') or CONF.share_backend_name) # Note(zhiteng): These information are driver/backend specific, # each driver may define these values in its own config options # or fetch from driver specific configuration file. common = dict( share_backend_name=backend_name or 'Generic_NFS', driver_handles_share_servers=self.driver_handles_share_servers, vendor_name='Open Source', driver_version='1.0', storage_protocol=None, total_capacity_gb='unknown', free_capacity_gb='unknown', reserved_percentage=0, QoS_support=False, pools=self.pools or None, snapshot_support=self.snapshots_are_supported, ) if isinstance(data, dict): common.update(data) self._stats = common def get_share_server_pools(self, share_server): """Return list of pools related to a particular share server. :param share_server: ShareServer class instance. """ return [] def create_consistency_group(self, context, cg_dict, share_server=None): """Create a consistency group. :param context: :param cg_dict: The consistency group details EXAMPLE: { 'status': 'creating', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 15, 14, 6), 'updated_at': None, 'source_cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'host': 'openstack2@cmodeSSVMNFS', 'deleted_at': None, 'share_types': [<models.ConsistencyGroupShareTypeMapping>], 'id': 'eda52174-0442-476d-9694-a58327466c14', 'name': None } :returns: (cg_model_update, share_update_list) cg_model_update - a dict containing any values to be updated for the CG in the database. This value may be None. """ raise NotImplementedError() def create_consistency_group_from_cgsnapshot(self, context, cg_dict, cgsnapshot_dict, share_server=None): """Create a consistency group from a cgsnapshot. :param context: :param cg_dict: The consistency group details EXAMPLE: .. code:: { 'status': 'creating', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 15, 14, 6), 'updated_at': None, 'source_cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'host': 'openstack2@cmodeSSVMNFS', 'deleted_at': None, 'shares': [<models.Share>], # The new shares being created 'share_types': [<models.ConsistencyGroupShareTypeMapping>], 'id': 'eda52174-0442-476d-9694-a58327466c14', 'name': None } :param cgsnapshot_dict: The cgsnapshot details EXAMPLE: .. code:: { 'status': 'available', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': '0', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'consistency_group_id': '4b04fdc3-00b9-4909-ba1a-06e9b3f88b67', 'cgsnapshot_members': [ { 'status': 'available', 'share_type_id': '1a9ed31e-ee70-483d-93ba-89690e028d7f', 'user_id': 'a0314a441ca842019b0952224aa39192', 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share': <models.Share>, 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share_proto': 'NFS', 'project_id': '13c0be6290934bd98596cfa004650049', 'cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'deleted_at': None, 'id': '6813e06b-a8f5-4784-b17d-f3e91afa370e', 'size': 1 } ], 'deleted_at': None, 'id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'name': None } :return: (cg_model_update, share_update_list) cg_model_update - a dict containing any values to be updated for the CG in the database. This value may be None. share_update_list - a list of dictionaries containing dicts for every share created in the CG. Any share dicts should at a minimum contain the 'id' key and 'export_locations'. Export locations should be in the same format as returned by a share_create. This list may be empty or None. EXAMPLE: .. code:: [{'id': 'uuid', 'export_locations': ['export_path']}] """ raise NotImplementedError() def delete_consistency_group(self, context, cg_dict, share_server=None): """Delete a consistency group :param context: The request context :param cg_dict: The consistency group details EXAMPLE: .. code:: { 'status': 'creating', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 15, 14, 6), 'updated_at': None, 'source_cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'host': 'openstack2@cmodeSSVMNFS', 'deleted_at': None, 'shares': [<models.Share>], # The new shares being created 'share_types': [<models.ConsistencyGroupShareTypeMapping>], 'id': 'eda52174-0442-476d-9694-a58327466c14', 'name': None } :return: cg_model_update cg_model_update - a dict containing any values to be updated for the CG in the database. This value may be None. """ raise NotImplementedError() def create_cgsnapshot(self, context, snap_dict, share_server=None): """Create a consistency group snapshot. :param context: :param snap_dict: The cgsnapshot details EXAMPLE: .. code:: { 'status': 'available', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': '0', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'consistency_group_id': '4b04fdc3-00b9-4909-ba1a-06e9b3f88b67', 'cgsnapshot_members': [ { 'status': 'available', 'share_type_id': '1a9ed31e-ee70-483d-93ba-89690e028d7f', 'user_id': 'a0314a441ca842019b0952224aa39192', 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share': <models.Share>, 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share_proto': 'NFS', 'project_id': '13c0be6290934bd98596cfa004650049', 'cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'deleted_at': None, 'id': '6813e06b-a8f5-4784-b17d-f3e91afa370e', 'size': 1 } ], 'deleted_at': None, 'id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'name': None } :return: (cgsnapshot_update, member_update_list) cgsnapshot_update - a dict containing any values to be updated for the CGSnapshot in the database. This value may be None. member_update_list - a list of dictionaries containing for every member of the cgsnapshot. Each dict should contains values to be updated for teh CGSnapshotMember in the database. This list may be empty or None. """ raise NotImplementedError() def delete_cgsnapshot(self, context, snap_dict, share_server=None): """Delete a consistency group snapshot :param context: :param snap_dict: The cgsnapshot details EXAMPLE: .. code:: { 'status': 'available', 'project_id': '13c0be6290934bd98596cfa004650049', 'user_id': 'a0314a441ca842019b0952224aa39192', 'description': None, 'deleted': '0', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'consistency_group_id': '4b04fdc3-00b9-4909-ba1a-06e9b3f88b67', 'cgsnapshot_members': [ { 'status': 'available', 'share_type_id': '1a9ed31e-ee70-483d-93ba-89690e028d7f', 'share_id': 'e14b5174-e534-4f35-bc4f-fe81c1575d6f', 'user_id': 'a0314a441ca842019b0952224aa39192', 'deleted': 'False', 'created_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share': <models.Share>, 'updated_at': datetime.datetime(2015, 8, 10, 0, 5, 58), 'share_proto': 'NFS', 'project_id': '13c0be6290934bd98596cfa004650049', 'cgsnapshot_id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'deleted_at': None, 'id': '6813e06b-a8f5-4784-b17d-f3e91afa370e', 'size': 1 } ], 'deleted_at': None, 'id': 'f6aa3b59-57eb-421e-965c-4e182538e36a', 'name': None } :return: (cgsnapshot_update, member_update_list) cgsnapshot_update - a dict containing any values to be updated for the CGSnapshot in the database. This value may be None. """ raise NotImplementedError() def get_periodic_hook_data(self, context, share_instances): """Dedicated for update/extend of data for existing share instances. Redefine this method in share driver to be able to update/change/extend share instances data that will be used by periodic hook action. One of possible updates is add-on of "automount" CLI commands for each share instance for case of notification is enabled using 'hook' approach. :param context: Current context :param share_instances: share instances list provided by share manager :return: list of share instances. """ return share_instances
redhat-openstack/manila
manila/share/driver.py
Python
apache-2.0
45,808
from django.db import models from django.contrib.auth.models import User from albaproject.settings import MEDIA_ROOT import pdb def _upload_to_generic(prefix_path=None, instance=None, field=None, filename=None): #pdb.set_trace() if not instance.pk: # generate DB PK if not present instance.save() if not prefix_path: if not filename: return '{0}/job_{1}/{2}'.format(instance.user.username, instance.pk, field) return '{0}/job_{1}/{2}/{3}'.format(instance.user.username, instance.pk, field, filename) return '{0}/{1}/job_{2}/{3}'.format(prefix_path, instance.user.username, instance.pk, field) class Job(models.Model): def __unicode__(self): return str(self.id) def save(self, *args, **kwargs): #pdb.set_trace() _input = self.file_input _job = self.mapred_job _output = self.file_output self.file_input = None self.mapred_job = None self.file_output = None super(Job, self).save(*args,**kwargs) self.save = super(Job, self).save self.file_input = _input self.mapred_job = _job self.file_output = _output self.save() #super.save def input_dest(self, filename): return _upload_to_generic(None, self, 'input', filename) def mapred_dest(self, filename): return _upload_to_generic(None, self, 'mapred', filename) def output_dest(self, filename): return _upload_to_generic(None, self, 'output', filename) def output_path(self): return _upload_to_generic(MEDIA_ROOT, self, 'output', None) user = models.ForeignKey(User) file_input = models.FileField(upload_to=input_dest, null=True) mapred_job = models.FileField(upload_to=mapred_dest, null=True) fully_qualified_job_impl_class = models.CharField(max_length=200, null=True) file_output = models.FileField(upload_to=output_dest, null=True) submission_date = models.DateTimeField(auto_now_add=True) class Server(models.Model): job = models.ForeignKey(Job) openstack_id = models.CharField(max_length=200) server_name = models.CharField(max_length=200) vcpus = models.PositiveSmallIntegerField() ram = models.PositiveIntegerField() disk = models.PositiveIntegerField()
marcos-sb/quick-openstacked-hadoop
Alba/albaproject/mapred/models.py
Python
apache-2.0
2,416
# Simple example of reading the MCP3008 analog input channels and printing import time import sys import numpy as np # Import SPI library (for hardware SPI) and MCP3008 library. import Adafruit_GPIO.SPI as SPI import Adafruit_MCP3008 import RPi.GPIO as GPIO import spidev # Software SPI configuration: #CLK = 18 #MISO = 23 #MOSI = 24 #CS = 25 #mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI) # Hardware SPI configuration: SPI_PORT = 0 SPI_DEVICE = 0 mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE)) # Choose channel an_chan = 3 # channel 8 (numbered 0-7) # choose GPIO pin ledPin = 18 GPIO.setmode(GPIO.BCM) GPIO.setup(ledPin,GPIO.OUT) samplingTime = 280.0 deltaTime = 40.0 sleepTime = 9680.0 directions = {'N':3.84,'NNE':1.98,'NE':2.25,'ENE':0.41,'E':0.45,'ESE':0.32,'SE':0.90,'SSE':0.62,'S':1.40,'SSW':1.19,'SW':3.08,'WSW':2.93,'W':4.62,'WNW':4.04,'NW':4.78,'NNW':3.43} directions = dict((v,k) for k,v in directions.iteritems()) d = [3.84,1.98,2.25,0.41,0.45,0.32,0.90,0.62,1.40,1.19,3.08,2.93,4.62,4.04,4.78,3.43] sortd = np.sort(d) #print sortd midp = (sortd[1:]+sortd[:-1])/2 midp = np.insert(midp,0,0) midp = np.insert(midp,len(midp),5.0) print midp #for i in range(0,len(sortd)): # print directions.get(sortd[i]) # Main program loop. try: while True: GPIO.output(ledPin,0) time.sleep(samplingTime*10.0**-6) # The read_adc function will get the value of the specified channel voMeasured = mcp.read_adc(an_chan) time.sleep(deltaTime*10.0**-6) GPIO.output(ledPin,1) time.sleep(sleepTime*10.0**-66) calcVoltage = voMeasured*(5.0/1024) c = round(calcVoltage,2) print c for i in range(1,len(midp)-1): b = midp[i-1] en = midp[i+1] if c > 3.90 and c < 3.95: direction = 4.78 break elif c > b and c < en: direction = sortd[i] break #dustDensity = 0.17*calcVoltage-0.1 #if dustDensity < 0: # dustDensity = 0.00 # Print the ADC values. print "Raw signal value (0 - 1023): ", voMeasured print "Voltage: ", c, direction, directions.get(direction) #print "Dust Density: ", dustDensity time.sleep(1) except KeyboardInterrupt: GPIO.cleanup()
opendatadurban/citizen_sensors
Weather_Station/test_wind_dir.py
Python
apache-2.0
2,418
from JumpScale import j from Sheet import * class Sheets(j.tools.code.classGetBase()): def __init__(self): self.__jslocation__ = "j.tools.worksheets" self.sheets = {} self.sheetsByCategory = {} self.sheetNames = [] def new(self, name, nrcols=72, headers=[], category=None): sheet = Sheet(name, nrcols=nrcols, headers=headers) self.add(sheet, category) return sheet def add(self, sheet, category=None): self.sheets[sheet.name] = sheet if category is not None: if category not in self.sheetsByCategory: self.sheetsByCategory[category] = [] self.sheetsByCategory[category].append(sheet.name) self.sheetNames.append(sheet.name) def dict2sheet(self, data): sheet = Sheet("", nrmonths=72, headers=[]) sheet.dict2obj(data) return sheet def aggregateSheets(self, sheetnames, rowdescr, category, aggregateSheetName="Total", aggregation={}): """ @param sheetnames are the sheets to aggregate @param rowdescr {groupname:[rownames,...]} """ sheettotal = self.new(name=aggregateSheetName, category=category) sheettotal.description = "sheet aggregation of %s" % category sheettotal.addRows(rowdescr, aggregation) sheets = [] for name in sheetnames: sheets.append(self.sheets[name]) for group in list(rowdescr.keys()): rownames = rowdescr[group] for rowname in rownames: for x in range(0, sheettotal.nrcols): rowdest = sheettotal.rows[rowname] sumvalue = 0.0 for sheet in sheets: if sheet.rows[rowname].cells[x] is None: raise j.exceptions.RuntimeError( "could not aggregate sheet%s row:%s, found None value" % (sheet.name, rowname)) sumvalue += sheet.rows[rowname].cells[x] rowdest.cells[x] = sumvalue return sheettotal def applyFunction(self, rows, method, rowDest=None, params={}): """ @param rows is array if of rows we would like to use as inputvalues @param rowDest if empty will be same as first row @param method is python function with params (values,params) values are inputvalues from the rows """ if rowDest == "": rowDest = rows[0] for colnr in range(rowDest.nrcols): input = [] for row in rows: val = row.cells[colnr] if val is None: val = 0.0 input.append(val) rowDest.cells[colnr] = method(input, params) return rowDest def sumRows(self, rows, newRow): """ make sum of rows @param rows is list of rows to add @param newRow is the row where the result will be stored """ def sum(values, params): total = 0.0 for value in values: total += value return total rows2 = [] for row in rows: if row is not None: rows2.append(row) newRow = self.applyFunction(rows2, sum, newRow) return newRow def multiplyRows(self, rows, newRow): def mult(values, params): total = 1.0 for value in values: total = total * value return total rows2 = [] for row in rows: if row is not None: rows2.append(row) newRow = self.applyFunction(rows2, mult, newRow) return newRow
Jumpscale/jumpscale_core8
lib/JumpScale/tools/worksheets/Sheets.py
Python
apache-2.0
3,721
# Copyright 2019 The dm_control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ """Composer models of Kinova robots.""" from dm_control.entities.manipulators.kinova.jaco_arm import JacoArm from dm_control.entities.manipulators.kinova.jaco_hand import JacoHand
deepmind/dm_control
dm_control/entities/manipulators/kinova/__init__.py
Python
apache-2.0
848
import os import json from PySide2 import QtCore from opencmiss.zinc.context import Context from opencmiss.zinc.material import Material from mapclientplugins.meshgeneratorstep.model.meshgeneratormodel import MeshGeneratorModel from mapclientplugins.meshgeneratorstep.model.meshannotationmodel import MeshAnnotationModel from mapclientplugins.meshgeneratorstep.model.segmentationdatamodel import SegmentationDataModel from scaffoldmaker.scaffolds import Scaffolds_decodeJSON, Scaffolds_JSONEncoder class MasterModel(object): def __init__(self, location, identifier): self._location = location self._identifier = identifier self._filenameStem = os.path.join(self._location, self._identifier) self._context = Context("MeshGenerator") self._timekeeper = self._context.getTimekeepermodule().getDefaultTimekeeper() self._timer = QtCore.QTimer() self._current_time = 0.0 self._timeValueUpdate = None self._frameIndexUpdate = None self._initialise() self._region = self._context.createRegion() self._generator_model = MeshGeneratorModel(self._context, self._region, self._materialmodule) self._segmentation_data_model = SegmentationDataModel(self._region, self._materialmodule) self._annotation_model = MeshAnnotationModel() self._settings = { 'segmentation_data_settings' : self._segmentation_data_model.getSettings() } self._makeConnections() # self._loadSettings() def printLog(self): logger = self._context.getLogger() for index in range(logger.getNumberOfMessages()): print(logger.getMessageTextAtIndex(index)) def _initialise(self): self._filenameStem = os.path.join(self._location, self._identifier) tess = self._context.getTessellationmodule().getDefaultTessellation() tess.setRefinementFactors(12) # set up standard materials and glyphs so we can use them elsewhere self._materialmodule = self._context.getMaterialmodule() self._materialmodule.defineStandardMaterials() solid_blue = self._materialmodule.createMaterial() solid_blue.setName('solid_blue') solid_blue.setManaged(True) solid_blue.setAttributeReal3(Material.ATTRIBUTE_AMBIENT, [ 0.0, 0.2, 0.6 ]) solid_blue.setAttributeReal3(Material.ATTRIBUTE_DIFFUSE, [ 0.0, 0.7, 1.0 ]) solid_blue.setAttributeReal3(Material.ATTRIBUTE_EMISSION, [ 0.0, 0.0, 0.0 ]) solid_blue.setAttributeReal3(Material.ATTRIBUTE_SPECULAR, [ 0.1, 0.1, 0.1 ]) solid_blue.setAttributeReal(Material.ATTRIBUTE_SHININESS , 0.2) trans_blue = self._materialmodule.createMaterial() trans_blue.setName('trans_blue') trans_blue.setManaged(True) trans_blue.setAttributeReal3(Material.ATTRIBUTE_AMBIENT, [ 0.0, 0.2, 0.6 ]) trans_blue.setAttributeReal3(Material.ATTRIBUTE_DIFFUSE, [ 0.0, 0.7, 1.0 ]) trans_blue.setAttributeReal3(Material.ATTRIBUTE_EMISSION, [ 0.0, 0.0, 0.0 ]) trans_blue.setAttributeReal3(Material.ATTRIBUTE_SPECULAR, [ 0.1, 0.1, 0.1 ]) trans_blue.setAttributeReal(Material.ATTRIBUTE_ALPHA , 0.3) trans_blue.setAttributeReal(Material.ATTRIBUTE_SHININESS , 0.2) glyphmodule = self._context.getGlyphmodule() glyphmodule.defineStandardGlyphs() def _makeConnections(self): pass def getIdentifier(self): return self._identifier def getOutputModelFilename(self): return self._filenameStem + '.exf' def getGeneratorModel(self): return self._generator_model def getMeshAnnotationModel(self): return self._annotation_model def getSegmentationDataModel(self): return self._segmentation_data_model def getScene(self): return self._region.getScene() def getContext(self): return self._context def registerSceneChangeCallback(self, sceneChangeCallback): self._generator_model.registerSceneChangeCallback(sceneChangeCallback) def done(self): self._saveSettings() self._generator_model.done() self._generator_model.writeModel(self.getOutputModelFilename()) self._generator_model.writeAnnotations(self._filenameStem) self._generator_model.exportToVtk(self._filenameStem) def _getSettings(self): ''' Ensures master model settings includes current settings for sub models. :return: Master setting dict. ''' settings = self._settings settings['generator_settings'] = self._generator_model.getSettings() settings['segmentation_data_settings'] = self._segmentation_data_model.getSettings() return settings def loadSettings(self): try: settings = self._settings with open(self._filenameStem + '-settings.json', 'r') as f: savedSettings = json.loads(f.read(), object_hook=Scaffolds_decodeJSON) settings.update(savedSettings) if not 'generator_settings' in settings: # migrate from old settings before named generator_settings settings = {'generator_settings': settings} except: # no settings saved yet, following gets defaults settings = self._getSettings() self._generator_model.setSettings(settings['generator_settings']) self._segmentation_data_model.setSettings(settings['segmentation_data_settings']) self._annotation_model.setScaffoldTypeByName(self._generator_model.getEditScaffoldTypeName()) self._getSettings() def _saveSettings(self): self._generator_model.updateSettingsBeforeWrite() settings = self._getSettings() with open(self._filenameStem + '-settings.json', 'w') as f: f.write(json.dumps(settings, cls=Scaffolds_JSONEncoder, sort_keys=True, indent=4)) def setSegmentationDataFile(self, data_filename): self._segmentation_data_model.setDataFilename(data_filename)
rchristie/mapclientplugins.meshgeneratorstep
mapclientplugins/meshgeneratorstep/model/mastermodel.py
Python
apache-2.0
6,058
from django.contrib.auth.models import User from django.test import TestCase from dcim.choices import * from dcim.filters import * from dcim.models import ( Cable, ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay, DeviceBayTemplate, DeviceRole, DeviceType, FrontPort, FrontPortTemplate, Interface, InterfaceTemplate, InventoryItem, Manufacturer, Platform, PowerFeed, PowerPanel, PowerPort, PowerPortTemplate, PowerOutlet, PowerOutletTemplate, Rack, RackGroup, RackReservation, RackRole, RearPort, RearPortTemplate, Region, Site, VirtualChassis, ) from ipam.models import IPAddress from tenancy.models import Tenant, TenantGroup from virtualization.models import Cluster, ClusterType class RegionTestCase(TestCase): queryset = Region.objects.all() filterset = RegionFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1', description='A'), Region(name='Region 2', slug='region-2', description='B'), Region(name='Region 3', slug='region-3', description='C'), ) for region in regions: region.save() child_regions = ( Region(name='Region 1A', slug='region-1a', parent=regions[0]), Region(name='Region 1B', slug='region-1b', parent=regions[0]), Region(name='Region 2A', slug='region-2a', parent=regions[1]), Region(name='Region 2B', slug='region-2b', parent=regions[1]), Region(name='Region 3A', slug='region-3a', parent=regions[2]), Region(name='Region 3B', slug='region-3b', parent=regions[2]), ) for region in child_regions: region.save() def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Region 1', 'Region 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['region-1', 'region-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_parent(self): parent_regions = Region.objects.filter(parent__isnull=True)[:2] params = {'parent_id': [parent_regions[0].pk, parent_regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'parent': [parent_regions[0].slug, parent_regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) class SiteTestCase(TestCase): queryset = Site.objects.all() filterset = SiteFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() tenant_groups = ( TenantGroup(name='Tenant group 1', slug='tenant-group-1'), TenantGroup(name='Tenant group 2', slug='tenant-group-2'), TenantGroup(name='Tenant group 3', slug='tenant-group-3'), ) for tenantgroup in tenant_groups: tenantgroup.save() tenants = ( Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]), Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]), Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]), ) Tenant.objects.bulk_create(tenants) sites = ( Site(name='Site 1', slug='site-1', region=regions[0], tenant=tenants[0], status=SiteStatusChoices.STATUS_ACTIVE, facility='Facility 1', asn=65001, latitude=10, longitude=10, contact_name='Contact 1', contact_phone='123-555-0001', contact_email='contact1@example.com'), Site(name='Site 2', slug='site-2', region=regions[1], tenant=tenants[1], status=SiteStatusChoices.STATUS_PLANNED, facility='Facility 2', asn=65002, latitude=20, longitude=20, contact_name='Contact 2', contact_phone='123-555-0002', contact_email='contact2@example.com'), Site(name='Site 3', slug='site-3', region=regions[2], tenant=tenants[2], status=SiteStatusChoices.STATUS_RETIRED, facility='Facility 3', asn=65003, latitude=30, longitude=30, contact_name='Contact 3', contact_phone='123-555-0003', contact_email='contact3@example.com'), ) Site.objects.bulk_create(sites) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Site 1', 'Site 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['site-1', 'site-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_facility(self): params = {'facility': ['Facility 1', 'Facility 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_asn(self): params = {'asn': [65001, 65002]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_latitude(self): params = {'latitude': [10, 20]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_longitude(self): params = {'longitude': [10, 20]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_contact_name(self): params = {'contact_name': ['Contact 1', 'Contact 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_contact_phone(self): params = {'contact_phone': ['123-555-0001', '123-555-0002']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_contact_email(self): params = {'contact_email': ['contact1@example.com', 'contact2@example.com']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_status(self): params = {'status': [SiteStatusChoices.STATUS_ACTIVE, SiteStatusChoices.STATUS_PLANNED]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant(self): tenants = Tenant.objects.all()[:2] params = {'tenant_id': [tenants[0].pk, tenants[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant': [tenants[0].slug, tenants[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant_group(self): tenant_groups = TenantGroup.objects.all()[:2] params = {'tenant_group_id': [tenant_groups[0].pk, tenant_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant_group': [tenant_groups[0].slug, tenant_groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class RackGroupTestCase(TestCase): queryset = RackGroup.objects.all() filterset = RackGroupFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) parent_rack_groups = ( RackGroup(name='Parent Rack Group 1', slug='parent-rack-group-1', site=sites[0]), RackGroup(name='Parent Rack Group 2', slug='parent-rack-group-2', site=sites[1]), RackGroup(name='Parent Rack Group 3', slug='parent-rack-group-3', site=sites[2]), ) for rackgroup in parent_rack_groups: rackgroup.save() rack_groups = ( RackGroup(name='Rack Group 1', slug='rack-group-1', site=sites[0], parent=parent_rack_groups[0], description='A'), RackGroup(name='Rack Group 2', slug='rack-group-2', site=sites[1], parent=parent_rack_groups[1], description='B'), RackGroup(name='Rack Group 3', slug='rack-group-3', site=sites[2], parent=parent_rack_groups[2], description='C'), ) for rackgroup in rack_groups: rackgroup.save() def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Rack Group 1', 'Rack Group 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['rack-group-1', 'rack-group-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_parent(self): parent_groups = RackGroup.objects.filter(name__startswith='Parent')[:2] params = {'parent_id': [parent_groups[0].pk, parent_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'parent': [parent_groups[0].slug, parent_groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class RackRoleTestCase(TestCase): queryset = RackRole.objects.all() filterset = RackRoleFilterSet @classmethod def setUpTestData(cls): rack_roles = ( RackRole(name='Rack Role 1', slug='rack-role-1', color='ff0000'), RackRole(name='Rack Role 2', slug='rack-role-2', color='00ff00'), RackRole(name='Rack Role 3', slug='rack-role-3', color='0000ff'), ) RackRole.objects.bulk_create(rack_roles) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Rack Role 1', 'Rack Role 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['rack-role-1', 'rack-role-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_color(self): params = {'color': ['ff0000', '00ff00']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class RackTestCase(TestCase): queryset = Rack.objects.all() filterset = RackFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) rack_groups = ( RackGroup(name='Rack Group 1', slug='rack-group-1', site=sites[0]), RackGroup(name='Rack Group 2', slug='rack-group-2', site=sites[1]), RackGroup(name='Rack Group 3', slug='rack-group-3', site=sites[2]), ) for rackgroup in rack_groups: rackgroup.save() rack_roles = ( RackRole(name='Rack Role 1', slug='rack-role-1'), RackRole(name='Rack Role 2', slug='rack-role-2'), RackRole(name='Rack Role 3', slug='rack-role-3'), ) RackRole.objects.bulk_create(rack_roles) tenant_groups = ( TenantGroup(name='Tenant group 1', slug='tenant-group-1'), TenantGroup(name='Tenant group 2', slug='tenant-group-2'), TenantGroup(name='Tenant group 3', slug='tenant-group-3'), ) for tenantgroup in tenant_groups: tenantgroup.save() tenants = ( Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]), Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]), Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]), ) Tenant.objects.bulk_create(tenants) racks = ( Rack(name='Rack 1', facility_id='rack-1', site=sites[0], group=rack_groups[0], tenant=tenants[0], status=RackStatusChoices.STATUS_ACTIVE, role=rack_roles[0], serial='ABC', asset_tag='1001', type=RackTypeChoices.TYPE_2POST, width=RackWidthChoices.WIDTH_19IN, u_height=42, desc_units=False, outer_width=100, outer_depth=100, outer_unit=RackDimensionUnitChoices.UNIT_MILLIMETER), Rack(name='Rack 2', facility_id='rack-2', site=sites[1], group=rack_groups[1], tenant=tenants[1], status=RackStatusChoices.STATUS_PLANNED, role=rack_roles[1], serial='DEF', asset_tag='1002', type=RackTypeChoices.TYPE_4POST, width=RackWidthChoices.WIDTH_21IN, u_height=43, desc_units=False, outer_width=200, outer_depth=200, outer_unit=RackDimensionUnitChoices.UNIT_MILLIMETER), Rack(name='Rack 3', facility_id='rack-3', site=sites[2], group=rack_groups[2], tenant=tenants[2], status=RackStatusChoices.STATUS_RESERVED, role=rack_roles[2], serial='GHI', asset_tag='1003', type=RackTypeChoices.TYPE_CABINET, width=RackWidthChoices.WIDTH_23IN, u_height=44, desc_units=True, outer_width=300, outer_depth=300, outer_unit=RackDimensionUnitChoices.UNIT_INCH), ) Rack.objects.bulk_create(racks) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Rack 1', 'Rack 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_facility_id(self): params = {'facility_id': ['rack-1', 'rack-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_asset_tag(self): params = {'asset_tag': ['1001', '1002']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): params = {'type': [RackTypeChoices.TYPE_2POST, RackTypeChoices.TYPE_4POST]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_width(self): params = {'width': [RackWidthChoices.WIDTH_19IN, RackWidthChoices.WIDTH_21IN]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_u_height(self): params = {'u_height': [42, 43]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_desc_units(self): params = {'desc_units': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'desc_units': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_outer_width(self): params = {'outer_width': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_outer_depth(self): params = {'outer_depth': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_outer_unit(self): self.assertEqual(Rack.objects.filter(outer_unit__isnull=False).count(), 3) params = {'outer_unit': RackDimensionUnitChoices.UNIT_MILLIMETER} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_group(self): groups = RackGroup.objects.all()[:2] params = {'group_id': [groups[0].pk, groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'group': [groups[0].slug, groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_status(self): params = {'status': [RackStatusChoices.STATUS_ACTIVE, RackStatusChoices.STATUS_PLANNED]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_role(self): roles = RackRole.objects.all()[:2] params = {'role_id': [roles[0].pk, roles[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'role': [roles[0].slug, roles[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_serial(self): params = {'serial': 'ABC'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'serial': 'abc'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_tenant(self): tenants = Tenant.objects.all()[:2] params = {'tenant_id': [tenants[0].pk, tenants[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant': [tenants[0].slug, tenants[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant_group(self): tenant_groups = TenantGroup.objects.all()[:2] params = {'tenant_group_id': [tenant_groups[0].pk, tenant_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant_group': [tenant_groups[0].slug, tenant_groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class RackReservationTestCase(TestCase): queryset = RackReservation.objects.all() filterset = RackReservationFilterSet @classmethod def setUpTestData(cls): sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), Site(name='Site 3', slug='site-3'), ) Site.objects.bulk_create(sites) rack_groups = ( RackGroup(name='Rack Group 1', slug='rack-group-1', site=sites[0]), RackGroup(name='Rack Group 2', slug='rack-group-2', site=sites[1]), RackGroup(name='Rack Group 3', slug='rack-group-3', site=sites[2]), ) for rackgroup in rack_groups: rackgroup.save() racks = ( Rack(name='Rack 1', site=sites[0], group=rack_groups[0]), Rack(name='Rack 2', site=sites[1], group=rack_groups[1]), Rack(name='Rack 3', site=sites[2], group=rack_groups[2]), ) Rack.objects.bulk_create(racks) users = ( User(username='User 1'), User(username='User 2'), User(username='User 3'), ) User.objects.bulk_create(users) tenant_groups = ( TenantGroup(name='Tenant group 1', slug='tenant-group-1'), TenantGroup(name='Tenant group 2', slug='tenant-group-2'), TenantGroup(name='Tenant group 3', slug='tenant-group-3'), ) for tenantgroup in tenant_groups: tenantgroup.save() tenants = ( Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]), Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]), Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]), ) Tenant.objects.bulk_create(tenants) reservations = ( RackReservation(rack=racks[0], units=[1, 2, 3], user=users[0], tenant=tenants[0]), RackReservation(rack=racks[1], units=[4, 5, 6], user=users[1], tenant=tenants[1]), RackReservation(rack=racks[2], units=[7, 8, 9], user=users[2], tenant=tenants[2]), ) RackReservation.objects.bulk_create(reservations) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_group(self): groups = RackGroup.objects.all()[:2] params = {'group_id': [groups[0].pk, groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'group': [groups[0].slug, groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_user(self): users = User.objects.all()[:2] params = {'user_id': [users[0].pk, users[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'user': [users[0].username, users[1].username]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant(self): tenants = Tenant.objects.all()[:2] params = {'tenant_id': [tenants[0].pk, tenants[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant': [tenants[0].slug, tenants[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant_group(self): tenant_groups = TenantGroup.objects.all()[:2] params = {'tenant_group_id': [tenant_groups[0].pk, tenant_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant_group': [tenant_groups[0].slug, tenant_groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class ManufacturerTestCase(TestCase): queryset = Manufacturer.objects.all() filterset = ManufacturerFilterSet @classmethod def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1', description='A'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2', description='B'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3', description='C'), ) Manufacturer.objects.bulk_create(manufacturers) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Manufacturer 1', 'Manufacturer 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['manufacturer-1', 'manufacturer-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class DeviceTypeTestCase(TestCase): queryset = DeviceType.objects.all() filterset = DeviceTypeFilterSet @classmethod def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3'), ) Manufacturer.objects.bulk_create(manufacturers) device_types = ( DeviceType(manufacturer=manufacturers[0], model='Model 1', slug='model-1', part_number='Part Number 1', u_height=1, is_full_depth=True), DeviceType(manufacturer=manufacturers[1], model='Model 2', slug='model-2', part_number='Part Number 2', u_height=2, is_full_depth=True, subdevice_role=SubdeviceRoleChoices.ROLE_PARENT), DeviceType(manufacturer=manufacturers[2], model='Model 3', slug='model-3', part_number='Part Number 3', u_height=3, is_full_depth=False, subdevice_role=SubdeviceRoleChoices.ROLE_CHILD), ) DeviceType.objects.bulk_create(device_types) # Add component templates for filtering ConsolePortTemplate.objects.bulk_create(( ConsolePortTemplate(device_type=device_types[0], name='Console Port 1'), ConsolePortTemplate(device_type=device_types[1], name='Console Port 2'), )) ConsoleServerPortTemplate.objects.bulk_create(( ConsoleServerPortTemplate(device_type=device_types[0], name='Console Server Port 1'), ConsoleServerPortTemplate(device_type=device_types[1], name='Console Server Port 2'), )) PowerPortTemplate.objects.bulk_create(( PowerPortTemplate(device_type=device_types[0], name='Power Port 1'), PowerPortTemplate(device_type=device_types[1], name='Power Port 2'), )) PowerOutletTemplate.objects.bulk_create(( PowerOutletTemplate(device_type=device_types[0], name='Power Outlet 1'), PowerOutletTemplate(device_type=device_types[1], name='Power Outlet 2'), )) InterfaceTemplate.objects.bulk_create(( InterfaceTemplate(device_type=device_types[0], name='Interface 1'), InterfaceTemplate(device_type=device_types[1], name='Interface 2'), )) rear_ports = ( RearPortTemplate(device_type=device_types[0], name='Rear Port 1', type=PortTypeChoices.TYPE_8P8C), RearPortTemplate(device_type=device_types[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C), ) RearPortTemplate.objects.bulk_create(rear_ports) FrontPortTemplate.objects.bulk_create(( FrontPortTemplate(device_type=device_types[0], name='Front Port 1', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[0]), FrontPortTemplate(device_type=device_types[1], name='Front Port 2', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[1]), )) DeviceBayTemplate.objects.bulk_create(( DeviceBayTemplate(device_type=device_types[0], name='Device Bay 1'), DeviceBayTemplate(device_type=device_types[1], name='Device Bay 2'), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_model(self): params = {'model': ['Model 1', 'Model 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['model-1', 'model-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_part_number(self): params = {'part_number': ['Part Number 1', 'Part Number 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_u_height(self): params = {'u_height': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_is_full_depth(self): params = {'is_full_depth': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'is_full_depth': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_subdevice_role(self): params = {'subdevice_role': SubdeviceRoleChoices.ROLE_PARENT} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_manufacturer(self): manufacturers = Manufacturer.objects.all()[:2] params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_console_ports(self): params = {'console_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'console_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_console_server_ports(self): params = {'console_server_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'console_server_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_power_ports(self): params = {'power_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'power_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_power_outlets(self): params = {'power_outlets': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'power_outlets': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_interfaces(self): params = {'interfaces': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'interfaces': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_pass_through_ports(self): params = {'pass_through_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'pass_through_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_device_bays(self): params = {'device_bays': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device_bays': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class ConsolePortTemplateTestCase(TestCase): queryset = ConsolePortTemplate.objects.all() filterset = ConsolePortTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) ConsolePortTemplate.objects.bulk_create(( ConsolePortTemplate(device_type=device_types[0], name='Console Port 1'), ConsolePortTemplate(device_type=device_types[1], name='Console Port 2'), ConsolePortTemplate(device_type=device_types[2], name='Console Port 3'), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Console Port 1', 'Console Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class ConsoleServerPortTemplateTestCase(TestCase): queryset = ConsoleServerPortTemplate.objects.all() filterset = ConsoleServerPortTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) ConsoleServerPortTemplate.objects.bulk_create(( ConsoleServerPortTemplate(device_type=device_types[0], name='Console Server Port 1'), ConsoleServerPortTemplate(device_type=device_types[1], name='Console Server Port 2'), ConsoleServerPortTemplate(device_type=device_types[2], name='Console Server Port 3'), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Console Server Port 1', 'Console Server Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class PowerPortTemplateTestCase(TestCase): queryset = PowerPortTemplate.objects.all() filterset = PowerPortTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) PowerPortTemplate.objects.bulk_create(( PowerPortTemplate(device_type=device_types[0], name='Power Port 1', maximum_draw=100, allocated_draw=50), PowerPortTemplate(device_type=device_types[1], name='Power Port 2', maximum_draw=200, allocated_draw=100), PowerPortTemplate(device_type=device_types[2], name='Power Port 3', maximum_draw=300, allocated_draw=150), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Port 1', 'Power Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_maximum_draw(self): params = {'maximum_draw': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_allocated_draw(self): params = {'allocated_draw': [50, 100]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class PowerOutletTemplateTestCase(TestCase): queryset = PowerOutletTemplate.objects.all() filterset = PowerOutletTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) PowerOutletTemplate.objects.bulk_create(( PowerOutletTemplate(device_type=device_types[0], name='Power Outlet 1', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A), PowerOutletTemplate(device_type=device_types[1], name='Power Outlet 2', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_B), PowerOutletTemplate(device_type=device_types[2], name='Power Outlet 3', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_C), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Outlet 1', 'Power Outlet 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_feed_leg(self): # TODO: Support filtering for multiple values params = {'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_A} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class InterfaceTemplateTestCase(TestCase): queryset = InterfaceTemplate.objects.all() filterset = InterfaceTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) InterfaceTemplate.objects.bulk_create(( InterfaceTemplate(device_type=device_types[0], name='Interface 1', type=InterfaceTypeChoices.TYPE_1GE_FIXED, mgmt_only=True), InterfaceTemplate(device_type=device_types[1], name='Interface 2', type=InterfaceTypeChoices.TYPE_1GE_GBIC, mgmt_only=False), InterfaceTemplate(device_type=device_types[2], name='Interface 3', type=InterfaceTypeChoices.TYPE_1GE_SFP, mgmt_only=False), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Interface 1', 'Interface 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): # TODO: Support filtering for multiple values params = {'type': InterfaceTypeChoices.TYPE_1GE_FIXED} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_mgmt_only(self): params = {'mgmt_only': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'mgmt_only': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class FrontPortTemplateTestCase(TestCase): queryset = FrontPortTemplate.objects.all() filterset = FrontPortTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) rear_ports = ( RearPortTemplate(device_type=device_types[0], name='Rear Port 1', type=PortTypeChoices.TYPE_8P8C), RearPortTemplate(device_type=device_types[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C), RearPortTemplate(device_type=device_types[2], name='Rear Port 3', type=PortTypeChoices.TYPE_8P8C), ) RearPortTemplate.objects.bulk_create(rear_ports) FrontPortTemplate.objects.bulk_create(( FrontPortTemplate(device_type=device_types[0], name='Front Port 1', rear_port=rear_ports[0], type=PortTypeChoices.TYPE_8P8C), FrontPortTemplate(device_type=device_types[1], name='Front Port 2', rear_port=rear_ports[1], type=PortTypeChoices.TYPE_110_PUNCH), FrontPortTemplate(device_type=device_types[2], name='Front Port 3', rear_port=rear_ports[2], type=PortTypeChoices.TYPE_BNC), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Front Port 1', 'Front Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): # TODO: Support filtering for multiple values params = {'type': PortTypeChoices.TYPE_8P8C} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class RearPortTemplateTestCase(TestCase): queryset = RearPortTemplate.objects.all() filterset = RearPortTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) RearPortTemplate.objects.bulk_create(( RearPortTemplate(device_type=device_types[0], name='Rear Port 1', type=PortTypeChoices.TYPE_8P8C, positions=1), RearPortTemplate(device_type=device_types[1], name='Rear Port 2', type=PortTypeChoices.TYPE_110_PUNCH, positions=2), RearPortTemplate(device_type=device_types[2], name='Rear Port 3', type=PortTypeChoices.TYPE_BNC, positions=3), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Rear Port 1', 'Rear Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): # TODO: Support filtering for multiple values params = {'type': PortTypeChoices.TYPE_8P8C} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_positions(self): params = {'positions': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class DeviceBayTemplateTestCase(TestCase): queryset = DeviceBayTemplate.objects.all() filterset = DeviceBayTemplateFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_types = ( DeviceType(manufacturer=manufacturer, model='Model 1', slug='model-1'), DeviceType(manufacturer=manufacturer, model='Model 2', slug='model-2'), DeviceType(manufacturer=manufacturer, model='Model 3', slug='model-3'), ) DeviceType.objects.bulk_create(device_types) DeviceBayTemplate.objects.bulk_create(( DeviceBayTemplate(device_type=device_types[0], name='Device Bay 1'), DeviceBayTemplate(device_type=device_types[1], name='Device Bay 2'), DeviceBayTemplate(device_type=device_types[2], name='Device Bay 3'), )) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Device Bay 1', 'Device Bay 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype_id(self): device_types = DeviceType.objects.all()[:2] params = {'devicetype_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class DeviceRoleTestCase(TestCase): queryset = DeviceRole.objects.all() filterset = DeviceRoleFilterSet @classmethod def setUpTestData(cls): device_roles = ( DeviceRole(name='Device Role 1', slug='device-role-1', color='ff0000', vm_role=True), DeviceRole(name='Device Role 2', slug='device-role-2', color='00ff00', vm_role=True), DeviceRole(name='Device Role 3', slug='device-role-3', color='0000ff', vm_role=False), ) DeviceRole.objects.bulk_create(device_roles) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Device Role 1', 'Device Role 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['device-role-1', 'device-role-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_color(self): params = {'color': ['ff0000', '00ff00']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_vm_role(self): params = {'vm_role': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'vm_role': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class PlatformTestCase(TestCase): queryset = Platform.objects.all() filterset = PlatformFilterSet @classmethod def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3'), ) Manufacturer.objects.bulk_create(manufacturers) platforms = ( Platform(name='Platform 1', slug='platform-1', manufacturer=manufacturers[0], napalm_driver='driver-1', description='A'), Platform(name='Platform 2', slug='platform-2', manufacturer=manufacturers[1], napalm_driver='driver-2', description='B'), Platform(name='Platform 3', slug='platform-3', manufacturer=manufacturers[2], napalm_driver='driver-3', description='C'), ) Platform.objects.bulk_create(platforms) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Platform 1', 'Platform 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_slug(self): params = {'slug': ['platform-1', 'platform-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_napalm_driver(self): params = {'napalm_driver': ['driver-1', 'driver-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_manufacturer(self): manufacturers = Manufacturer.objects.all()[:2] params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class DeviceTestCase(TestCase): queryset = Device.objects.all() filterset = DeviceFilterSet @classmethod def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3'), ) Manufacturer.objects.bulk_create(manufacturers) device_types = ( DeviceType(manufacturer=manufacturers[0], model='Model 1', slug='model-1', is_full_depth=True), DeviceType(manufacturer=manufacturers[1], model='Model 2', slug='model-2', is_full_depth=True), DeviceType(manufacturer=manufacturers[2], model='Model 3', slug='model-3', is_full_depth=False), ) DeviceType.objects.bulk_create(device_types) device_roles = ( DeviceRole(name='Device Role 1', slug='device-role-1'), DeviceRole(name='Device Role 2', slug='device-role-2'), DeviceRole(name='Device Role 3', slug='device-role-3'), ) DeviceRole.objects.bulk_create(device_roles) platforms = ( Platform(name='Platform 1', slug='platform-1'), Platform(name='Platform 2', slug='platform-2'), Platform(name='Platform 3', slug='platform-3'), ) Platform.objects.bulk_create(platforms) regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) rack_groups = ( RackGroup(name='Rack Group 1', slug='rack-group-1', site=sites[0]), RackGroup(name='Rack Group 2', slug='rack-group-2', site=sites[1]), RackGroup(name='Rack Group 3', slug='rack-group-3', site=sites[2]), ) for rackgroup in rack_groups: rackgroup.save() racks = ( Rack(name='Rack 1', site=sites[0], group=rack_groups[0]), Rack(name='Rack 2', site=sites[1], group=rack_groups[1]), Rack(name='Rack 3', site=sites[2], group=rack_groups[2]), ) Rack.objects.bulk_create(racks) cluster_type = ClusterType.objects.create(name='Cluster Type 1', slug='cluster-type-1') clusters = ( Cluster(name='Cluster 1', type=cluster_type), Cluster(name='Cluster 2', type=cluster_type), Cluster(name='Cluster 3', type=cluster_type), ) Cluster.objects.bulk_create(clusters) tenant_groups = ( TenantGroup(name='Tenant group 1', slug='tenant-group-1'), TenantGroup(name='Tenant group 2', slug='tenant-group-2'), TenantGroup(name='Tenant group 3', slug='tenant-group-3'), ) for tenantgroup in tenant_groups: tenantgroup.save() tenants = ( Tenant(name='Tenant 1', slug='tenant-1', group=tenant_groups[0]), Tenant(name='Tenant 2', slug='tenant-2', group=tenant_groups[1]), Tenant(name='Tenant 3', slug='tenant-3', group=tenant_groups[2]), ) Tenant.objects.bulk_create(tenants) devices = ( Device(name='Device 1', device_type=device_types[0], device_role=device_roles[0], platform=platforms[0], tenant=tenants[0], serial='ABC', asset_tag='1001', site=sites[0], rack=racks[0], position=1, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_ACTIVE, cluster=clusters[0], local_context_data={"foo": 123}), Device(name='Device 2', device_type=device_types[1], device_role=device_roles[1], platform=platforms[1], tenant=tenants[1], serial='DEF', asset_tag='1002', site=sites[1], rack=racks[1], position=2, face=DeviceFaceChoices.FACE_FRONT, status=DeviceStatusChoices.STATUS_STAGED, cluster=clusters[1]), Device(name='Device 3', device_type=device_types[2], device_role=device_roles[2], platform=platforms[2], tenant=tenants[2], serial='GHI', asset_tag='1003', site=sites[2], rack=racks[2], position=3, face=DeviceFaceChoices.FACE_REAR, status=DeviceStatusChoices.STATUS_FAILED, cluster=clusters[2]), ) Device.objects.bulk_create(devices) # Add components for filtering ConsolePort.objects.bulk_create(( ConsolePort(device=devices[0], name='Console Port 1'), ConsolePort(device=devices[1], name='Console Port 2'), )) ConsoleServerPort.objects.bulk_create(( ConsoleServerPort(device=devices[0], name='Console Server Port 1'), ConsoleServerPort(device=devices[1], name='Console Server Port 2'), )) PowerPort.objects.bulk_create(( PowerPort(device=devices[0], name='Power Port 1'), PowerPort(device=devices[1], name='Power Port 2'), )) PowerOutlet.objects.bulk_create(( PowerOutlet(device=devices[0], name='Power Outlet 1'), PowerOutlet(device=devices[1], name='Power Outlet 2'), )) interfaces = ( Interface(device=devices[0], name='Interface 1', mac_address='00-00-00-00-00-01'), Interface(device=devices[1], name='Interface 2', mac_address='00-00-00-00-00-02'), ) Interface.objects.bulk_create(interfaces) rear_ports = ( RearPort(device=devices[0], name='Rear Port 1', type=PortTypeChoices.TYPE_8P8C), RearPort(device=devices[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C), ) RearPort.objects.bulk_create(rear_ports) FrontPort.objects.bulk_create(( FrontPort(device=devices[0], name='Front Port 1', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[0]), FrontPort(device=devices[1], name='Front Port 2', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[1]), )) DeviceBay.objects.bulk_create(( DeviceBay(device=devices[0], name='Device Bay 1'), DeviceBay(device=devices[1], name='Device Bay 2'), )) # Assign primary IPs for filtering ipaddresses = ( IPAddress(address='192.0.2.1/24', assigned_object=interfaces[0]), IPAddress(address='192.0.2.2/24', assigned_object=interfaces[1]), ) IPAddress.objects.bulk_create(ipaddresses) Device.objects.filter(pk=devices[0].pk).update(primary_ip4=ipaddresses[0]) Device.objects.filter(pk=devices[1].pk).update(primary_ip4=ipaddresses[1]) # VirtualChassis assignment for filtering virtual_chassis = VirtualChassis.objects.create(master=devices[0]) Device.objects.filter(pk=devices[0].pk).update(virtual_chassis=virtual_chassis, vc_position=1, vc_priority=1) Device.objects.filter(pk=devices[1].pk).update(virtual_chassis=virtual_chassis, vc_position=2, vc_priority=2) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Device 1', 'Device 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_asset_tag(self): params = {'asset_tag': ['1001', '1002']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_face(self): params = {'face': DeviceFaceChoices.FACE_FRONT} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_position(self): params = {'position': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_vc_position(self): params = {'vc_position': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_vc_priority(self): params = {'vc_priority': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_manufacturer(self): manufacturers = Manufacturer.objects.all()[:2] params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicetype(self): device_types = DeviceType.objects.all()[:2] params = {'device_type_id': [device_types[0].pk, device_types[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_devicerole(self): device_roles = DeviceRole.objects.all()[:2] params = {'role_id': [device_roles[0].pk, device_roles[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'role': [device_roles[0].slug, device_roles[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_platform(self): platforms = Platform.objects.all()[:2] params = {'platform_id': [platforms[0].pk, platforms[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'platform': [platforms[0].slug, platforms[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_rackgroup(self): rack_groups = RackGroup.objects.all()[:2] params = {'rack_group_id': [rack_groups[0].pk, rack_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_rack(self): racks = Rack.objects.all()[:2] params = {'rack_id': [racks[0].pk, racks[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cluster(self): clusters = Cluster.objects.all()[:2] params = {'cluster_id': [clusters[0].pk, clusters[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_model(self): params = {'model': ['model-1', 'model-2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_status(self): params = {'status': [DeviceStatusChoices.STATUS_ACTIVE, DeviceStatusChoices.STATUS_STAGED]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_is_full_depth(self): params = {'is_full_depth': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'is_full_depth': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_mac_address(self): params = {'mac_address': ['00-00-00-00-00-01', '00-00-00-00-00-02']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_serial(self): params = {'serial': 'ABC'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'serial': 'abc'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_has_primary_ip(self): params = {'has_primary_ip': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'has_primary_ip': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_virtual_chassis_id(self): params = {'virtual_chassis_id': [VirtualChassis.objects.first().pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_virtual_chassis_member(self): params = {'virtual_chassis_member': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'virtual_chassis_member': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_console_ports(self): params = {'console_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'console_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_console_server_ports(self): params = {'console_server_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'console_server_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_power_ports(self): params = {'power_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'power_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_power_outlets(self): params = {'power_outlets': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'power_outlets': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_interfaces(self): params = {'interfaces': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'interfaces': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_pass_through_ports(self): params = {'pass_through_ports': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'pass_through_ports': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_device_bays(self): params = {'device_bays': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device_bays': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_local_context_data(self): params = {'local_context_data': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'local_context_data': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant(self): tenants = Tenant.objects.all()[:2] params = {'tenant_id': [tenants[0].pk, tenants[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant': [tenants[0].slug, tenants[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_tenant_group(self): tenant_groups = TenantGroup.objects.all()[:2] params = {'tenant_group_id': [tenant_groups[0].pk, tenant_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'tenant_group': [tenant_groups[0].slug, tenant_groups[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class ConsolePortTestCase(TestCase): queryset = ConsolePort.objects.all() filterset = ConsolePortFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) console_server_ports = ( ConsoleServerPort(device=devices[3], name='Console Server Port 1'), ConsoleServerPort(device=devices[3], name='Console Server Port 2'), ) ConsoleServerPort.objects.bulk_create(console_server_ports) console_ports = ( ConsolePort(device=devices[0], name='Console Port 1', label='A', description='First'), ConsolePort(device=devices[1], name='Console Port 2', label='B', description='Second'), ConsolePort(device=devices[2], name='Console Port 3', label='C', description='Third'), ) ConsolePort.objects.bulk_create(console_ports) # Cables Cable(termination_a=console_ports[0], termination_b=console_server_ports[0]).save() Cable(termination_a=console_ports[1], termination_b=console_server_ports[1]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Console Port 1', 'Console Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class ConsoleServerPortTestCase(TestCase): queryset = ConsoleServerPort.objects.all() filterset = ConsoleServerPortFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) console_ports = ( ConsolePort(device=devices[3], name='Console Server Port 1'), ConsolePort(device=devices[3], name='Console Server Port 2'), ) ConsolePort.objects.bulk_create(console_ports) console_server_ports = ( ConsoleServerPort(device=devices[0], name='Console Server Port 1', label='A', description='First'), ConsoleServerPort(device=devices[1], name='Console Server Port 2', label='B', description='Second'), ConsoleServerPort(device=devices[2], name='Console Server Port 3', label='C', description='Third'), ) ConsoleServerPort.objects.bulk_create(console_server_ports) # Cables Cable(termination_a=console_server_ports[0], termination_b=console_ports[0]).save() Cable(termination_a=console_server_ports[1], termination_b=console_ports[1]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Console Server Port 1', 'Console Server Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class PowerPortTestCase(TestCase): queryset = PowerPort.objects.all() filterset = PowerPortFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) power_outlets = ( PowerOutlet(device=devices[3], name='Power Outlet 1'), PowerOutlet(device=devices[3], name='Power Outlet 2'), ) PowerOutlet.objects.bulk_create(power_outlets) power_ports = ( PowerPort(device=devices[0], name='Power Port 1', label='A', maximum_draw=100, allocated_draw=50, description='First'), PowerPort(device=devices[1], name='Power Port 2', label='B', maximum_draw=200, allocated_draw=100, description='Second'), PowerPort(device=devices[2], name='Power Port 3', label='C', maximum_draw=300, allocated_draw=150, description='Third'), ) PowerPort.objects.bulk_create(power_ports) # Cables Cable(termination_a=power_ports[0], termination_b=power_outlets[0]).save() Cable(termination_a=power_ports[1], termination_b=power_outlets[1]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Port 1', 'Power Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_maximum_draw(self): params = {'maximum_draw': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_allocated_draw(self): params = {'allocated_draw': [50, 100]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class PowerOutletTestCase(TestCase): queryset = PowerOutlet.objects.all() filterset = PowerOutletFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) power_ports = ( PowerPort(device=devices[3], name='Power Outlet 1'), PowerPort(device=devices[3], name='Power Outlet 2'), ) PowerPort.objects.bulk_create(power_ports) power_outlets = ( PowerOutlet(device=devices[0], name='Power Outlet 1', label='A', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_A, description='First'), PowerOutlet(device=devices[1], name='Power Outlet 2', label='B', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_B, description='Second'), PowerOutlet(device=devices[2], name='Power Outlet 3', label='C', feed_leg=PowerOutletFeedLegChoices.FEED_LEG_C, description='Third'), ) PowerOutlet.objects.bulk_create(power_outlets) # Cables Cable(termination_a=power_outlets[0], termination_b=power_ports[0]).save() Cable(termination_a=power_outlets[1], termination_b=power_ports[1]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Outlet 1', 'Power Outlet 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_feed_leg(self): # TODO: Support filtering for multiple values params = {'feed_leg': PowerOutletFeedLegChoices.FEED_LEG_A} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class InterfaceTestCase(TestCase): queryset = Interface.objects.all() filterset = InterfaceFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) interfaces = ( Interface(device=devices[0], name='Interface 1', label='A', type=InterfaceTypeChoices.TYPE_1GE_SFP, enabled=True, mgmt_only=True, mtu=100, mode=InterfaceModeChoices.MODE_ACCESS, mac_address='00-00-00-00-00-01', description='First'), Interface(device=devices[1], name='Interface 2', label='B', type=InterfaceTypeChoices.TYPE_1GE_GBIC, enabled=True, mgmt_only=True, mtu=200, mode=InterfaceModeChoices.MODE_TAGGED, mac_address='00-00-00-00-00-02', description='Second'), Interface(device=devices[2], name='Interface 3', label='C', type=InterfaceTypeChoices.TYPE_1GE_FIXED, enabled=False, mgmt_only=False, mtu=300, mode=InterfaceModeChoices.MODE_TAGGED_ALL, mac_address='00-00-00-00-00-03', description='Third'), Interface(device=devices[3], name='Interface 4', label='D', type=InterfaceTypeChoices.TYPE_OTHER, enabled=True, mgmt_only=True), Interface(device=devices[3], name='Interface 5', label='E', type=InterfaceTypeChoices.TYPE_OTHER, enabled=True, mgmt_only=True), Interface(device=devices[3], name='Interface 6', label='F', type=InterfaceTypeChoices.TYPE_OTHER, enabled=False, mgmt_only=False), ) Interface.objects.bulk_create(interfaces) # Cables Cable(termination_a=interfaces[0], termination_b=interfaces[3]).save() Cable(termination_a=interfaces[1], termination_b=interfaces[4]).save() # Third pair is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Interface 1', 'Interface 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_enabled(self): params = {'enabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'enabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_mtu(self): params = {'mtu': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_mgmt_only(self): params = {'mgmt_only': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'mgmt_only': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_mode(self): params = {'mode': InterfaceModeChoices.MODE_ACCESS} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_kind(self): params = {'kind': 'physical'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 6) params = {'kind': 'virtual'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 0) def test_mac_address(self): params = {'mac_address': ['00-00-00-00-00-01', '00-00-00-00-00-02']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): params = {'type': [InterfaceTypeChoices.TYPE_1GE_FIXED, InterfaceTypeChoices.TYPE_1GE_GBIC]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class FrontPortTestCase(TestCase): queryset = FrontPort.objects.all() filterset = FrontPortFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) rear_ports = ( RearPort(device=devices[0], name='Rear Port 1', type=PortTypeChoices.TYPE_8P8C, positions=6), RearPort(device=devices[1], name='Rear Port 2', type=PortTypeChoices.TYPE_8P8C, positions=6), RearPort(device=devices[2], name='Rear Port 3', type=PortTypeChoices.TYPE_8P8C, positions=6), RearPort(device=devices[3], name='Rear Port 4', type=PortTypeChoices.TYPE_8P8C, positions=6), RearPort(device=devices[3], name='Rear Port 5', type=PortTypeChoices.TYPE_8P8C, positions=6), RearPort(device=devices[3], name='Rear Port 6', type=PortTypeChoices.TYPE_8P8C, positions=6), ) RearPort.objects.bulk_create(rear_ports) front_ports = ( FrontPort(device=devices[0], name='Front Port 1', label='A', type=PortTypeChoices.TYPE_8P8C, rear_port=rear_ports[0], rear_port_position=1, description='First'), FrontPort(device=devices[1], name='Front Port 2', label='B', type=PortTypeChoices.TYPE_110_PUNCH, rear_port=rear_ports[1], rear_port_position=2, description='Second'), FrontPort(device=devices[2], name='Front Port 3', label='C', type=PortTypeChoices.TYPE_BNC, rear_port=rear_ports[2], rear_port_position=3, description='Third'), FrontPort(device=devices[3], name='Front Port 4', label='D', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[3], rear_port_position=1), FrontPort(device=devices[3], name='Front Port 5', label='E', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[4], rear_port_position=1), FrontPort(device=devices[3], name='Front Port 6', label='F', type=PortTypeChoices.TYPE_FC, rear_port=rear_ports[5], rear_port_position=1), ) FrontPort.objects.bulk_create(front_ports) # Cables Cable(termination_a=front_ports[0], termination_b=front_ports[3]).save() Cable(termination_a=front_ports[1], termination_b=front_ports[4]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Front Port 1', 'Front Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): # TODO: Test for multiple values params = {'type': PortTypeChoices.TYPE_8P8C} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class RearPortTestCase(TestCase): queryset = RearPort.objects.all() filterset = RearPortFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), Device(name=None, device_type=device_type, device_role=device_role, site=sites[3]), # For cable connections ) Device.objects.bulk_create(devices) rear_ports = ( RearPort(device=devices[0], name='Rear Port 1', label='A', type=PortTypeChoices.TYPE_8P8C, positions=1, description='First'), RearPort(device=devices[1], name='Rear Port 2', label='B', type=PortTypeChoices.TYPE_110_PUNCH, positions=2, description='Second'), RearPort(device=devices[2], name='Rear Port 3', label='C', type=PortTypeChoices.TYPE_BNC, positions=3, description='Third'), RearPort(device=devices[3], name='Rear Port 4', label='D', type=PortTypeChoices.TYPE_FC, positions=4), RearPort(device=devices[3], name='Rear Port 5', label='E', type=PortTypeChoices.TYPE_FC, positions=5), RearPort(device=devices[3], name='Rear Port 6', label='F', type=PortTypeChoices.TYPE_FC, positions=6), ) RearPort.objects.bulk_create(rear_ports) # Cables Cable(termination_a=rear_ports[0], termination_b=rear_ports[3]).save() Cable(termination_a=rear_ports[1], termination_b=rear_ports[4]).save() # Third port is not connected def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Rear Port 1', 'Rear Port 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_type(self): # TODO: Test for multiple values params = {'type': PortTypeChoices.TYPE_8P8C} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_positions(self): params = {'positions': [1, 2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class DeviceBayTestCase(TestCase): queryset = DeviceBay.objects.all() filterset = DeviceBayFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = Site.objects.bulk_create(( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), Site(name='Site X', slug='site-x'), )) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), ) Device.objects.bulk_create(devices) device_bays = ( DeviceBay(device=devices[0], name='Device Bay 1', label='A', description='First'), DeviceBay(device=devices[1], name='Device Bay 2', label='B', description='Second'), DeviceBay(device=devices[2], name='Device Bay 3', label='C', description='Third'), ) DeviceBay.objects.bulk_create(device_bays) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Device Bay 1', 'Device Bay 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_description(self): params = {'description': ['First', 'Second']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class InventoryItemTestCase(TestCase): queryset = InventoryItem.objects.all() filterset = InventoryItemFilterSet @classmethod def setUpTestData(cls): manufacturers = ( Manufacturer(name='Manufacturer 1', slug='manufacturer-1'), Manufacturer(name='Manufacturer 2', slug='manufacturer-2'), Manufacturer(name='Manufacturer 3', slug='manufacturer-3'), ) Manufacturer.objects.bulk_create(manufacturers) device_type = DeviceType.objects.create(manufacturer=manufacturers[0], model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[1]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[2]), ) Device.objects.bulk_create(devices) inventory_items = ( InventoryItem(device=devices[0], manufacturer=manufacturers[0], name='Inventory Item 1', label='A', part_id='1001', serial='ABC', asset_tag='1001', discovered=True, description='First'), InventoryItem(device=devices[1], manufacturer=manufacturers[1], name='Inventory Item 2', label='B', part_id='1002', serial='DEF', asset_tag='1002', discovered=True, description='Second'), InventoryItem(device=devices[2], manufacturer=manufacturers[2], name='Inventory Item 3', label='C', part_id='1003', serial='GHI', asset_tag='1003', discovered=False, description='Third'), ) for i in inventory_items: i.save() child_inventory_items = ( InventoryItem(device=devices[0], name='Inventory Item 1A', parent=inventory_items[0]), InventoryItem(device=devices[1], name='Inventory Item 2A', parent=inventory_items[1]), InventoryItem(device=devices[2], name='Inventory Item 3A', parent=inventory_items[2]), ) for i in child_inventory_items: i.save() def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Inventory Item 1', 'Inventory Item 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['A', 'B']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_part_id(self): params = {'part_id': ['1001', '1002']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_asset_tag(self): params = {'asset_tag': ['1001', '1002']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_discovered(self): # TODO: Fix boolean value params = {'discovered': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'discovered': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_device(self): # TODO: Allow multiple values device = Device.objects.first() params = {'device_id': device.pk} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'device': device.name} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_parent_id(self): parent_items = InventoryItem.objects.filter(parent__isnull=True)[:2] params = {'parent_id': [parent_items[0].pk, parent_items[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_manufacturer(self): manufacturers = Manufacturer.objects.all()[:2] params = {'manufacturer_id': [manufacturers[0].pk, manufacturers[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'manufacturer': [manufacturers[0].slug, manufacturers[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_serial(self): params = {'serial': 'ABC'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) params = {'serial': 'abc'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) class VirtualChassisTestCase(TestCase): queryset = VirtualChassis.objects.all() filterset = VirtualChassisFilterSet @classmethod def setUpTestData(cls): manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0], vc_position=1), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[0], vc_position=2), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[1], vc_position=1), Device(name='Device 4', device_type=device_type, device_role=device_role, site=sites[1], vc_position=2), Device(name='Device 5', device_type=device_type, device_role=device_role, site=sites[2], vc_position=1), Device(name='Device 6', device_type=device_type, device_role=device_role, site=sites[2], vc_position=2), ) Device.objects.bulk_create(devices) virtual_chassis = ( VirtualChassis(name='VC 1', master=devices[0], domain='Domain 1'), VirtualChassis(name='VC 2', master=devices[2], domain='Domain 2'), VirtualChassis(name='VC 3', master=devices[4], domain='Domain 3'), ) VirtualChassis.objects.bulk_create(virtual_chassis) Device.objects.filter(pk=devices[1].pk).update(virtual_chassis=virtual_chassis[0]) Device.objects.filter(pk=devices[3].pk).update(virtual_chassis=virtual_chassis[1]) Device.objects.filter(pk=devices[5].pk).update(virtual_chassis=virtual_chassis[2]) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_domain(self): params = {'domain': ['Domain 1', 'Domain 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_master(self): masters = Device.objects.all() params = {'master_id': [masters[0].pk, masters[2].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'master': [masters[0].name, masters[2].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['VC 1', 'VC 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class CableTestCase(TestCase): queryset = Cable.objects.all() filterset = CableFilterSet @classmethod def setUpTestData(cls): sites = ( Site(name='Site 1', slug='site-1'), Site(name='Site 2', slug='site-2'), Site(name='Site 3', slug='site-3'), ) Site.objects.bulk_create(sites) tenants = ( Tenant(name='Tenant 1', slug='tenant-1'), Tenant(name='Tenant 2', slug='tenant-2'), ) Tenant.objects.bulk_create(tenants) racks = ( Rack(name='Rack 1', site=sites[0]), Rack(name='Rack 2', site=sites[1]), Rack(name='Rack 3', site=sites[2]), ) Rack.objects.bulk_create(racks) manufacturer = Manufacturer.objects.create(name='Manufacturer 1', slug='manufacturer-1') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model 1', slug='model-1') device_role = DeviceRole.objects.create(name='Device Role 1', slug='device-role-1') devices = ( Device(name='Device 1', device_type=device_type, device_role=device_role, site=sites[0], rack=racks[0], position=1, tenant=tenants[0]), Device(name='Device 2', device_type=device_type, device_role=device_role, site=sites[0], rack=racks[0], position=2, tenant=tenants[0]), Device(name='Device 3', device_type=device_type, device_role=device_role, site=sites[1], rack=racks[1], position=1, tenant=tenants[1]), Device(name='Device 4', device_type=device_type, device_role=device_role, site=sites[1], rack=racks[1], position=2), Device(name='Device 5', device_type=device_type, device_role=device_role, site=sites[2], rack=racks[2], position=1), Device(name='Device 6', device_type=device_type, device_role=device_role, site=sites[2], rack=racks[2], position=2), ) Device.objects.bulk_create(devices) interfaces = ( Interface(device=devices[0], name='Interface 1', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[0], name='Interface 2', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[1], name='Interface 3', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[1], name='Interface 4', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[2], name='Interface 5', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[2], name='Interface 6', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[3], name='Interface 7', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[3], name='Interface 8', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[4], name='Interface 9', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[4], name='Interface 10', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[5], name='Interface 11', type=InterfaceTypeChoices.TYPE_1GE_FIXED), Interface(device=devices[5], name='Interface 12', type=InterfaceTypeChoices.TYPE_1GE_FIXED), ) Interface.objects.bulk_create(interfaces) # Cables Cable(termination_a=interfaces[1], termination_b=interfaces[2], label='Cable 1', type=CableTypeChoices.TYPE_CAT3, status=CableStatusChoices.STATUS_CONNECTED, color='aa1409', length=10, length_unit=CableLengthUnitChoices.UNIT_FOOT).save() Cable(termination_a=interfaces[3], termination_b=interfaces[4], label='Cable 2', type=CableTypeChoices.TYPE_CAT3, status=CableStatusChoices.STATUS_CONNECTED, color='aa1409', length=20, length_unit=CableLengthUnitChoices.UNIT_FOOT).save() Cable(termination_a=interfaces[5], termination_b=interfaces[6], label='Cable 3', type=CableTypeChoices.TYPE_CAT5E, status=CableStatusChoices.STATUS_CONNECTED, color='f44336', length=30, length_unit=CableLengthUnitChoices.UNIT_FOOT).save() Cable(termination_a=interfaces[7], termination_b=interfaces[8], label='Cable 4', type=CableTypeChoices.TYPE_CAT5E, status=CableStatusChoices.STATUS_PLANNED, color='f44336', length=40, length_unit=CableLengthUnitChoices.UNIT_FOOT).save() Cable(termination_a=interfaces[9], termination_b=interfaces[10], label='Cable 5', type=CableTypeChoices.TYPE_CAT6, status=CableStatusChoices.STATUS_PLANNED, color='e91e63', length=10, length_unit=CableLengthUnitChoices.UNIT_METER).save() Cable(termination_a=interfaces[11], termination_b=interfaces[0], label='Cable 6', type=CableTypeChoices.TYPE_CAT6, status=CableStatusChoices.STATUS_PLANNED, color='e91e63', length=20, length_unit=CableLengthUnitChoices.UNIT_METER).save() def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_label(self): params = {'label': ['Cable 1', 'Cable 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_length(self): params = {'length': [10, 20]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_length_unit(self): params = {'length_unit': CableLengthUnitChoices.UNIT_FOOT} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_type(self): params = {'type': [CableTypeChoices.TYPE_CAT3, CableTypeChoices.TYPE_CAT5E]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_status(self): params = {'status': [CableStatusChoices.STATUS_CONNECTED]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3) params = {'status': [CableStatusChoices.STATUS_PLANNED]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3) def test_color(self): params = {'color': ['aa1409', 'f44336']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) def test_device(self): devices = Device.objects.all()[:2] params = {'device_id': [devices[0].pk, devices[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3) params = {'device': [devices[0].name, devices[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 3) def test_rack(self): racks = Rack.objects.all()[:2] params = {'rack_id': [racks[0].pk, racks[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 5) params = {'rack': [racks[0].name, racks[1].name]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 5) def test_site(self): site = Site.objects.all()[:2] params = {'site_id': [site[0].pk, site[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 5) params = {'site': [site[0].slug, site[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 5) def test_tenant(self): tenant = Tenant.objects.all()[:2] params = {'tenant_id': [tenant[0].pk, tenant[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) params = {'tenant': [tenant[0].slug, tenant[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 4) class PowerPanelTestCase(TestCase): queryset = PowerPanel.objects.all() filterset = PowerPanelFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) rack_groups = ( RackGroup(name='Rack Group 1', slug='rack-group-1', site=sites[0]), RackGroup(name='Rack Group 2', slug='rack-group-2', site=sites[1]), RackGroup(name='Rack Group 3', slug='rack-group-3', site=sites[2]), ) for rackgroup in rack_groups: rackgroup.save() power_panels = ( PowerPanel(name='Power Panel 1', site=sites[0], rack_group=rack_groups[0]), PowerPanel(name='Power Panel 2', site=sites[1], rack_group=rack_groups[1]), PowerPanel(name='Power Panel 3', site=sites[2], rack_group=rack_groups[2]), ) PowerPanel.objects.bulk_create(power_panels) def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Panel 1', 'Power Panel 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_rack_group(self): rack_groups = RackGroup.objects.all()[:2] params = {'rack_group_id': [rack_groups[0].pk, rack_groups[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) class PowerFeedTestCase(TestCase): queryset = PowerFeed.objects.all() filterset = PowerFeedFilterSet @classmethod def setUpTestData(cls): regions = ( Region(name='Region 1', slug='region-1'), Region(name='Region 2', slug='region-2'), Region(name='Region 3', slug='region-3'), ) for region in regions: region.save() sites = ( Site(name='Site 1', slug='site-1', region=regions[0]), Site(name='Site 2', slug='site-2', region=regions[1]), Site(name='Site 3', slug='site-3', region=regions[2]), ) Site.objects.bulk_create(sites) racks = ( Rack(name='Rack 1', site=sites[0]), Rack(name='Rack 2', site=sites[1]), Rack(name='Rack 3', site=sites[2]), ) Rack.objects.bulk_create(racks) power_panels = ( PowerPanel(name='Power Panel 1', site=sites[0]), PowerPanel(name='Power Panel 2', site=sites[1]), PowerPanel(name='Power Panel 3', site=sites[2]), ) PowerPanel.objects.bulk_create(power_panels) power_feeds = ( PowerFeed(power_panel=power_panels[0], rack=racks[0], name='Power Feed 1', status=PowerFeedStatusChoices.STATUS_ACTIVE, type=PowerFeedTypeChoices.TYPE_PRIMARY, supply=PowerFeedSupplyChoices.SUPPLY_AC, phase=PowerFeedPhaseChoices.PHASE_3PHASE, voltage=100, amperage=100, max_utilization=10), PowerFeed(power_panel=power_panels[1], rack=racks[1], name='Power Feed 2', status=PowerFeedStatusChoices.STATUS_FAILED, type=PowerFeedTypeChoices.TYPE_PRIMARY, supply=PowerFeedSupplyChoices.SUPPLY_AC, phase=PowerFeedPhaseChoices.PHASE_3PHASE, voltage=200, amperage=200, max_utilization=20), PowerFeed(power_panel=power_panels[2], rack=racks[2], name='Power Feed 3', status=PowerFeedStatusChoices.STATUS_OFFLINE, type=PowerFeedTypeChoices.TYPE_REDUNDANT, supply=PowerFeedSupplyChoices.SUPPLY_DC, phase=PowerFeedPhaseChoices.PHASE_SINGLE, voltage=300, amperage=300, max_utilization=30), ) PowerFeed.objects.bulk_create(power_feeds) manufacturer = Manufacturer.objects.create(name='Manufacturer', slug='manufacturer') device_type = DeviceType.objects.create(manufacturer=manufacturer, model='Model', slug='model') device_role = DeviceRole.objects.create(name='Device Role', slug='device-role') device = Device.objects.create(name='Device', device_type=device_type, device_role=device_role, site=sites[0]) power_ports = [ PowerPort(device=device, name='Power Port 1'), PowerPort(device=device, name='Power Port 2'), ] PowerPort.objects.bulk_create(power_ports) Cable(termination_a=power_feeds[0], termination_b=power_ports[0]).save() Cable(termination_a=power_feeds[1], termination_b=power_ports[1]).save() def test_id(self): params = {'id': self.queryset.values_list('pk', flat=True)[:2]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_name(self): params = {'name': ['Power Feed 1', 'Power Feed 2']} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_status(self): # TODO: Test for multiple values params = {'status': PowerFeedStatusChoices.STATUS_ACTIVE} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_type(self): params = {'type': PowerFeedTypeChoices.TYPE_PRIMARY} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_supply(self): params = {'supply': PowerFeedSupplyChoices.SUPPLY_AC} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_phase(self): params = {'phase': PowerFeedPhaseChoices.PHASE_3PHASE} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_voltage(self): params = {'voltage': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_amperage(self): params = {'amperage': [100, 200]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_max_utilization(self): params = {'max_utilization': [10, 20]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_region(self): regions = Region.objects.all()[:2] params = {'region_id': [regions[0].pk, regions[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'region': [regions[0].slug, regions[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_site(self): sites = Site.objects.all()[:2] params = {'site_id': [sites[0].pk, sites[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'site': [sites[0].slug, sites[1].slug]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_power_panel_id(self): power_panels = PowerPanel.objects.all()[:2] params = {'power_panel_id': [power_panels[0].pk, power_panels[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_rack_id(self): racks = Rack.objects.all()[:2] params = {'rack_id': [racks[0].pk, racks[1].pk]} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) def test_cabled(self): params = {'cabled': 'true'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'cabled': 'false'} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) def test_connected(self): params = {'connected': True} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2) params = {'connected': False} self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1) # TODO: Connection filters
digitalocean/netbox
netbox/dcim/tests/test_filters.py
Python
apache-2.0
132,317
''' @Summary: Utility Methods for dynamic actions during program operation. @Author: devopsec ''' import os, sys, socket, inspect def getWorkingDirs(): ''' Returns project dir, parent dir, and current dir of calling script as dict''' project_dir, parent_dir, current_dir = None if os.path.exists(os.path.dirname(__file__)): current_dir = os.path.abspath(os.path.dirname(__file__)) parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) else: current_dir = os.path.abspath(os.getcwd()) parent_dir = os.path.abspath(os.path.join(os.getcwd(), '..')) check = os.path.exists(parent_dir) while (check != False): project_dir = os.getcwd() os.chdir("..") check = os.path.exists(os.path.join(os.getcwd(), '..')) return { 'project_dir' : project_dir, 'parent_dir' : parent_dir, 'current_dir' : current_dir } def setProjectPath(dir=None): ''' Sets project path to current calling script location or provided dir and move to it ''' if not dir == None and os.path.exists(dir): proj_path = os.path.abspath(dir) os.chdir(proj_path) sys.path.append(proj_path) print("Project path set to: " + proj_path) else: if os.path.exists(os.path.dirname(__file__)): proj_path = os.path.abspath(os.path.dirname(__file__)) os.chdir(proj_path) sys.path.append(proj_path) else: proj_path = os.path.abspath(os.getcwd()) os.chdir(proj_path) sys.path.append(proj_path) def get_current_ip(): ''' Returns current ip of system ''' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) return s.getsockname()[0] def get_hostname(): ''' Returns hostname of current host ''' if socket.gethostname().find('.') >= 0: return socket.gethostname() else: return socket.gethostbyaddr(socket.gethostname())[0] def script_info(): ''' Returns a dictionary with information about the running top level Python --------------------------------------------------------------------------- dir: directory containing script or compiled executable name: name of script or executable source: name of source code file --------------------------------------------------------------------------- "name" and "source" are identical if and only if running interpreted code. When running code compiled by py2exe or cx_freeze, "source" contains the name of the originating Python script. If compiled by PyInstaller, "source" contains no meaningful information. ''' #---------------------------------------------------------------------------# # scan through call stack for caller information # #---------------------------------------------------------------------------# for teil in inspect.stack(): # skip system calls if teil[1].startswith("<"): continue if teil[1].upper().startswith(sys.exec_prefix.upper()): continue trc = teil[1] # trc contains highest level calling script name, check if we have been compiled if getattr(sys, 'frozen', False): scriptdir, scriptname = os.path.split(sys.executable) return { "dir" : scriptdir, "name" : scriptname, "source" : trc } # from here on, we are in the interpreted case scriptdir, trc = os.path.split(trc) # if trc did not contain directory information, # the current working directory is what we need if not scriptdir: scriptdir = os.getcwd() scr_dict = { "name" : trc, "source" : trc, "dir" : scriptdir } return scr_dict
flyballlabs/threatdetectionservice
api/util/dynamic.py
Python
apache-2.0
3,841
"""Support for Telegram bot using polling.""" import logging from homeassistant.const import ( EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP) from homeassistant.core import callback from . import ( CONF_ALLOWED_CHAT_IDS, PLATFORM_SCHEMA as TELEGRAM_PLATFORM_SCHEMA, BaseTelegramBotEntity, initialize_bot) _LOGGER = logging.getLogger(__name__) PLATFORM_SCHEMA = TELEGRAM_PLATFORM_SCHEMA async def async_setup_platform(hass, config): """Set up the Telegram polling platform.""" bot = initialize_bot(config) pol = TelegramPoll(bot, hass, config[CONF_ALLOWED_CHAT_IDS]) @callback def _start_bot(_event): """Start the bot.""" pol.start_polling() @callback def _stop_bot(_event): """Stop the bot.""" pol.stop_polling() hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, _start_bot) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _stop_bot) return True def process_error(bot, update, error): """Telegram bot error handler.""" from telegram.error import ( TelegramError, TimedOut, NetworkError, RetryAfter) try: raise error except (TimedOut, NetworkError, RetryAfter): # Long polling timeout or connection problem. Nothing serious. pass except TelegramError: _LOGGER.error('Update "%s" caused error "%s"', update, error) def message_handler(handler): """Create messages handler.""" from telegram import Update from telegram.ext import Handler class MessageHandler(Handler): """Telegram bot message handler.""" def __init__(self): """Initialize the messages handler instance.""" super().__init__(handler) def check_update(self, update): # pylint: disable=no-self-use """Check is update valid.""" return isinstance(update, Update) def handle_update(self, update, dispatcher): """Handle update.""" optional_args = self.collect_optional_args(dispatcher, update) return self.callback(dispatcher.bot, update, **optional_args) return MessageHandler() class TelegramPoll(BaseTelegramBotEntity): """Asyncio telegram incoming message handler.""" def __init__(self, bot, hass, allowed_chat_ids): """Initialize the polling instance.""" from telegram.ext import Updater BaseTelegramBotEntity.__init__(self, hass, allowed_chat_ids) self.updater = Updater(bot=bot, workers=4) self.dispatcher = self.updater.dispatcher self.dispatcher.add_handler(message_handler(self.process_update)) self.dispatcher.add_error_handler(process_error) def start_polling(self): """Start the polling task.""" self.updater.start_polling() def stop_polling(self): """Stop the polling task.""" self.updater.stop() def process_update(self, bot, update): """Process incoming message.""" self.process_message(update.to_dict())
jamespcole/home-assistant
homeassistant/components/telegram_bot/polling.py
Python
apache-2.0
3,026
import re from django.template import Node, Variable, VariableNode, _render_value_in_context from django.template import TemplateSyntaxError, TokenParser, Library from django.template import TOKEN_TEXT, TOKEN_VAR from django.utils import translation from django.utils.encoding import force_unicode register = Library() class GetAvailableLanguagesNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): from django.conf import settings context[self.variable] = [(k, translation.ugettext(v)) for k, v in settings.LANGUAGES] return '' class GetCurrentLanguageNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): context[self.variable] = translation.get_language() return '' class GetCurrentLanguageBidiNode(Node): def __init__(self, variable): self.variable = variable def render(self, context): context[self.variable] = translation.get_language_bidi() return '' class TranslateNode(Node): def __init__(self, value, noop): self.value = Variable(value) self.noop = noop def render(self, context): value = self.value.resolve(context) if self.noop: return value else: return _render_value_in_context(translation.ugettext(value), context) class BlockTranslateNode(Node): def __init__(self, extra_context, singular, plural=None, countervar=None, counter=None): self.extra_context = extra_context self.singular = singular self.plural = plural self.countervar = countervar self.counter = counter def render_token_list(self, tokens): result = [] vars = [] for token in tokens: if token.token_type == TOKEN_TEXT: result.append(token.contents) elif token.token_type == TOKEN_VAR: result.append(u'%%(%s)s' % token.contents) vars.append(token.contents) return ''.join(result), vars def render(self, context): tmp_context = {} for var, val in self.extra_context.items(): tmp_context[var] = val.render(context) # Update() works like a push(), so corresponding context.pop() is at # the end of function context.update(tmp_context) singular, vars = self.render_token_list(self.singular) if self.plural and self.countervar and self.counter: count = self.counter.resolve(context) context[self.countervar] = count plural, vars = self.render_token_list(self.plural) result = translation.ungettext(singular, plural, count) else: result = translation.ugettext(singular) # Escape all isolated '%' before substituting in the context. result = re.sub(u'%(?!\()', u'%%', result) data = dict([(v, _render_value_in_context(context[v], context)) for v in vars]) context.pop() return result % data def do_get_available_languages(parser, token): """ This will store a list of available languages in the context. Usage:: {% get_available_languages as languages %} {% for language in languages %} ... {% endfor %} This will just pull the LANGUAGES setting from your setting file (or the default settings) and put it into the named variable. """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError, "'get_available_languages' requires 'as variable' (got %r)" % args return GetAvailableLanguagesNode(args[2]) def do_get_current_language(parser, token): """ This will store the current language in the context. Usage:: {% get_current_language as language %} This will fetch the currently active language and put it's value into the ``language`` context variable. """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError, "'get_current_language' requires 'as variable' (got %r)" % args return GetCurrentLanguageNode(args[2]) def do_get_current_language_bidi(parser, token): """ This will store the current language layout in the context. Usage:: {% get_current_language_bidi as bidi %} This will fetch the currently active language's layout and put it's value into the ``bidi`` context variable. True indicates right-to-left layout, otherwise left-to-right """ args = token.contents.split() if len(args) != 3 or args[1] != 'as': raise TemplateSyntaxError, "'get_current_language_bidi' requires 'as variable' (got %r)" % args return GetCurrentLanguageBidiNode(args[2]) def do_translate(parser, token): """ This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will run the string through the translation engine. There is a second form:: {% trans "this is a test" noop %} This will only mark for translation, but will return the string unchanged. Use it when you need to store values into forms that should be translated later on. You can use variables instead of constant strings to translate stuff you marked somewhere else:: {% trans variable %} This will just try to translate the contents of the variable ``variable``. Make sure that the string in there is something that is in the .po file. """ class TranslateParser(TokenParser): def top(self): value = self.value() if self.more(): if self.tag() == 'noop': noop = True else: raise TemplateSyntaxError, "only option for 'trans' is 'noop'" else: noop = False return (value, noop) value, noop = TranslateParser(token.contents).top() return TranslateNode(value, noop) def do_block_translate(parser, token): """ This will translate a block of text with parameters. Usage:: {% blocktrans with foo|filter as bar and baz|filter as boo %} This is {{ bar }} and {{ boo }}. {% endblocktrans %} Additionally, this supports pluralization:: {% blocktrans count var|length as count %} There is {{ count }} object. {% plural %} There are {{ count }} objects. {% endblocktrans %} This is much like ngettext, only in template syntax. """ class BlockTranslateParser(TokenParser): def top(self): countervar = None counter = None extra_context = {} while self.more(): tag = self.tag() if tag == 'with' or tag == 'and': value = self.value() if self.tag() != 'as': raise TemplateSyntaxError, "variable bindings in 'blocktrans' must be 'with value as variable'" extra_context[self.tag()] = VariableNode( parser.compile_filter(value)) elif tag == 'count': counter = parser.compile_filter(self.value()) if self.tag() != 'as': raise TemplateSyntaxError, "counter specification in 'blocktrans' must be 'count value as variable'" countervar = self.tag() else: raise TemplateSyntaxError, "unknown subtag %s for 'blocktrans' found" % tag return (countervar, counter, extra_context) countervar, counter, extra_context = BlockTranslateParser(token.contents).top() singular = [] plural = [] while parser.tokens: token = parser.next_token() if token.token_type in (TOKEN_VAR, TOKEN_TEXT): singular.append(token) else: break if countervar and counter: if token.contents.strip() != 'plural': raise TemplateSyntaxError, "'blocktrans' doesn't allow other block tags inside it" while parser.tokens: token = parser.next_token() if token.token_type in (TOKEN_VAR, TOKEN_TEXT): plural.append(token) else: break if token.contents.strip() != 'endblocktrans': raise TemplateSyntaxError, "'blocktrans' doesn't allow other block tags (seen %r) inside it" % token.contents return BlockTranslateNode(extra_context, singular, plural, countervar, counter) register.tag('get_available_languages', do_get_available_languages) register.tag('get_current_language', do_get_current_language) register.tag('get_current_language_bidi', do_get_current_language_bidi) register.tag('trans', do_translate) register.tag('blocktrans', do_block_translate)
greggian/TapdIn
django/templatetags/i18n.py
Python
apache-2.0
9,355
import pytest import numpy as np import noisily as ns # FIXME This has got to be an abuse of fixtures, right? @pytest.fixture(scope='module', params=[(1, 1), (37, 57), (128, 128)]) def indices2D(request): shape = request.param return np.transpose(np.indices(shape)) @pytest.fixture(scope='module', params=[(1, 1, 1), (29, 13, 31), (64, 64, 64)]) def indices3D(request): shape = request.param return np.transpose(np.indices(shape)) @pytest.fixture(scope='module', params=[(1, 1, 1, 1), (7, 11, 17, 13), (32, 32, 32, 32)]) def indices4D(request): shape = request.param return np.transpose(np.indices(shape)) @pytest.fixture(scope='module', params=[ns.perlin2D, ns.value2D, ns.open_simplex2D, ns.cell2D_range, ns.cell2D_range_inv, ns.cell2D_value, ns.cell2D_manhattan, ns.cell2D_manhattan_inv, ns.cell2D_manhattan_value]) def noise2D(request): return request.param @pytest.fixture(scope='module', params=[ns.perlin3D, ns.value3D, ns.open_simplex3D, ns.cell3D_range, ns.cell3D_range_inv, ns.cell3D_value, ns.cell3D_manhattan, ns.cell3D_manhattan_inv, ns.cell3D_manhattan_value]) def noise3D(request): return request.param @pytest.fixture(scope='module', params=[ns.perlin4D, ns.value4D, ns.open_simplex4D, ns.cell4D_range, ns.cell4D_range_inv, ns.cell4D_value, ns.cell4D_manhattan, ns.cell4D_manhattan_inv, ns.cell4D_manhattan_value]) def noise4D(request): return request.param @pytest.fixture(scope='module', params=[{'seed': 123}, {'period': 64}, {'seed': 12345, 'period': 16}]) def generator2D(request, noise2D): return ns.generator(noise2D, **request.param) @pytest.fixture(scope='module', params=[{'seed': 123}, {'period': 64}, {'seed': 12345, 'period': 16}]) def generator3D(request, noise3D): return ns.generator(noise3D, **request.param) @pytest.fixture(scope='module', params=[{'seed': 123}, {'period': 64}, {'seed': 12345, 'period': 16}]) def generator4D(request, noise4D): return ns.generator(noise4D, **request.param) def test_output2D(generator2D, indices2D): output = generator2D(indices2D) assert output.shape == indices2D.shape[:-1] assert output.size == indices2D.size // 2 assert np.array_equal(output, generator2D(indices2D)) def test_output3D(generator3D, indices3D): output = generator3D(indices3D) assert output.shape == indices3D.shape[:-1] assert output.size == indices3D.size // 3 assert np.array_equal(output, generator3D(indices3D)) def test_output4D(generator4D, indices4D): output = generator4D(indices4D) assert output.shape == indices4D.shape[:-1] assert output.size == indices4D.size // 4 assert np.array_equal(output, generator4D(indices4D))
tocubed/noisily
tests/test_noise.py
Python
apache-2.0
2,684
# Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import logging from django.conf import settings from django.http import HttpResponse from django import shortcuts from django import template from django.template.defaultfilters import title from django import urls from django.utils.http import urlencode from django.utils.safestring import mark_safe from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ from django.utils.translation import ngettext_lazy from django.utils.translation import npgettext_lazy from django.utils.translation import pgettext_lazy import netaddr from horizon import exceptions from horizon import messages from horizon import tables from horizon.templatetags import sizeformat from horizon.utils import filters from openstack_dashboard import api from openstack_dashboard.dashboards.project.floating_ips import workflows from openstack_dashboard.dashboards.project.instances import tabs from openstack_dashboard.dashboards.project.instances \ import utils as instance_utils from openstack_dashboard.dashboards.project.instances.workflows \ import resize_instance from openstack_dashboard.dashboards.project.instances.workflows \ import update_instance from openstack_dashboard import policy from openstack_dashboard.views import get_url_with_pagination LOG = logging.getLogger(__name__) ACTIVE_STATES = ("ACTIVE",) VOLUME_ATTACH_READY_STATES = ("ACTIVE", "SHUTOFF") SNAPSHOT_READY_STATES = ("ACTIVE", "SHUTOFF", "PAUSED", "SUSPENDED") SHELVE_READY_STATES = ("ACTIVE", "SHUTOFF", "PAUSED", "SUSPENDED") POWER_STATES = { 0: "NO STATE", 1: "RUNNING", 2: "BLOCKED", 3: "PAUSED", 4: "SHUTDOWN", 5: "SHUTOFF", 6: "CRASHED", 7: "SUSPENDED", 8: "FAILED", 9: "BUILDING", } PAUSE = 0 UNPAUSE = 1 SUSPEND = 0 RESUME = 1 SHELVE = 0 UNSHELVE = 1 def is_deleting(instance): task_state = getattr(instance, "OS-EXT-STS:task_state", None) if not task_state: return False return task_state.lower() == "deleting" class DeleteInstance(policy.PolicyTargetMixin, tables.DeleteAction): policy_rules = (("compute", "os_compute_api:servers:delete"),) help_text = _("Deleted instances are not recoverable.") default_message_level = "info" @staticmethod def action_present(count): return ngettext_lazy( "Delete Instance", "Delete Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Scheduled deletion of Instance", "Scheduled deletion of Instances", count ) def allowed(self, request, instance=None): error_state = False if instance: error_state = (instance.status == 'ERROR') return error_state or not is_deleting(instance) def action(self, request, obj_id): api.nova.server_delete(request, obj_id) class RebootInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "reboot" classes = ('btn-reboot',) policy_rules = (("compute", "os_compute_api:servers:reboot"),) help_text = _("Restarted instances will lose any data" " not saved in persistent storage.") action_type = "danger" @staticmethod def action_present(count): return ngettext_lazy( "Hard Reboot Instance", "Hard Reboot Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Hard Rebooted Instance", "Hard Rebooted Instances", count ) def allowed(self, request, instance=None): if instance is None: return True return ((instance.status in ACTIVE_STATES or instance.status == 'SHUTOFF') and not is_deleting(instance)) def action(self, request, obj_id): api.nova.server_reboot(request, obj_id, soft_reboot=False) class SoftRebootInstance(RebootInstance): name = "soft_reboot" @staticmethod def action_present(count): return ngettext_lazy( "Soft Reboot Instance", "Soft Reboot Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Soft Rebooted Instance", "Soft Rebooted Instances", count ) def action(self, request, obj_id): api.nova.server_reboot(request, obj_id, soft_reboot=True) def allowed(self, request, instance=None): if instance is not None: return instance.status in ACTIVE_STATES return True class RescueInstance(policy.PolicyTargetMixin, tables.LinkAction): name = "rescue" verbose_name = _("Rescue Instance") policy_rules = (("compute", "os_compute_api:os-rescue"),) classes = ("btn-rescue", "ajax-modal") url = "horizon:project:instances:rescue" def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) return urls.reverse(self.url, args=[instance_id]) def allowed(self, request, instance): return instance.status in ACTIVE_STATES class UnRescueInstance(tables.BatchAction): name = 'unrescue' classes = ("btn-unrescue",) @staticmethod def action_present(count): return ngettext_lazy( "Unrescue Instance", "Unrescue Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Unrescued Instance", "Unrescued Instances", count ) def action(self, request, obj_id): api.nova.server_unrescue(request, obj_id) def allowed(self, request, instance=None): if instance: return instance.status == "RESCUE" return False class TogglePause(tables.BatchAction): name = "pause" icon = "pause" @staticmethod def action_present(count): return ( ngettext_lazy( "Pause Instance", "Pause Instances", count ), ngettext_lazy( "Resume Instance", "Resume Instances", count ), ) @staticmethod def action_past(count): return ( ngettext_lazy( "Paused Instance", "Paused Instances", count ), ngettext_lazy( "Resumed Instance", "Resumed Instances", count ), ) def allowed(self, request, instance=None): if not instance: return False self.paused = instance.status == "PAUSED" if self.paused: self.current_present_action = UNPAUSE policy_rules = ( ("compute", "os_compute_api:os-pause-server:unpause"),) else: self.current_present_action = PAUSE policy_rules = ( ("compute", "os_compute_api:os-pause-server:pause"),) has_permission = policy.check( policy_rules, request, target={'project_id': getattr(instance, 'tenant_id', None)}) return (has_permission and (instance.status in ACTIVE_STATES or self.paused) and not is_deleting(instance)) def action(self, request, obj_id): if self.paused: api.nova.server_unpause(request, obj_id) self.current_past_action = UNPAUSE else: api.nova.server_pause(request, obj_id) self.current_past_action = PAUSE class ToggleSuspend(tables.BatchAction): name = "suspend" classes = ("btn-suspend",) @staticmethod def action_present(count): return ( ngettext_lazy( "Suspend Instance", "Suspend Instances", count ), ngettext_lazy( "Resume Instance", "Resume Instances", count ), ) @staticmethod def action_past(count): return ( ngettext_lazy( "Suspended Instance", "Suspended Instances", count ), ngettext_lazy( "Resumed Instance", "Resumed Instances", count ), ) def allowed(self, request, instance=None): if not instance: return False self.suspended = instance.status == "SUSPENDED" if self.suspended: self.current_present_action = RESUME policy_rules = ( ("compute", "os_compute_api:os-suspend-server:resume"),) else: self.current_present_action = SUSPEND policy_rules = ( ("compute", "os_compute_api:os-suspend-server:suspend"),) has_permission = policy.check( policy_rules, request, target={'project_id': getattr(instance, 'tenant_id', None)}) return (has_permission and (instance.status in ACTIVE_STATES or self.suspended) and not is_deleting(instance)) def action(self, request, obj_id): if self.suspended: api.nova.server_resume(request, obj_id) self.current_past_action = RESUME else: api.nova.server_suspend(request, obj_id) self.current_past_action = SUSPEND class ToggleShelve(tables.BatchAction): name = "shelve" icon = "shelve" @staticmethod def action_present(count): return ( ngettext_lazy( "Shelve Instance", "Shelve Instances", count ), ngettext_lazy( "Unshelve Instance", "Unshelve Instances", count ), ) @staticmethod def action_past(count): return ( ngettext_lazy( "Shelved Instance", "Shelved Instances", count ), ngettext_lazy( "Unshelved Instance", "Unshelved Instances", count ), ) def allowed(self, request, instance=None): if not instance: return False if not request.user.is_superuser and getattr( instance, 'locked', False): return False self.shelved = instance.status == "SHELVED_OFFLOADED" if self.shelved: self.current_present_action = UNSHELVE policy_rules = (("compute", "os_compute_api:os-shelve:unshelve"),) else: self.current_present_action = SHELVE policy_rules = (("compute", "os_compute_api:os-shelve:shelve"),) has_permission = policy.check( policy_rules, request, target={'project_id': getattr(instance, 'tenant_id', None)}) return (has_permission and (instance.status in SHELVE_READY_STATES or self.shelved) and not is_deleting(instance)) def action(self, request, obj_id): if self.shelved: api.nova.server_unshelve(request, obj_id) self.current_past_action = UNSHELVE else: api.nova.server_shelve(request, obj_id) self.current_past_action = SHELVE class LaunchLinkNG(tables.LinkAction): name = "launch-ng" verbose_name = _("Launch Instance") url = "horizon:project:instances:index" ajax = False classes = ("btn-launch", ) icon = "cloud-upload" policy_rules = (("compute", "os_compute_api:servers:create"),) def __init__(self, attrs=None, **kwargs): kwargs['preempt'] = True super().__init__(attrs, **kwargs) def allowed(self, request, datum): try: limits = api.nova.tenant_absolute_limits(request, reserved=True) instances_available = limits['maxTotalInstances'] \ - limits['totalInstancesUsed'] cores_available = limits['maxTotalCores'] \ - limits['totalCoresUsed'] ram_available = limits['maxTotalRAMSize'] - limits['totalRAMUsed'] if instances_available <= 0 or cores_available <= 0 \ or ram_available <= 0: if "disabled" not in self.classes: self.classes = list(self.classes) + ['disabled'] self.verbose_name = format_lazy( '{verbose_name} {quota_exceeded}', verbose_name=self.verbose_name, quota_exceeded=_("(Quota exceeded)")) else: self.verbose_name = _("Launch Instance") classes = [c for c in self.classes if c != "disabled"] self.classes = classes except Exception: LOG.exception("Failed to retrieve quota information") # If we can't get the quota information, leave it to the # API to check when launching return True # The action should always be displayed def single(self, table, request, object_id=None): self.allowed(request, None) return HttpResponse(self.render(is_table_action=True)) def get_default_attrs(self): url = urls.reverse(self.url) ngclick = "modal.openLaunchInstanceWizard(" \ "{ successUrl: '%s' })" % url self.attrs.update({ 'ng-controller': 'LaunchInstanceModalController as modal', 'ng-click': ngclick }) return super().get_default_attrs() def get_link_url(self, datum=None): return "javascript:void(0);" class EditInstance(policy.PolicyTargetMixin, tables.LinkAction): name = "edit" verbose_name = _("Edit Instance") url = "horizon:project:instances:update" classes = ("ajax-modal",) icon = "pencil" policy_rules = (("compute", "os_compute_api:servers:update"),) def get_link_url(self, project): return self._get_link_url(project, 'instance_info') def _get_link_url(self, project, step_slug): base_url = urls.reverse(self.url, args=[project.id]) next_url = self.table.get_full_url() params = {"step": step_slug, update_instance.UpdateInstance.redirect_param_name: next_url} param = urlencode(params) return "?".join([base_url, param]) def allowed(self, request, instance): return not is_deleting(instance) class EditInstanceSecurityGroups(EditInstance): name = "edit_secgroups" verbose_name = _("Edit Security Groups") def get_link_url(self, project): return self._get_link_url(project, 'update_security_groups') def allowed(self, request, instance=None): if not api.base.is_service_enabled(request, 'network'): return False return (instance.status in ACTIVE_STATES and not is_deleting(instance) and request.user.tenant_id == instance.tenant_id) class EditPortSecurityGroups(tables.LinkAction): name = "edit_port_secgroups" verbose_name = _("Edit Port Security Groups") policy_rules = (("network", "update_security_group"),) url = "horizon:project:instances:detail" icon = "pencil" def get_link_url(self, instance): base_url = urls.reverse(self.url, args=[instance.id]) return '%s?tab=%s__%s' % (base_url, 'instance_details', 'interfaces') class CreateSnapshot(policy.PolicyTargetMixin, tables.LinkAction): name = "snapshot" verbose_name = _("Create Snapshot") url = "horizon:project:images:snapshots:create" classes = ("ajax-modal",) icon = "camera" policy_rules = (("compute", "os_compute_api:snapshot"),) def allowed(self, request, instance=None): return instance.status in SNAPSHOT_READY_STATES \ and not is_deleting(instance) class ConsoleLink(policy.PolicyTargetMixin, tables.LinkAction): name = "console" verbose_name = _("Console") url = "horizon:project:instances:detail" classes = ("btn-console",) policy_rules = (("compute", "os_compute_api:os-consoles:index"),) def allowed(self, request, instance=None): # We check if ConsoleLink is allowed only if settings.CONSOLE_TYPE is # not set at all, or if it's set to any value other than None or False. return (bool(settings.CONSOLE_TYPE) and instance.status in ACTIVE_STATES and not is_deleting(instance)) def get_link_url(self, datum): base_url = super().get_link_url(datum) tab_query_string = tabs.ConsoleTab( tabs.InstanceDetailTabs).get_query_string() return "?".join([base_url, tab_query_string]) class LogLink(policy.PolicyTargetMixin, tables.LinkAction): name = "log" verbose_name = _("View Log") url = "horizon:project:instances:detail" classes = ("btn-log",) policy_rules = (("compute", "os_compute_api:os-console-output"),) def allowed(self, request, instance=None): return instance.status in ACTIVE_STATES and not is_deleting(instance) def get_link_url(self, datum): base_url = super().get_link_url(datum) tab_query_string = tabs.LogTab( tabs.InstanceDetailTabs).get_query_string() return "?".join([base_url, tab_query_string]) class ResizeLink(policy.PolicyTargetMixin, tables.LinkAction): name = "resize" verbose_name = _("Resize Instance") url = "horizon:project:instances:resize" classes = ("ajax-modal", "btn-resize") policy_rules = (("compute", "os_compute_api:servers:resize"),) action_type = "danger" def get_link_url(self, project): return self._get_link_url(project, 'flavor_choice') def _get_link_url(self, project, step_slug): base_url = urls.reverse(self.url, args=[project.id]) next_url = self.table.get_full_url() params = {"step": step_slug, resize_instance.ResizeInstance.redirect_param_name: next_url} param = urlencode(params) return "?".join([base_url, param]) def allowed(self, request, instance): return ((instance.status in ACTIVE_STATES or instance.status == 'SHUTOFF') and not is_deleting(instance)) class ConfirmResize(policy.PolicyTargetMixin, tables.Action): name = "confirm" verbose_name = _("Confirm Resize/Migrate") classes = ("btn-confirm", "btn-action-required") policy_rules = (("compute", "os_compute_api:servers:confirm_resize"),) def allowed(self, request, instance): return instance.status == 'VERIFY_RESIZE' def single(self, table, request, obj_id): instance = table.get_object_by_id(obj_id) try: api.nova.server_confirm_resize(request, instance.id) except Exception: exceptions.handle(request, _('Unable to confirm resize instance "%s".') % (instance.name or instance.id)) return shortcuts.redirect(request.get_full_path()) class RevertResize(policy.PolicyTargetMixin, tables.Action): name = "revert" verbose_name = _("Revert Resize/Migrate") classes = ("btn-revert", "btn-action-required") policy_rules = (("compute", "os_compute_api:servers:revert_resize"),) def allowed(self, request, instance): return instance.status == 'VERIFY_RESIZE' def single(self, table, request, obj_id): instance = table.get_object_by_id(obj_id) try: api.nova.server_revert_resize(request, instance.id) except Exception: exceptions.handle(request, _('Unable to revert resize instance "%s".') % (instance.name or instance.id)) class RebuildInstance(policy.PolicyTargetMixin, tables.LinkAction): name = "rebuild" verbose_name = _("Rebuild Instance") classes = ("btn-rebuild", "ajax-modal") url = "horizon:project:instances:rebuild" policy_rules = (("compute", "os_compute_api:servers:rebuild"),) action_type = "danger" def allowed(self, request, instance): return ((instance.status in ACTIVE_STATES or instance.status == 'SHUTOFF') and not is_deleting(instance)) def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) return urls.reverse(self.url, args=[instance_id]) class DecryptInstancePassword(tables.LinkAction): name = "decryptpassword" verbose_name = _("Retrieve Password") classes = ("btn-decrypt", "ajax-modal") url = "horizon:project:instances:decryptpassword" def allowed(self, request, instance): return (settings.OPENSTACK_ENABLE_PASSWORD_RETRIEVE and (instance.status in ACTIVE_STATES or instance.status == 'SHUTOFF') and not is_deleting(instance) and get_keyname(instance) is not None) def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) keypair_name = get_keyname(datum) return urls.reverse(self.url, args=[instance_id, keypair_name]) class AssociateIP(policy.PolicyTargetMixin, tables.LinkAction): name = "associate" verbose_name = _("Associate Floating IP") url = "horizon:project:floating_ips:associate" classes = ("ajax-modal",) icon = "link" policy_rules = (("network", "update_floatingip"),) def allowed(self, request, instance): if not api.base.is_service_enabled(request, 'network'): return False if not api.neutron.floating_ip_supported(request): return False if api.neutron.floating_ip_simple_associate_supported(request): return False if instance.status == "ERROR": return False for addresses in instance.addresses.values(): for address in addresses: if address.get('OS-EXT-IPS:type') == "floating": return False return not is_deleting(instance) def get_link_url(self, datum): base_url = urls.reverse(self.url) next_url = self.table.get_full_url() params = { "instance_id": self.table.get_object_id(datum), workflows.IPAssociationWorkflow.redirect_param_name: next_url} params = urlencode(params) return "?".join([base_url, params]) class DisassociateIP(tables.LinkAction): name = "disassociate" verbose_name = _("Disassociate Floating IP") url = "horizon:project:instances:disassociate" classes = ("btn-disassociate", 'ajax-modal') policy_rules = (("network", "update_floatingip"),) action_type = "danger" def allowed(self, request, instance): if not api.base.is_service_enabled(request, 'network'): return False if not api.neutron.floating_ip_supported(request): return False for addresses in instance.addresses.values(): for address in addresses: if address.get('OS-EXT-IPS:type') == "floating": return not is_deleting(instance) return False class UpdateMetadata(policy.PolicyTargetMixin, tables.LinkAction): name = "update_metadata" verbose_name = _("Update Metadata") ajax = False icon = "pencil" attrs = {"ng-controller": "MetadataModalHelperController as modal"} policy_rules = (("compute", "os_compute_api:server-metadata:update"),) def __init__(self, attrs=None, **kwargs): kwargs['preempt'] = True super().__init__(attrs, **kwargs) def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) self.attrs['ng-click'] = ( "modal.openMetadataModal('instance', '%s', true, 'metadata')" % instance_id) return "javascript:void(0);" def allowed(self, request, instance=None): return (instance and instance.status.lower() != 'error') def instance_fault_to_friendly_message(instance): fault = getattr(instance, 'fault', {}) message = fault.get('message', _("Unknown")) default_message = _("Please try again later [Error: %s].") % message fault_map = { 'NoValidHost': _("There is not enough capacity for this " "flavor in the selected availability zone. " "Try again later or select a different availability " "zone.") } return fault_map.get(message, default_message) def get_instance_error(instance): if instance.status.lower() != 'error': return None message = instance_fault_to_friendly_message(instance) preamble = _('Failed to perform requested operation on instance "%s", the ' 'instance has an error status') % instance.name or instance.id message = format_lazy('{preamble}: {message}', preamble=preamble, message=message) return message class UpdateRow(tables.Row): ajax = True def get_data(self, request, instance_id): instance = api.nova.server_get(request, instance_id) try: instance.full_flavor = instance_utils.resolve_flavor(request, instance) except Exception: exceptions.handle(request, _('Unable to retrieve flavor information ' 'for instance "%s".') % instance_id, ignore=True) try: api.network.servers_update_addresses(request, [instance]) except Exception: exceptions.handle(request, _('Unable to retrieve Network information ' 'for instance "%s".') % instance_id, ignore=True) error = get_instance_error(instance) if error: messages.error(request, error) return instance class StartInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "start" classes = ('btn-confirm',) policy_rules = (("compute", "os_compute_api:servers:start"),) @staticmethod def action_present(count): return ngettext_lazy( "Start Instance", "Start Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Started Instance", "Started Instances", count ) def allowed(self, request, instance): return ((instance is None) or (instance.status in ("SHUTDOWN", "SHUTOFF", "CRASHED"))) def action(self, request, obj_id): api.nova.server_start(request, obj_id) class StopInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "stop" policy_rules = (("compute", "os_compute_api:servers:stop"),) help_text = _("The instance(s) will be shut off.") action_type = "danger" @staticmethod def action_present(count): return npgettext_lazy( "Action to perform (the instance is currently running)", "Shut Off Instance", "Shut Off Instances", count ) @staticmethod def action_past(count): return npgettext_lazy( "Past action (the instance is currently already Shut Off)", "Shut Off Instance", "Shut Off Instances", count ) def allowed(self, request, instance): return (instance is None or (get_power_state(instance) in ("RUNNING", "SUSPENDED") and not is_deleting(instance))) def action(self, request, obj_id): api.nova.server_stop(request, obj_id) class LockInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "lock" policy_rules = (("compute", "os_compute_api:os-lock-server:lock"),) @staticmethod def action_present(count): return ngettext_lazy( "Lock Instance", "Lock Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Locked Instance", "Locked Instances", count ) # to only allow unlocked instances to be locked def allowed(self, request, instance): if getattr(instance, 'locked', False): return False if not api.nova.is_feature_available(request, "locked_attribute"): return False return True def action(self, request, obj_id): api.nova.server_lock(request, obj_id) class UnlockInstance(policy.PolicyTargetMixin, tables.BatchAction): name = "unlock" policy_rules = (("compute", "os_compute_api:os-lock-server:unlock"),) @staticmethod def action_present(count): return ngettext_lazy( "Unlock Instance", "Unlock Instances", count ) @staticmethod def action_past(count): return ngettext_lazy( "Unlocked Instance", "Unlocked Instances", count ) # to only allow locked instances to be unlocked def allowed(self, request, instance): if not getattr(instance, 'locked', True): return False if not api.nova.is_feature_available(request, "locked_attribute"): return False return True def action(self, request, obj_id): api.nova.server_unlock(request, obj_id) class AttachVolume(tables.LinkAction): name = "attach_volume" verbose_name = _("Attach Volume") url = "horizon:project:instances:attach_volume" classes = ("ajax-modal",) policy_rules = ( ("compute", "os_compute_api:os-volumes-attachments:create"),) # This action should be disabled if the instance # is not active, or the instance is being deleted # or cinder is not enabled def allowed(self, request, instance=None): return (instance.status in ("ACTIVE") and not is_deleting(instance) and api.cinder.is_volume_service_enabled(request)) class DetachVolume(AttachVolume): name = "detach_volume" verbose_name = _("Detach Volume") url = "horizon:project:instances:detach_volume" policy_rules = ( ("compute", "os_compute_api:os-volumes-attachments:delete"),) # This action should be disabled if the instance # is not active, or the instance is being deleted # or cinder is not enabled def allowed(self, request, instance=None): return (instance.status in ("ACTIVE") and not is_deleting(instance) and api.cinder.is_volume_service_enabled(request)) class AttachInterface(policy.PolicyTargetMixin, tables.LinkAction): name = "attach_interface" verbose_name = _("Attach Interface") classes = ("btn-confirm", "ajax-modal") url = "horizon:project:instances:attach_interface" policy_rules = (("compute", "os_compute_api:os-attach-interfaces"),) def allowed(self, request, instance): return ((instance.status in ACTIVE_STATES or instance.status == 'SHUTOFF') and not is_deleting(instance) and api.base.is_service_enabled(request, 'network')) def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) return urls.reverse(self.url, args=[instance_id]) class DetachInterface(policy.PolicyTargetMixin, tables.LinkAction): name = "detach_interface" verbose_name = _("Detach Interface") classes = ("btn-confirm", "ajax-modal") url = "horizon:project:instances:detach_interface" policy_rules = (("compute", "os_compute_api:os-attach-interfaces:delete"),) def allowed(self, request, instance): if not api.base.is_service_enabled(request, 'network'): return False if is_deleting(instance): return False if (instance.status not in ACTIVE_STATES and instance.status != 'SHUTOFF'): return False for addresses in instance.addresses.values(): for address in addresses: if address.get('OS-EXT-IPS:type') == "fixed": return True return False def get_link_url(self, datum): instance_id = self.table.get_object_id(datum) return urls.reverse(self.url, args=[instance_id]) def get_ips(instance): template_name = 'project/instances/_instance_ips.html' ip_groups = {} for ip_group, addresses in instance.addresses.items(): ips = [addr['addr'] for addr in addresses] ips.sort(key=lambda ip: netaddr.IPAddress(ip).version) ip_groups[ip_group] = ips context = { "ip_groups": ip_groups, } return template.loader.render_to_string(template_name, context) def get_flavor(instance): if hasattr(instance, "full_flavor"): template_name = 'project/instances/_instance_flavor.html' size_ram = sizeformat.mb_float_format(instance.full_flavor.ram) if instance.full_flavor.disk > 0: size_disk = sizeformat.diskgbformat(instance.full_flavor.disk) else: size_disk = _("%s GB") % "0" context = { "name": instance.full_flavor.name, "id": instance.id, "size_disk": size_disk, "size_ram": size_ram, "vcpus": instance.full_flavor.vcpus, "flavor_id": getattr(instance.full_flavor, 'id', None) } return template.loader.render_to_string(template_name, context) return _("Not available") def get_keyname(instance): if hasattr(instance, "key_name"): keyname = instance.key_name return keyname return _("Not available") def get_power_state(instance): return POWER_STATES.get(getattr(instance, "OS-EXT-STS:power_state", 0), '') STATUS_DISPLAY_CHOICES = ( ("deleted", pgettext_lazy("Current status of an Instance", "Deleted")), ("active", pgettext_lazy("Current status of an Instance", "Active")), ("shutoff", pgettext_lazy("Current status of an Instance", "Shutoff")), ("suspended", pgettext_lazy("Current status of an Instance", "Suspended")), ("paused", pgettext_lazy("Current status of an Instance", "Paused")), ("error", pgettext_lazy("Current status of an Instance", "Error")), ("resize", pgettext_lazy("Current status of an Instance", "Resize/Migrate")), ("verify_resize", pgettext_lazy("Current status of an Instance", "Confirm or Revert Resize/Migrate")), ("revert_resize", pgettext_lazy( "Current status of an Instance", "Revert Resize/Migrate")), ("reboot", pgettext_lazy("Current status of an Instance", "Reboot")), ("hard_reboot", pgettext_lazy("Current status of an Instance", "Hard Reboot")), ("password", pgettext_lazy("Current status of an Instance", "Password")), ("rebuild", pgettext_lazy("Current status of an Instance", "Rebuild")), ("migrating", pgettext_lazy("Current status of an Instance", "Migrating")), ("build", pgettext_lazy("Current status of an Instance", "Build")), ("rescue", pgettext_lazy("Current status of an Instance", "Rescue")), ("soft-delete", pgettext_lazy("Current status of an Instance", "Soft Deleted")), ("shelved", pgettext_lazy("Current status of an Instance", "Shelved")), ("shelved_offloaded", pgettext_lazy("Current status of an Instance", "Shelved Offloaded")), # these vm states are used when generating CSV usage summary ("building", pgettext_lazy("Current status of an Instance", "Building")), ("stopped", pgettext_lazy("Current status of an Instance", "Stopped")), ("rescued", pgettext_lazy("Current status of an Instance", "Rescued")), ("resized", pgettext_lazy("Current status of an Instance", "Resized")), ) TASK_DISPLAY_NONE = pgettext_lazy("Task status of an Instance", "None") # Mapping of task states taken from Nova's nova/compute/task_states.py TASK_DISPLAY_CHOICES = ( ("scheduling", pgettext_lazy("Task status of an Instance", "Scheduling")), ("block_device_mapping", pgettext_lazy("Task status of an Instance", "Block Device Mapping")), ("networking", pgettext_lazy("Task status of an Instance", "Networking")), ("spawning", pgettext_lazy("Task status of an Instance", "Spawning")), ("image_snapshot", pgettext_lazy("Task status of an Instance", "Snapshotting")), ("image_snapshot_pending", pgettext_lazy("Task status of an Instance", "Image Snapshot Pending")), ("image_pending_upload", pgettext_lazy("Task status of an Instance", "Image Pending Upload")), ("image_uploading", pgettext_lazy("Task status of an Instance", "Image Uploading")), ("image_backup", pgettext_lazy("Task status of an Instance", "Image Backup")), ("updating_password", pgettext_lazy("Task status of an Instance", "Updating Password")), ("resize_prep", pgettext_lazy("Task status of an Instance", "Preparing Resize or Migrate")), ("resize_migrating", pgettext_lazy("Task status of an Instance", "Resizing or Migrating")), ("resize_migrated", pgettext_lazy("Task status of an Instance", "Resized or Migrated")), ("resize_finish", pgettext_lazy("Task status of an Instance", "Finishing Resize or Migrate")), ("resize_reverting", pgettext_lazy("Task status of an Instance", "Reverting Resize or Migrate")), ("resize_confirming", pgettext_lazy("Task status of an Instance", "Confirming Resize or Migrate")), ("rebooting", pgettext_lazy("Task status of an Instance", "Rebooting")), ("reboot_pending", pgettext_lazy("Task status of an Instance", "Reboot Pending")), ("reboot_started", pgettext_lazy("Task status of an Instance", "Reboot Started")), ("rebooting_hard", pgettext_lazy("Task status of an Instance", "Hard Rebooting")), ("reboot_pending_hard", pgettext_lazy("Task status of an Instance", "Hard Reboot Pending")), ("reboot_started_hard", pgettext_lazy("Task status of an Instance", "Hard Reboot Started")), ("pausing", pgettext_lazy("Task status of an Instance", "Pausing")), ("unpausing", pgettext_lazy("Task status of an Instance", "Resuming")), ("suspending", pgettext_lazy("Task status of an Instance", "Suspending")), ("resuming", pgettext_lazy("Task status of an Instance", "Resuming")), ("powering-off", pgettext_lazy("Task status of an Instance", "Powering Off")), ("powering-on", pgettext_lazy("Task status of an Instance", "Powering On")), ("rescuing", pgettext_lazy("Task status of an Instance", "Rescuing")), ("unrescuing", pgettext_lazy("Task status of an Instance", "Unrescuing")), ("rebuilding", pgettext_lazy("Task status of an Instance", "Rebuilding")), ("rebuild_block_device_mapping", pgettext_lazy( "Task status of an Instance", "Rebuild Block Device Mapping")), ("rebuild_spawning", pgettext_lazy("Task status of an Instance", "Rebuild Spawning")), ("migrating", pgettext_lazy("Task status of an Instance", "Migrating")), ("deleting", pgettext_lazy("Task status of an Instance", "Deleting")), ("soft-deleting", pgettext_lazy("Task status of an Instance", "Soft Deleting")), ("restoring", pgettext_lazy("Task status of an Instance", "Restoring")), ("shelving", pgettext_lazy("Task status of an Instance", "Shelving")), ("shelving_image_pending_upload", pgettext_lazy( "Task status of an Instance", "Shelving Image Pending Upload")), ("shelving_image_uploading", pgettext_lazy("Task status of an Instance", "Shelving Image Uploading")), ("shelving_offloading", pgettext_lazy("Task status of an Instance", "Shelving Offloading")), ("unshelving", pgettext_lazy("Task status of an Instance", "Unshelving")), ) POWER_DISPLAY_CHOICES = ( ("NO STATE", pgettext_lazy("Power state of an Instance", "No State")), ("RUNNING", pgettext_lazy("Power state of an Instance", "Running")), ("BLOCKED", pgettext_lazy("Power state of an Instance", "Blocked")), ("PAUSED", pgettext_lazy("Power state of an Instance", "Paused")), ("SHUTDOWN", pgettext_lazy("Power state of an Instance", "Shut Down")), ("SHUTOFF", pgettext_lazy("Power state of an Instance", "Shut Off")), ("CRASHED", pgettext_lazy("Power state of an Instance", "Crashed")), ("SUSPENDED", pgettext_lazy("Power state of an Instance", "Suspended")), ("FAILED", pgettext_lazy("Power state of an Instance", "Failed")), ("BUILDING", pgettext_lazy("Power state of an Instance", "Building")), ) INSTANCE_FILTER_CHOICES = ( ('uuid', _("Instance ID ="), True), ('name', _("Instance Name ="), True), ('image', _("Image ID ="), True), ('image_name', _("Image Name ="), True), ('ip', _("IPv4 Address ="), True), ('ip6', _("IPv6 Address ="), True, None, api.neutron.is_enabled_by_config('enable_ipv6')), ('flavor', _("Flavor ID ="), True), ('flavor_name', _("Flavor Name ="), True), ('key_name', _("Key Pair Name ="), True), ('status', _("Status ="), True), ('availability_zone', _("Availability Zone ="), True), ('changes-since', _("Changes Since"), True, _("Filter by an ISO 8061 formatted time, e.g. 2016-06-14T06:27:59Z")), ('vcpus', _("vCPUs ="), True), ) class InstancesFilterAction(tables.FilterAction): filter_type = "server" filter_choices = INSTANCE_FILTER_CHOICES def render_locked(instance): if not hasattr(instance, 'locked'): return "" if instance.locked: icon_classes = "fa fa-fw fa-lock" help_tooltip = _("This instance is currently locked. To enable more " "actions on it, please unlock it by selecting Unlock " "Instance from the actions menu.") else: icon_classes = "fa fa-fw fa-unlock text-muted" help_tooltip = _("This instance is unlocked.") locked_status = ('<span data-toggle="tooltip" title="{}" class="{}">' '</span>').format(help_tooltip, icon_classes) return mark_safe(locked_status) def get_server_detail_link(obj, request): return get_url_with_pagination(request, InstancesTable._meta.pagination_param, InstancesTable._meta.prev_pagination_param, 'horizon:project:instances:detail', obj.id) class InstancesTable(tables.DataTable): TASK_STATUS_CHOICES = ( (None, True), ("none", True) ) STATUS_CHOICES = ( ("active", True), ("shutoff", True), ("suspended", True), ("paused", True), ("error", False), ("rescue", True), ("shelved", True), ("shelved_offloaded", True), ) name = tables.WrappingColumn("name", link=get_server_detail_link, verbose_name=_("Instance Name")) image_name = tables.WrappingColumn("image_name", verbose_name=_("Image Name")) ip = tables.Column(get_ips, verbose_name=_("IP Address"), attrs={'data-type': "ip"}) flavor = tables.Column(get_flavor, sortable=False, verbose_name=_("Flavor")) keypair = tables.Column(get_keyname, verbose_name=_("Key Pair")) status = tables.Column("status", filters=(title, filters.replace_underscores), verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES, display_choices=STATUS_DISPLAY_CHOICES) locked = tables.Column(render_locked, verbose_name="", sortable=False) az = tables.Column("availability_zone", verbose_name=_("Availability Zone")) task = tables.Column("OS-EXT-STS:task_state", verbose_name=_("Task"), empty_value=TASK_DISPLAY_NONE, status=True, status_choices=TASK_STATUS_CHOICES, display_choices=TASK_DISPLAY_CHOICES) state = tables.Column(get_power_state, filters=(title, filters.replace_underscores), verbose_name=_("Power State"), display_choices=POWER_DISPLAY_CHOICES) created = tables.Column("created", verbose_name=_("Age"), filters=(filters.parse_isotime, filters.timesince_sortable), attrs={'data-type': 'timesince'}) class Meta(object): name = "instances" verbose_name = _("Instances") status_columns = ["status", "task"] row_class = UpdateRow table_actions_menu = (StartInstance, StopInstance, SoftRebootInstance) launch_actions = (LaunchLinkNG,) table_actions = launch_actions + (DeleteInstance, InstancesFilterAction) row_actions = (StartInstance, ConfirmResize, RevertResize, CreateSnapshot, AssociateIP, DisassociateIP, AttachInterface, DetachInterface, EditInstance, AttachVolume, DetachVolume, UpdateMetadata, DecryptInstancePassword, EditInstanceSecurityGroups, EditPortSecurityGroups, ConsoleLink, LogLink, RescueInstance, UnRescueInstance, TogglePause, ToggleSuspend, ToggleShelve, ResizeLink, LockInstance, UnlockInstance, SoftRebootInstance, RebootInstance, StopInstance, RebuildInstance, DeleteInstance)
openstack/horizon
openstack_dashboard/dashboards/project/instances/tables.py
Python
apache-2.0
48,198
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). from __future__ import absolute_import from pex.fetcher import URLFetcher from pex.network_configuration import NetworkConfiguration from pex.requirements import Constraint, parse_requirement_file, parse_requirement_strings from pex.typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Iterable, List, Optional import attr # vendor:skip from pex.requirements import ParsedRequirement else: from pex.third_party import attr @attr.s(frozen=True) class RequirementConfiguration(object): requirements = attr.ib(default=None) # type: Optional[Iterable[str]] requirement_files = attr.ib(default=None) # type: Optional[Iterable[str]] constraint_files = attr.ib(default=None) # type: Optional[Iterable[str]] def parse_requirements(self, network_configuration=None): # type: (Optional[NetworkConfiguration]) -> Iterable[ParsedRequirement] parsed_requirements = [] # type: List[ParsedRequirement] if self.requirements: parsed_requirements.extend(parse_requirement_strings(self.requirements)) if self.requirement_files: fetcher = URLFetcher(network_configuration=network_configuration) for requirement_file in self.requirement_files: parsed_requirements.extend( requirement_or_constraint for requirement_or_constraint in parse_requirement_file( requirement_file, is_constraints=False, fetcher=fetcher ) if not isinstance(requirement_or_constraint, Constraint) ) return parsed_requirements def parse_constraints(self, network_configuration=None): # type: (Optional[NetworkConfiguration]) -> Iterable[Constraint] parsed_constraints = [] # type: List[Constraint] if self.constraint_files: fetcher = URLFetcher(network_configuration=network_configuration) for constraint_file in self.constraint_files: parsed_constraints.extend( requirement_or_constraint for requirement_or_constraint in parse_requirement_file( constraint_file, is_constraints=True, fetcher=fetcher ) if isinstance(requirement_or_constraint, Constraint) ) return parsed_constraints
pantsbuild/pex
pex/resolve/requirement_configuration.py
Python
apache-2.0
2,532
""" Tests for the MDK public API that are easier to do in Python. """ from time import time from builtins import range from past.builtins import unicode from unittest import TestCase from tempfile import mkdtemp from collections import Counter import configparser import hypothesis.strategies as st from hypothesis import given, assume from mdk import MDKImpl from mdk_runtime import fakeRuntime from mdk_runtime.actors import _QuarkRuntimeLaterCaller from mdk_discovery import ( ReplaceCluster, NodeActive, RecordingFailurePolicyFactory, ) from mdk_protocol import Close, ProtocolError from .common import ( create_node, SANDBOX_ENV, MDKConnector, create_mdk_with_faketracer, ) class MDKInitializationTestCase(TestCase): """ Tests for top-level MDK API startup. """ def test_no_datawire_token(self): """ If DATAWIRE_TOKEN is not set neither the TracingClient nor the DiscoClient are started. """ # Disable connecting to our Discovery server: runtime = fakeRuntime() runtime.getEnvVarsService().set("MDK_DISCOVERY_SOURCE", "synapse:path=" + mkdtemp()) # Start the MDK: mdk = MDKImpl(runtime) mdk.start() # Do a bunch of logging: session = mdk.session() session.info("category", "hello!") session.error("category", "ono") session.warn("category", "gazoots") session.critical("category", "aaaaaaa") session.debug("category", "behold!") # Time passes... scheduleService = runtime.getScheduleService() for i in range(10): scheduleService.advance(1.0) scheduleService.pump() # No WebSocket connections made: self.assertFalse(runtime.getWebSocketsService().fakeActors) def add_bools(list_of_lists): """ Given recursive list that can contain other lists, return tuple of that plus a booleans strategy for each list. """ l = [] def count(recursive): l.append(1) for child in recursive: if isinstance(child, list): count(child) count(list_of_lists) return st.tuples(st.just(list_of_lists), st.tuples(*[st.sampled_from([True, False]) for i in l])) class InteractionTestCase(TestCase): """Tests for the Session interaction API.""" def init(self): """Initialize an empty environment.""" self.connector = MDKConnector(RecordingFailurePolicyFactory()) # Because we want to use blocking resolve() we need async message delivery: self.connector.runtime.dispatcher.pump() self.connector.runtime.dispatcher.callLater = _QuarkRuntimeLaterCaller() self.runtime = self.connector.runtime self.mdk = self.connector.mdk self.disco = self.mdk._disco # Create a session: self.session = self.mdk.session() def setUp(self): self.init() # Register some nodes: self.node1 = create_node("a1", "service1") self.node2 = create_node("a2", "service1") self.node3 = create_node("b1", "service2") self.node4 = create_node("b2", "service2") self.all_nodes = set([self.node1, self.node2, self.node3, self.node4]) self.disco.onMessage(None, ReplaceCluster("service1", SANDBOX_ENV, [self.node1, self.node2])) self.disco.onMessage(None, ReplaceCluster("service2", SANDBOX_ENV, [self.node3, self.node4])) def assertPolicyState(self, policies, successes, failures): """ Assert that the given FailurePolicy instances has the given number of success() and failure() calls. """ for policy in policies: self.assertEqual((policy.successes, policy.failures), (successes, failures)) def test_successfulInteraction(self): """ All nodes resolved within a successful interaction are marked as succeeding to connect. """ self.session.start_interaction() node = self.session.resolve("service1", "1.0") another_node = self.session.resolve("service2", "1.0") self.session.finish_interaction() expected_successful = [self.disco.failurePolicy(node), self.disco.failurePolicy(another_node)] expected_nothing = list(self.disco.failurePolicy(n) for n in self.all_nodes if n.address not in [node.address, another_node.address]) self.assertPolicyState(expected_successful, 1, 0) self.assertPolicyState(expected_nothing, 0, 0) def test_failedInteraction(self): """All nodes resolved with a failing interaction are marked as failures.""" self.session.start_interaction() node = self.session.resolve("service1", "1.0") another_node = self.session.resolve("service2", "1.0") self.session.fail_interaction("OHNO") self.session.finish_interaction() expected_failed = [self.disco.failurePolicy(node), self.disco.failurePolicy(another_node)] expected_nothing = list(self.disco.failurePolicy(n) for n in self.all_nodes if n.address not in [node.address, another_node.address]) self.assertPolicyState(expected_failed, 0, 1) self.assertPolicyState(expected_nothing, 0, 0) def test_failedResetsInteraction(self): """ Nodes resolved after a failing interaction are not marked as failed when finish is called. """ self.session.start_interaction() node = self.session.resolve("service1", "1.0") self.session.fail_interaction("OHNO") another_node = self.session.resolve("service2", "1.0") self.session.finish_interaction() expected_failed = [self.disco.failurePolicy(node)] expected_succeeded = [self.disco.failurePolicy(another_node)] expected_nothing = list(self.disco.failurePolicy(n) for n in self.all_nodes if n.address not in [node.address, another_node.address]) self.assertPolicyState(expected_failed, 0, 1) self.assertPolicyState(expected_succeeded, 1, 0) self.assertPolicyState(expected_nothing, 0, 0) def test_finishedResetsInteraction(self): """ Each new interaction allows marking Nodes with new information. """ self.session.start_interaction() node = self.session.resolve("service1", "1.0") self.session.fail_interaction("OHNO") self.session.finish_interaction() self.session.start_interaction() # Resolve same node again: while True: another_node = self.session.resolve("service1", "1.0") if node.address == another_node.address: break self.session.finish_interaction() self.assertPolicyState([self.disco.failurePolicy(node)], 1, 1) @given(st.recursive(st.text(alphabet="abcd", min_size=1, max_size=3), st.lists).flatmap(add_bools)) def test_nestedInteractions(self, values): """ Nested interactions operate independently of parent interactions. :param values: a two-tuple composed of: - a recursive list of unicode and other recursive lists - list start means begin interaction, string means node resolve, list end means finish interaction. - list of False/True; True means failed interaction """ requested_interactions, failures = values failures = iter(failures) assume(not isinstance(requested_interactions, unicode)) self.init() ws_actor = self.connector.expectSocket() self.connector.connect(ws_actor) failures = iter(failures) created_services = {} expected_success_nodes = Counter() expected_failed_nodes = Counter() def run_interaction(children): should_fail = next(failures) failed = [] succeeded = [] self.session.start_interaction() for child in children: if isinstance(child, unicode): # Make sure disco knows about the node: if child in created_services: node = created_services[child] else: node = create_node(child, child) created_services[child] = node self.disco.onMessage(None, NodeActive(node)) # Make sure the child Node is resolved in the interaction self.session.resolve(node.service, "1.0") if should_fail: expected_failed_nodes[node] += 1 failed.append(node) else: expected_success_nodes[node] += 1 succeeded.append(node) else: run_interaction(child) if should_fail: self.session.fail_interaction("OHNO") self.session.finish_interaction() self.connector.advance_time(5.0) # Make sure interaction is sent ws_actor.swallowLogMessages() self.connector.expectInteraction( self, ws_actor, self.session, failed, succeeded) run_interaction(requested_interactions) for node in set(expected_failed_nodes) | set(expected_success_nodes): policy = self.disco.failurePolicy(node) self.assertEqual((policy.successes, policy.failures), (expected_success_nodes[node], expected_failed_nodes[node])) class SessionDeadlineTests(TestCase): """Tests for the session deadline.""" def setUp(self): """Initialize an empty environment.""" # Initialize runtime and MDK: self.runtime = fakeRuntime() self.runtime.getEnvVarsService().set("DATAWIRE_TOKEN", "something") self.mdk = MDKImpl(self.runtime) self.mdk.start() self.session = self.mdk.session() def test_setDeadline(self): """A set deadline can be retrieved.""" self.session.setDeadline(13.5) self.assertEqual(13.5, self.session.getRemainingTime()) def test_notSetDeadline(self): """Deadline is null if not set.""" self.assertEqual(None, self.session.getRemainingTime()) def test_deadlineChangesAsTimePasses(self): """If time passes the deadline goes down.""" self.session.setDeadline(13.5) self.runtime.getTimeService().advance(2.0) self.assertEqual(11.5, self.session.getRemainingTime()) def test_setDeadlineTwice(self): """Deadlines can be decreased by setting, but not increased.""" self.session.setDeadline(10.0) self.session.setDeadline(9.0) decreased = self.session.getRemainingTime() self.session.setDeadline(11.0) still_decreased = self.session.getRemainingTime() self.assertEqual((decreased, still_decreased), (9.0, 9.0)) def test_serialization(self): """A serialized session preserves the deadline.""" self.session.setDeadline(10.0) self.session.setProperty("xx", "yy") serialized = self.session.externalize() session2 = self.mdk.join(serialized) self.assertEqual(session2.getRemainingTime(), 10.0) def test_mdkDefault(self): """The MDK can set a default deadline for new sessions.""" self.mdk.setDefaultDeadline(5.0) session = self.mdk.session() self.assertEqual(session.getRemainingTime(), 5.0) def test_mdkDefaultForJoinedSessions(self): """ Deadlines for joined sessions are decreased to the MDK default deadline, but never increased. """ session1 = self.mdk.session() session1.setDeadline(1.0) encoded1 = session1.externalize() session2 = self.mdk.session() session2.setDeadline(3.0) encoded2 = session2.externalize() self.mdk.setDefaultDeadline(2.0) self.assertEqual((1.0, 2.0), (self.mdk.join(encoded1).getRemainingTime(), self.mdk.join(encoded2).getRemainingTime())) def test_resolveNoDeadline(self): """ If a deadline higher than 10 seconds was set, resolving still times out after 10.0 seconds. """ self.session.setDeadline(20.0) start = time() with self.assertRaises(Exception): self.session.resolve("unknown", "1.0") self.assertAlmostEqual(time() - start, 10.0, delta=1) def test_resolveLowerDeadline(self): """ If a deadline lower than 10 seconds was set, resolving happens after the lower deadline. """ self.session.setDeadline(3.0) start = time() with self.assertRaises(Exception): self.session.resolve("unknown", "1.0") self.assertAlmostEqual(time() - start, 3.0, delta=1) class SessionTests(TestCase): """Tests for sessions.""" def setUp(self): """Initialize an empty environment.""" self.connector = MDKConnector(env={"MDK_ENVIRONMENT": "myenv"}) self.runtime = self.connector.runtime self.mdk = self.connector.mdk def assertSessionHas(self, session, trace_id, clock_level, **properties): """ Assert the given SessionImpl has the given trace, clock and properties. """ self.assertEqual(session._context.traceId, trace_id) self.assertEqual(session._context.clock.clocks, clock_level) self.assertEqual(session._context.properties, properties) def test_newSession(self): """New sessions have different trace IDs.""" session = self.mdk.session() session2 = self.mdk.session() self.assertSessionHas(session, session._context.traceId, [0]) self.assertSessionHas(session2, session2._context.traceId, [0]) self.assertNotEqual(session._context.traceId, session2._context.traceId) def test_newSesssionEnvironment(self): """New sessions get their environment from the MDK.""" session = self.mdk.session() assertEnvironmentEquals(self, session.getEnvironment(), "myenv", None) def test_sessionProperties(self): """Sessions have properties that can be set, checked and retrieved.""" session = self.mdk.session() value = ["123", {"12": 123}] session.setProperty("key", value) session.setProperty("key2", "hello") self.assertEqual((session.getProperty("key"), session.getProperty("key2"), session.hasProperty("key"), session.hasProperty("key2"), session.hasProperty("nope")), (value, "hello", True, True, False)) def test_joinSession(self): """ A joined session has some trace ID, clock level properties as the encoded session. """ session = self.mdk.session() session.setProperty("key", 456) session.setProperty("key2", [456, {"zoo": "foo"}]) session2 = self.mdk.join(session.externalize()) self.assertSessionHas(session2, session._context.traceId, [1, 0], key=456, key2=[456, {"zoo": "foo"}]) def test_joinSessionEnvironment(self): """ A joined session gets its environment from the encoded session, not the MDK. """ connector = MDKConnector(env={"MDK_ENVIRONMENT": "env2"}) encoded_session = connector.mdk.session().externalize() session2 = self.mdk.join(encoded_session) assertEnvironmentEquals(self, session2.getEnvironment(), "env2", None) def test_childSession(self): """ A child session has a new trace ID and clock level, but knows about the parent session's trace ID and clock level and inherits properties other than timeout. """ session = self.mdk.session() session.setProperty("other", 123) session._context.tick() session._context.tick() session._context.tick() session.setTimeout(13.0) session2 = self.mdk.derive(session.externalize()) self.assertNotEqual(session._context.traceId, session2._context.traceId) self.assertEqual(session2.getRemainingTime(), None) self.assertSessionHas(session2, session2._context.traceId, [1], other=123) def assertEnvironmentEquals(test, environment, name, fallback): """ Assert the given environment has the given name and fallback name. """ test.assertEqual(environment.name, name) test.assertEqual(environment.fallbackName, fallback) class ConnectionStartupShutdownTests(TestCase): """Tests for initial setup and shutdown of MCP connections.""" def test_connection_node_identity(self): """ Each connection to MCP sends an Open message with the same node identity. """ connector = MDKConnector() ws_actor = connector.expectSocket() open = connector.connect(ws_actor) ws_actor.close() connector.advance_time(1) ws_actor2 = connector.expectSocket() # Should be new connection: self.assertNotEqual(ws_actor, ws_actor2) open2 = connector.connect(ws_actor2) self.assertEqual(open.nodeId, open2.nodeId) self.assertEqual(open.nodeId, connector.mdk.procUUID) def test_random_node_identity(self): """ Node identity is randomly generated each time. """ connector = MDKConnector() ws_actor = connector.expectSocket() open = connector.connect(ws_actor) connector2 = MDKConnector() ws_actor2 = connector2.expectSocket() open2 = connector2.connect(ws_actor2) self.assertNotEqual(open.nodeId, open2.nodeId) def test_environment(self): """ The Open message includes the Environment loaded from an env variable. """ connector = MDKConnector(env={"MDK_ENVIRONMENT": "myenv"}) ws_actor = connector.expectSocket() open = connector.connect(ws_actor) assertEnvironmentEquals(self, open.environment, "myenv", None) connector = MDKConnector(env={"MDK_ENVIRONMENT": "parent:child"}) ws_actor = connector.expectSocket() open = connector.connect(ws_actor) assertEnvironmentEquals(self, open.environment, "child", "parent") def test_default_environment(self): """ The Environment is 'sandbox' if none env variable is set. """ connector = MDKConnector() ws_actor = connector.expectSocket() open = connector.connect(ws_actor) assertEnvironmentEquals(self, open.environment, "sandbox", None) def test_mdk_version(self): """ The Open message reports the MDK version. """ connector = MDKConnector() ws_actor = connector.expectSocket() open = connector.connect(ws_actor) parser = configparser.ConfigParser() parser.read([".bumpversion.cfg"]) expected_version = parser.get("bumpversion", "current_version") self.assertEqual(open.mdkVersion, expected_version) def test_close_no_error(self): """ Receiving Close message with no error is handled without blowing up. """ connector = MDKConnector() ws_actor = connector.expectSocket() connector.connect(ws_actor) ws_actor.send(Close().encode()) connector.pump() def test_close_with_error(self): """ Receiving a Close message with a ProtocolError logs the information in the error. """ code = "300" detail = "MONKEYS EVERYWHERE AIIEEEEEEE" title = "Something bad happened" id = "specialsnowflake" close = Close() close.error = ProtocolError() close.error.code = code close.error.title = title close.error.detail = detail close.error.id = id connector = MDKConnector() ws_actor = connector.expectSocket() connector.connect(ws_actor) with self.assertLogs("quark.protocol", "INFO") as cm: ws_actor.send(close.encode()) connector.pump() for text in [code, title, detail, id]: self.assertIn(text, cm.output[0]) self.assertTrue(cm.output[0].startswith("ERROR")) class InteractionReportingTests(TestCase): """The results of interactions are reported to the MCP.""" def setUp(self): self.node1 = create_node("a1", "service1", environment="myenv") self.node2 = create_node("a2", "service2", environment="myenv") self.node3 = create_node("a3", "service3", environment="myenv") def add_nodes(self, mdk): """Register existence of nodes with the MDK instance.""" mdk._disco.onMessage(None, NodeActive(self.node1)) mdk._disco.onMessage(None, NodeActive(self.node2)) mdk._disco.onMessage(None, NodeActive(self.node3)) def test_interaction(self): """Interaction results are sent to the MCP.""" connector = MDKConnector(env={"MDK_ENVIRONMENT": "myenv"}) time_service = connector.runtime.getTimeService() ws_actor = connector.expectSocket() connector.connect(ws_actor) self.add_nodes(connector.mdk) session = connector.mdk.session() session.start_interaction() start_time = time_service.time() connector.advance_time(123) # Can't use blocking resolve() with fake scheduling because it'll block # until timeout waiting for async events to be delivered. So use async # version: session._resolve("service1", "1.0") connector.pump() session.fail_interaction("fail") session._resolve("service2", "1.0") connector.pump() connector.advance_time(5) connector.pump() end_time = time_service.time() session.finish_interaction() connector.pump() connector.advance_time(5) connector.pump() # Skip log messages: ws_actor.swallowLogMessages() interaction = connector.expectInteraction(self, ws_actor, session, [self.node1], [self.node2]) self.assertEqual(interaction.startTimestamp, int(1000*start_time)) self.assertEqual(interaction.endTimestamp, int(1000*end_time)) self.assertEqual(interaction.environment.name, "myenv") def test_interactionClocks(self): """ The interaction event records the clock level at start and end. """ connector = MDKConnector() ws_actor = connector.expectSocket() connector.connect(ws_actor) session = connector.mdk.session() # Figure out previous level of clock for start [start_level] = session.info("doop", "didoop").causalLevel session.start_interaction() session.info("doop", "didup") # Figure out previous level of clock for end [end_level] = session.info("doop", "didoop").causalLevel session.finish_interaction() # Ensure message is sent: connector.advance_time(5) ws_actor.swallowLogMessages() interaction = connector.expectInteraction(self, ws_actor, session, [], []) self.assertEqual((interaction.startClock, interaction.endClock), ([start_level + 1], [end_level + 1])) class LoggingTests(TestCase): """Tests for logging API of Session.""" LEVELS = ["DEBUG", "INFO", "WARN", "ERROR", "CRITICAL"] def assert_log_level_enforced(self, minimum_level): """Only log messages at or above the given level are sent.""" mdk, tracer = create_mdk_with_faketracer() session = mdk.session() messages = ["a", "b", "c", "d", "e"] # Set logging level of the session: session.trace(minimum_level) # Log messages at all levels: for (l, m) in zip(self.LEVELS, messages): getattr(session, l.lower())("category", m) # Only messages at or above current level should actually be logged: result = [d["level"] for d in tracer.messages] expected_levels = self.LEVELS[self.LEVELS.index(minimum_level):] self.assertEqual(result, expected_levels) def test_log_levels_enforced(self): """ Only log messages at or above the set trace level are sent onwards. """ for level in self.LEVELS: self.assert_log_level_enforced(level) def test_log_result(self): """ A LoggedMessageId matching the logged message is returned by logging APIs. """ mdk, tracer = create_mdk_with_faketracer(environment="fallback:child") session = mdk.session() session.info("cat", "message") lmid = session.info("cat", "another message") logged = tracer.messages[1] self.assertEqual((lmid.traceId, lmid.causalLevel, lmid.environment, lmid.environmentFallback), (logged["context"], [2], "child", "fallback")) def test_log_result_too_low_level(self): """ A LoggedMessageId matching the logged message is returned by logging APIs even when the given level is low enough that a message wasn't sent to the MCP. """ mdk, tracer = create_mdk_with_faketracer() session = mdk.session() session.info("cat", "message") lmid = session.debug("cat", "another message") lmid2 = session.info("cat", "message") # Debug message wasn't set: self.assertEqual([d["level"] for d in tracer.messages], ["INFO", "INFO"]) # But we still got LoggedMessageId for debug message: self.assertEqual((lmid.causalLevel, lmid.traceId, lmid2.causalLevel, lmid2.traceId), ([2], session._context.traceId, [3], session._context.traceId)) def test_no_tracer(self): """ If no tracer was setup, logging still returns a LoggedMessageId. """ runtime = fakeRuntime() runtime.getEnvVarsService().set("MDK_DISCOVERY_SOURCE", "static:nodes={}") mdk = MDKImpl(runtime) mdk.start() # No DATAWIRE_TOKEN, so no tracer: self.assertEqual(mdk._tracer, None) session = mdk.session() session.info("cat", "message") lmid = session.info("cat", "another message") self.assertEqual((lmid.traceId, lmid.causalLevel), (session._context.traceId, [2]))
datawire/mdk
unittests/test_mdk.py
Python
apache-2.0
27,210
# Copyright 2016 Cisco Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ This module contains APIs to facilitate Imc backup and import """ import time from ..imcexception import ImcValidationException def backup_create(handle, remote_host, remote_file, protocol, username, password, passphrase, timeout_in_sec=600, entity="CMC", **kwargs): """ backup_create helps create and download Imc backups. Args: handle (ImcHandle): Imc Connection handle remote_host (str): IP or Hostname for the remote host. remote_file (str): Absolute path and name for the backup file protocol (str) : "ftp", "http", "scp", "sftp", "tftp" username (str) : Remote Host user name password (str) : Remote Host user credentials/password passphrase (str) : Password for the backup file. timeout_in_sec (number) : time in seconds for which method waits for the backUp file to generate before it exits. entity (str): For C3260 platforms: "CMC" for backup of chassis related configuration and state "CIMC1" for backup of server-1 related configuration and state "CIMC2" for backup of server-2 related configuration and state kwargs : key=value paired arguments Example: remote_file = "/root/config_backup.xml" backup_create(h,remote_file=remote_file, protocol="ftp",username="user",password="pass", remote_host="10.10.10.10",passphrase="xxxxxx") backup_create(handle, remote_file="/users/xyz/backup", remote_host="1.1.1.1", protocol="scp", username="admin", password="password", passphrase="passphrase", timeout_in_sec=600, entity="CMC") """ from ..mometa.mgmt.MgmtBackup import MgmtBackup, MgmtBackupConsts from ..mometa.top.TopSystem import TopSystem from ..mometa.equipment.EquipmentChassis import EquipmentChassis from ..imccoreutils import IMC_PLATFORM if password == "" or passphrase == "": raise ImcValidationException("Invalid password or passphrase") top_system = TopSystem() parent_mo = None mgmt_backup = None if handle.platform == IMC_PLATFORM.TYPE_CLASSIC: parent_mo = top_system elif handle.platform == IMC_PLATFORM.TYPE_MODULAR: parent_mo = EquipmentChassis(parent_mo_or_dn=top_system) mgmt_backup = MgmtBackup(parent_mo_or_dn=parent_mo) mgmt_backup.hostname = remote_host mgmt_backup.remote_file = remote_file mgmt_backup.user = username mgmt_backup.pwd = password mgmt_backup.passphrase = passphrase mgmt_backup.proto = protocol mgmt_backup.admin_state = MgmtBackupConsts.ADMIN_STATE_ENABLED mgmt_backup.set_prop_multiple(**kwargs) if handle.platform == IMC_PLATFORM.TYPE_MODULAR: mgmt_backup.entity = entity handle.add_mo(mgmt_backup, modify_present=True) # Checking for the backup to complete. time.sleep(10) duration = timeout_in_sec poll_interval = 2 download_status = False while not download_status: mgmt_backup = handle.query_dn(dn=mgmt_backup.dn) admin_state_temp = mgmt_backup.admin_state # Break condition:- if state id disabled then break if admin_state_temp == MgmtBackupConsts.ADMIN_STATE_DISABLED: if mgmt_backup.fsm_stage_descr == "Completed successfully": download_status = True if mgmt_backup.fsm_stage_descr == "Error": raise ImcValidationException("Failed to export the CIMC " "configuration file." + "Error Code: " + mgmt_backup.fsm_rmt_inv_err_code + " Error Description: " + mgmt_backup.fsm_rmt_inv_err_descr) if download_status: break time.sleep(min(duration, poll_interval)) duration = max(0, (duration - poll_interval)) if duration == 0: handle.remove_mo(mgmt_backup) raise ImcValidationException('backup_create timed out') def backup_import(handle, remote_host, remote_file, protocol, username, password, passphrase, entity="CMC", **kwargs): """ This operation uploads a Imc backup taken earlier via GUI or backup_create operation for all configuration, system configuration, and logical configuration files. User can perform an import while the system is up and running. Args: handle (ImcHandle): connection handle remote_host (str): IP or Hostname for the remote host. remote_file (str): Absolute path and name for the backup file protocol (str) : "ftp", "http", "scp", "sftp", "tftp" username (str) : Remote Host user name password (str) : Remote Host user credentials/password passphrase (str) : Password for the backup file. entity (str): For C3260 platforms: "CMC" for importing chassis related configuration and state "CIMC1" for importing server-1 related configuration and state "CIMC2" for importing server-2 related configuration and state kwargs : key=value paired arguments Example: remote_file = "/root/config_backup.xml" backup_import(h,remote_file=remote_file, protocol="ftp",username="user",password="pass", remote_host="10.10.10.10",passphrase="xxxxxx") backup_import(handle, remote_file="/users/xyz/backup", remote_host="1.1.1.1", protocol="scp", username="admin", password="password", passphrase="passphrase", timeout_in_sec=600, entity="CMC") """ from ..mometa.top.TopSystem import TopSystem from ..mometa.mgmt.MgmtImporter import MgmtImporter, MgmtImporterConsts from ..mometa.equipment.EquipmentChassis import EquipmentChassis from ..imccoreutils import IMC_PLATFORM if password == "" or passphrase == "": raise ImcValidationException("Invalid password or passphrase") # create MgmtImporter top_system = TopSystem() parent_mo = None if handle.platform == IMC_PLATFORM.TYPE_CLASSIC: parent_mo = top_system elif handle.platform == IMC_PLATFORM.TYPE_MODULAR: parent_mo = EquipmentChassis(parent_mo_or_dn=top_system) mgmt_importer = MgmtImporter(parent_mo_or_dn=parent_mo) mgmt_importer.hostname = remote_host mgmt_importer.remote_file = remote_file mgmt_importer.proto = protocol mgmt_importer.user = username mgmt_importer.pwd = password mgmt_importer.passphrase = passphrase mgmt_importer.admin_state = MgmtImporterConsts.ADMIN_STATE_ENABLED mgmt_importer.set_prop_multiple(**kwargs) if handle.platform == IMC_PLATFORM.TYPE_MODULAR: mgmt_importer.entity = entity handle.add_mo(mgmt_importer, modify_present=True) time.sleep(10) download_status = False while not download_status: mgmt_importer = handle.query_dn(dn=mgmt_importer.dn) admin_state_temp = mgmt_importer.admin_state # Break condition:- if state id disabled then break if admin_state_temp == MgmtImporterConsts.ADMIN_STATE_DISABLED: if mgmt_importer.fsm_stage_descr == "Completed successfully": download_status = True if mgmt_importer.fsm_stage_descr == "Error": raise ImcValidationException( "Failed to import the CIMC " "configuration file." + "Error Code: " + mgmt_importer.fsm_rmt_inv_err_code + " Error Description: " + mgmt_importer.fsm_rmt_inv_err_descr) if download_status: break return mgmt_importer
ragupta-git/ImcSdk
imcsdk/utils/imcbackup.py
Python
apache-2.0
8,595
#!/usr/bin/env python """ The scripts that compose this module contains a set of functions needed to process properly a background subtraction of each camera of a dataset """ import cbackground import cv2 import numpy as np import sys from gui import trackbar from threedgeometry import frameretriever
lacatus/TFM
bgsubtraction/__init__.py
Python
apache-2.0
305
import json, time from pyspider.database.base.taskdb import TaskDB as BaseTaskDB from .couchdbbase import SplitTableMixin class TaskDB(SplitTableMixin, BaseTaskDB): collection_prefix = '' def __init__(self, url, database='taskdb', username=None, password=None): self.username = username self.password = password self.base_url = url self.url = url + database + "/" self.database = database self.index = None super().__init__() self.create_database(database) self.projects = set() self._list_project() def _get_collection_name(self, project): return self.database + "_" + self._collection_name(project) def _create_project(self, project): collection_name = self._get_collection_name(project) self.create_database(collection_name) # create index payload = { 'index': { 'fields': ['status', 'taskid'] }, 'name': collection_name } res = self.session.post(self.base_url + collection_name + "/_index", json=payload).json() self.index = res['id'] self._list_project() def load_tasks(self, status, project=None, fields=None): if not project: self._list_project() if fields is None: fields = [] if project: projects = [project, ] else: projects = self.projects for project in projects: collection_name = self._get_collection_name(project) for task in self.get_docs(collection_name, {"selector": {"status": status}, "fields": fields}): yield task def get_task(self, project, taskid, fields=None): if project not in self.projects: self._list_project() if project not in self.projects: return if fields is None: fields = [] collection_name = self._get_collection_name(project) ret = self.get_docs(collection_name, {"selector": {"taskid": taskid}, "fields": fields}) if len(ret) == 0: return None return ret[0] def status_count(self, project): if project not in self.projects: self._list_project() if project not in self.projects: return {} collection_name = self._get_collection_name(project) def _count_for_status(collection_name, status): total = len(self.get_docs(collection_name, {"selector": {'status': status}})) return {'total': total, "_id": status} if total else None c = collection_name ret = [x for x in [_count_for_status(c, s) for s in [self.ACTIVE, self.SUCCESS, self.FAILED]] if x] result = {} if isinstance(ret, dict): ret = ret.get('result', []) for each in ret: result[each['_id']] = each['total'] return result def insert(self, project, taskid, obj={}): if project not in self.projects: self._create_project(project) obj = dict(obj) obj['taskid'] = taskid obj['project'] = project obj['updatetime'] = time.time() return self.update(project, taskid, obj=obj) def update(self, project, taskid, obj={}, **kwargs): obj = dict(obj) obj.update(kwargs) obj['updatetime'] = time.time() collection_name = self._get_collection_name(project) return self.update_doc(collection_name, taskid, obj) def drop_database(self): return self.delete(self.url) def drop(self, project): collection_name = self._get_collection_name(project) url = self.base_url + collection_name return self.delete(url)
luoq/pyspider
pyspider/database/couchdb/taskdb.py
Python
apache-2.0
3,764
""" Created by Max 12/10/2017 """ from ValueIteration import ValueIteration from Game import Game x = {(0, 32, -5, -5): None, (0, 32, -5, -4): None, (0, 32, -5, -3): None, (0, 32, -5, -2): None, (0, 32, -5, -1): None, (0, 32, -5, 0): None, (0, 32, -5, 1): None, (0, 32, -5, 2): None, (0, 32, -5, 3): None, (0, 32, -5, 4): None, (0, 32, -5, 5): None, (0, 32, -4, -5): None, (0, 32, -4, -4): None, (0, 32, -4, -3): None, (0, 32, -4, -2): None, (0, 32, -4, -1): None, (0, 32, -4, 0): None, (0, 32, -4, 1): None, (0, 32, -4, 2): None, (0, 32, -4, 3): None, (0, 32, -4, 4): None, (0, 32, -4, 5): None, (0, 32, -3, -5): None, (0, 32, -3, -4): None, (0, 32, -3, -3): None, (0, 32, -3, -2): None, (0, 32, -3, -1): None, (0, 32, -3, 0): None, (0, 32, -3, 1): None, (0, 32, -3, 2): None, (0, 32, -3, 3): None, (0, 32, -3, 4): None, (0, 32, -3, 5): None, (0, 32, -2, -5): None, (0, 32, -2, -4): None, (0, 32, -2, -3): None, (0, 32, -2, -2): None, (0, 32, -2, -1): None, (0, 32, -2, 0): None, (0, 32, -2, 1): None, (0, 32, -2, 2): None, (0, 32, -2, 3): None, (0, 32, -2, 4): None, (0, 32, -2, 5): None, (0, 32, -1, -5): None, (0, 32, -1, -4): None, (0, 32, -1, -3): None, (0, 32, -1, -2): None, (0, 32, -1, -1): None, (0, 32, -1, 0): None, (0, 32, -1, 1): None, (0, 32, -1, 2): None, (0, 32, -1, 3): None, (0, 32, -1, 4): None, (0, 32, -1, 5): None, (0, 32, 0, -5): None, (0, 32, 0, -4): None, (0, 32, 0, -3): None, (0, 32, 0, -2): None, (0, 32, 0, -1): None, (0, 32, 0, 0): None, (0, 32, 0, 1): None, (0, 32, 0, 2): None, (0, 32, 0, 3): None, (0, 32, 0, 4): None, (0, 32, 0, 5): None, (0, 32, 1, -5): None, (0, 32, 1, -4): None, (0, 32, 1, -3): None, (0, 32, 1, -2): None, (0, 32, 1, -1): None, (0, 32, 1, 0): None, (0, 32, 1, 1): None, (0, 32, 1, 2): None, (0, 32, 1, 3): None, (0, 32, 1, 4): None, (0, 32, 1, 5): None, (0, 32, 2, -5): None, (0, 32, 2, -4): None, (0, 32, 2, -3): None, (0, 32, 2, -2): None, (0, 32, 2, -1): None, (0, 32, 2, 0): None, (0, 32, 2, 1): None, (0, 32, 2, 2): None, (0, 32, 2, 3): None, (0, 32, 2, 4): None, (0, 32, 2, 5): None, (0, 32, 3, -5): None, (0, 32, 3, -4): None, (0, 32, 3, -3): None, (0, 32, 3, -2): None, (0, 32, 3, -1): None, (0, 32, 3, 0): None, (0, 32, 3, 1): None, (0, 32, 3, 2): None, (0, 32, 3, 3): None, (0, 32, 3, 4): None, (0, 32, 3, 5): None, (0, 32, 4, -5): None, (0, 32, 4, -4): None, (0, 32, 4, -3): None, (0, 32, 4, -2): None, (0, 32, 4, -1): None, (0, 32, 4, 0): None, (0, 32, 4, 1): None, (0, 32, 4, 2): None, (0, 32, 4, 3): None, (0, 32, 4, 4): None, (0, 32, 4, 5): None, (0, 32, 5, -5): None, (0, 32, 5, -4): None, (0, 32, 5, -3): None, (0, 32, 5, -2): None, (0, 32, 5, -1): None, (0, 32, 5, 0): None, (0, 32, 5, 1): None, (0, 32, 5, 2): None, (0, 32, 5, 3): None, (0, 32, 5, 4): None, (0, 32, 5, 5): None, (0, 33, -5, -5): None, (0, 33, -5, -4): None, (0, 33, -5, -3): None, (0, 33, -5, -2): None, (0, 33, -5, -1): None, (0, 33, -5, 0): None, (0, 33, -5, 1): None, (0, 33, -5, 2): None, (0, 33, -5, 3): None, (0, 33, -5, 4): None, (0, 33, -5, 5): None, (0, 33, -4, -5): None, (0, 33, -4, -4): None, (0, 33, -4, -3): None, (0, 33, -4, -2): None, (0, 33, -4, -1): None, (0, 33, -4, 0): None, (0, 33, -4, 1): None, (0, 33, -4, 2): None, (0, 33, -4, 3): None, (0, 33, -4, 4): None, (0, 33, -4, 5): None, (0, 33, -3, -5): None, (0, 33, -3, -4): None, (0, 33, -3, -3): None, (0, 33, -3, -2): None, (0, 33, -3, -1): None, (0, 33, -3, 0): None, (0, 33, -3, 1): None, (0, 33, -3, 2): None, (0, 33, -3, 3): None, (0, 33, -3, 4): None, (0, 33, -3, 5): None, (0, 33, -2, -5): None, (0, 33, -2, -4): None, (0, 33, -2, -3): None, (0, 33, -2, -2): None, (0, 33, -2, -1): None, (0, 33, -2, 0): None, (0, 33, -2, 1): None, (0, 33, -2, 2): None, (0, 33, -2, 3): None, (0, 33, -2, 4): None, (0, 33, -2, 5): None, (0, 33, -1, -5): None, (0, 33, -1, -4): None, (0, 33, -1, -3): None, (0, 33, -1, -2): None, (0, 33, -1, -1): None, (0, 33, -1, 0): None, (0, 33, -1, 1): None, (0, 33, -1, 2): None, (0, 33, -1, 3): None, (0, 33, -1, 4): None, (0, 33, -1, 5): None, (0, 33, 0, -5): None, (0, 33, 0, -4): None, (0, 33, 0, -3): None, (0, 33, 0, -2): None, (0, 33, 0, -1): None, (0, 33, 0, 0): None, (0, 33, 0, 1): None, (0, 33, 0, 2): None, (0, 33, 0, 3): None, (0, 33, 0, 4): None, (0, 33, 0, 5): None, (0, 33, 1, -5): None, (0, 33, 1, -4): None, (0, 33, 1, -3): None, (0, 33, 1, -2): None, (0, 33, 1, -1): None, (0, 33, 1, 0): None, (0, 33, 1, 1): None, (0, 33, 1, 2): None, (0, 33, 1, 3): None, (0, 33, 1, 4): None, (0, 33, 1, 5): None, (0, 33, 2, -5): None, (0, 33, 2, -4): None, (0, 33, 2, -3): None, (0, 33, 2, -2): None, (0, 33, 2, -1): None, (0, 33, 2, 0): None, (0, 33, 2, 1): None, (0, 33, 2, 2): None, (0, 33, 2, 3): None, (0, 33, 2, 4): None, (0, 33, 2, 5): None, (0, 33, 3, -5): None, (0, 33, 3, -4): None, (0, 33, 3, -3): None, (0, 33, 3, -2): None, (0, 33, 3, -1): None, (0, 33, 3, 0): None, (0, 33, 3, 1): None, (0, 33, 3, 2): None, (0, 33, 3, 3): None, (0, 33, 3, 4): None, (0, 33, 3, 5): None, (0, 33, 4, -5): None, (0, 33, 4, -4): None, (0, 33, 4, -3): None, (0, 33, 4, -2): None, (0, 33, 4, -1): None, (0, 33, 4, 0): None, (0, 33, 4, 1): None, (0, 33, 4, 2): None, (0, 33, 4, 3): None, (0, 33, 4, 4): None, (0, 33, 4, 5): None, (0, 33, 5, -5): None, (0, 33, 5, -4): None, (0, 33, 5, -3): None, (0, 33, 5, -2): None, (0, 33, 5, -1): None, (0, 33, 5, 0): None, (0, 33, 5, 1): None, (0, 33, 5, 2): None, (0, 33, 5, 3): None, (0, 33, 5, 4): None, (0, 33, 5, 5): None, (0, 34, -5, -5): None, (0, 34, -5, -4): None, (0, 34, -5, -3): None, (0, 34, -5, -2): None, (0, 34, -5, -1): None, (0, 34, -5, 0): None, (0, 34, -5, 1): None, (0, 34, -5, 2): None, (0, 34, -5, 3): None, (0, 34, -5, 4): None, (0, 34, -5, 5): None, (0, 34, -4, -5): None, (0, 34, -4, -4): None, (0, 34, -4, -3): None, (0, 34, -4, -2): None, (0, 34, -4, -1): None, (0, 34, -4, 0): None, (0, 34, -4, 1): None, (0, 34, -4, 2): None, (0, 34, -4, 3): None, (0, 34, -4, 4): None, (0, 34, -4, 5): None, (0, 34, -3, -5): None, (0, 34, -3, -4): None, (0, 34, -3, -3): None, (0, 34, -3, -2): None, (0, 34, -3, -1): None, (0, 34, -3, 0): None, (0, 34, -3, 1): None, (0, 34, -3, 2): None, (0, 34, -3, 3): None, (0, 34, -3, 4): None, (0, 34, -3, 5): None, (0, 34, -2, -5): None, (0, 34, -2, -4): None, (0, 34, -2, -3): None, (0, 34, -2, -2): None, (0, 34, -2, -1): None, (0, 34, -2, 0): None, (0, 34, -2, 1): None, (0, 34, -2, 2): None, (0, 34, -2, 3): None, (0, 34, -2, 4): None, (0, 34, -2, 5): None, (0, 34, -1, -5): None, (0, 34, -1, -4): None, (0, 34, -1, -3): None, (0, 34, -1, -2): None, (0, 34, -1, -1): None, (0, 34, -1, 0): None, (0, 34, -1, 1): None, (0, 34, -1, 2): None, (0, 34, -1, 3): None, (0, 34, -1, 4): None, (0, 34, -1, 5): None, (0, 34, 0, -5): None, (0, 34, 0, -4): None, (0, 34, 0, -3): None, (0, 34, 0, -2): None, (0, 34, 0, -1): None, (0, 34, 0, 0): None, (0, 34, 0, 1): None, (0, 34, 0, 2): None, (0, 34, 0, 3): None, (0, 34, 0, 4): None, (0, 34, 0, 5): None, (0, 34, 1, -5): None, (0, 34, 1, -4): None, (0, 34, 1, -3): None, (0, 34, 1, -2): None, (0, 34, 1, -1): None, (0, 34, 1, 0): None, (0, 34, 1, 1): None, (0, 34, 1, 2): None, (0, 34, 1, 3): None, (0, 34, 1, 4): None, (0, 34, 1, 5): None, (0, 34, 2, -5): None, (0, 34, 2, -4): None, (0, 34, 2, -3): None, (0, 34, 2, -2): None, (0, 34, 2, -1): None, (0, 34, 2, 0): None, (0, 34, 2, 1): None, (0, 34, 2, 2): None, (0, 34, 2, 3): None, (0, 34, 2, 4): None, (0, 34, 2, 5): None, (0, 34, 3, -5): None, (0, 34, 3, -4): None, (0, 34, 3, -3): None, (0, 34, 3, -2): None, (0, 34, 3, -1): None, (0, 34, 3, 0): None, (0, 34, 3, 1): None, (0, 34, 3, 2): None, (0, 34, 3, 3): None, (0, 34, 3, 4): None, (0, 34, 3, 5): None, (0, 34, 4, -5): None, (0, 34, 4, -4): None, (0, 34, 4, -3): None, (0, 34, 4, -2): None, (0, 34, 4, -1): None, (0, 34, 4, 0): None, (0, 34, 4, 1): None, (0, 34, 4, 2): None, (0, 34, 4, 3): None, (0, 34, 4, 4): None, (0, 34, 4, 5): None, (0, 34, 5, -5): None, (0, 34, 5, -4): None, (0, 34, 5, -3): None, (0, 34, 5, -2): None, (0, 34, 5, -1): None, (0, 34, 5, 0): None, (0, 34, 5, 1): None, (0, 34, 5, 2): None, (0, 34, 5, 3): None, (0, 34, 5, 4): None, (0, 34, 5, 5): None, (0, 35, -5, -5): None, (0, 35, -5, -4): None, (0, 35, -5, -3): None, (0, 35, -5, -2): None, (0, 35, -5, -1): None, (0, 35, -5, 0): None, (0, 35, -5, 1): None, (0, 35, -5, 2): None, (0, 35, -5, 3): None, (0, 35, -5, 4): None, (0, 35, -5, 5): None, (0, 35, -4, -5): None, (0, 35, -4, -4): None, (0, 35, -4, -3): None, (0, 35, -4, -2): None, (0, 35, -4, -1): None, (0, 35, -4, 0): None, (0, 35, -4, 1): None, (0, 35, -4, 2): None, (0, 35, -4, 3): None, (0, 35, -4, 4): None, (0, 35, -4, 5): None, (0, 35, -3, -5): None, (0, 35, -3, -4): None, (0, 35, -3, -3): None, (0, 35, -3, -2): None, (0, 35, -3, -1): None, (0, 35, -3, 0): None, (0, 35, -3, 1): None, (0, 35, -3, 2): None, (0, 35, -3, 3): None, (0, 35, -3, 4): None, (0, 35, -3, 5): None, (0, 35, -2, -5): None, (0, 35, -2, -4): None, (0, 35, -2, -3): None, (0, 35, -2, -2): None, (0, 35, -2, -1): None, (0, 35, -2, 0): None, (0, 35, -2, 1): None, (0, 35, -2, 2): None, (0, 35, -2, 3): None, (0, 35, -2, 4): None, (0, 35, -2, 5): None, (0, 35, -1, -5): None, (0, 35, -1, -4): None, (0, 35, -1, -3): None, (0, 35, -1, -2): None, (0, 35, -1, -1): None, (0, 35, -1, 0): None, (0, 35, -1, 1): None, (0, 35, -1, 2): None, (0, 35, -1, 3): None, (0, 35, -1, 4): None, (0, 35, -1, 5): None, (0, 35, 0, -5): None, (0, 35, 0, -4): None, (0, 35, 0, -3): None, (0, 35, 0, -2): None, (0, 35, 0, -1): None, (0, 35, 0, 0): None, (0, 35, 0, 1): None, (0, 35, 0, 2): None, (0, 35, 0, 3): None, (0, 35, 0, 4): None, (0, 35, 0, 5): None, (0, 35, 1, -5): None, (0, 35, 1, -4): None, (0, 35, 1, -3): None, (0, 35, 1, -2): None, (0, 35, 1, -1): None, (0, 35, 1, 0): None, (0, 35, 1, 1): None, (0, 35, 1, 2): None, (0, 35, 1, 3): None, (0, 35, 1, 4): None, (0, 35, 1, 5): None, (0, 35, 2, -5): None, (0, 35, 2, -4): None, (0, 35, 2, -3): None, (0, 35, 2, -2): None, (0, 35, 2, -1): None, (0, 35, 2, 0): None, (0, 35, 2, 1): None, (0, 35, 2, 2): None, (0, 35, 2, 3): None, (0, 35, 2, 4): None, (0, 35, 2, 5): None, (0, 35, 3, -5): None, (0, 35, 3, -4): None, (0, 35, 3, -3): None, (0, 35, 3, -2): None, (0, 35, 3, -1): None, (0, 35, 3, 0): None, (0, 35, 3, 1): None, (0, 35, 3, 2): None, (0, 35, 3, 3): None, (0, 35, 3, 4): None, (0, 35, 3, 5): None, (0, 35, 4, -5): None, (0, 35, 4, -4): None, (0, 35, 4, -3): None, (0, 35, 4, -2): None, (0, 35, 4, -1): None, (0, 35, 4, 0): None, (0, 35, 4, 1): None, (0, 35, 4, 2): None, (0, 35, 4, 3): None, (0, 35, 4, 4): None, (0, 35, 4, 5): None, (0, 35, 5, -5): None, (0, 35, 5, -4): None, (0, 35, 5, -3): None, (0, 35, 5, -2): None, (0, 35, 5, -1): None, (0, 35, 5, 0): None, (0, 35, 5, 1): None, (0, 35, 5, 2): None, (0, 35, 5, 3): None, (0, 35, 5, 4): None, (0, 35, 5, 5): None, (1, 32, -5, -5): None, (1, 32, -5, -4): None, (1, 32, -5, -3): None, (1, 32, -5, -2): None, (1, 32, -5, -1): None, (1, 32, -5, 0): None, (1, 32, -5, 1): None, (1, 32, -5, 2): None, (1, 32, -5, 3): None, (1, 32, -5, 4): None, (1, 32, -5, 5): None, (1, 32, -4, -5): None, (1, 32, -4, -4): None, (1, 32, -4, -3): None, (1, 32, -4, -2): None, (1, 32, -4, -1): None, (1, 32, -4, 0): None, (1, 32, -4, 1): None, (1, 32, -4, 2): None, (1, 32, -4, 3): None, (1, 32, -4, 4): None, (1, 32, -4, 5): None, (1, 32, -3, -5): None, (1, 32, -3, -4): None, (1, 32, -3, -3): None, (1, 32, -3, -2): None, (1, 32, -3, -1): None, (1, 32, -3, 0): None, (1, 32, -3, 1): None, (1, 32, -3, 2): None, (1, 32, -3, 3): None, (1, 32, -3, 4): None, (1, 32, -3, 5): None, (1, 32, -2, -5): None, (1, 32, -2, -4): None, (1, 32, -2, -3): None, (1, 32, -2, -2): None, (1, 32, -2, -1): None, (1, 32, -2, 0): None, (1, 32, -2, 1): None, (1, 32, -2, 2): None, (1, 32, -2, 3): None, (1, 32, -2, 4): None, (1, 32, -2, 5): None, (1, 32, -1, -5): None, (1, 32, -1, -4): None, (1, 32, -1, -3): None, (1, 32, -1, -2): None, (1, 32, -1, -1): None, (1, 32, -1, 0): None, (1, 32, -1, 1): None, (1, 32, -1, 2): None, (1, 32, -1, 3): None, (1, 32, -1, 4): None, (1, 32, -1, 5): None, (1, 32, 0, -5): None, (1, 32, 0, -4): None, (1, 32, 0, -3): None, (1, 32, 0, -2): None, (1, 32, 0, -1): None, (1, 32, 0, 0): None, (1, 32, 0, 1): None, (1, 32, 0, 2): None, (1, 32, 0, 3): None, (1, 32, 0, 4): None, (1, 32, 0, 5): None, (1, 32, 1, -5): None, (1, 32, 1, -4): None, (1, 32, 1, -3): None, (1, 32, 1, -2): None, (1, 32, 1, -1): None, (1, 32, 1, 0): None, (1, 32, 1, 1): None, (1, 32, 1, 2): None, (1, 32, 1, 3): None, (1, 32, 1, 4): None, (1, 32, 1, 5): None, (1, 32, 2, -5): None, (1, 32, 2, -4): None, (1, 32, 2, -3): None, (1, 32, 2, -2): None, (1, 32, 2, -1): None, (1, 32, 2, 0): None, (1, 32, 2, 1): None, (1, 32, 2, 2): None, (1, 32, 2, 3): None, (1, 32, 2, 4): None, (1, 32, 2, 5): None, (1, 32, 3, -5): None, (1, 32, 3, -4): None, (1, 32, 3, -3): None, (1, 32, 3, -2): None, (1, 32, 3, -1): None, (1, 32, 3, 0): None, (1, 32, 3, 1): None, (1, 32, 3, 2): None, (1, 32, 3, 3): None, (1, 32, 3, 4): None, (1, 32, 3, 5): None, (1, 32, 4, -5): None, (1, 32, 4, -4): None, (1, 32, 4, -3): None, (1, 32, 4, -2): None, (1, 32, 4, -1): None, (1, 32, 4, 0): None, (1, 32, 4, 1): None, (1, 32, 4, 2): None, (1, 32, 4, 3): None, (1, 32, 4, 4): None, (1, 32, 4, 5): None, (1, 32, 5, -5): None, (1, 32, 5, -4): None, (1, 32, 5, -3): None, (1, 32, 5, -2): None, (1, 32, 5, -1): None, (1, 32, 5, 0): None, (1, 32, 5, 1): None, (1, 32, 5, 2): None, (1, 32, 5, 3): None, (1, 32, 5, 4): None, (1, 32, 5, 5): None, (1, 33, -5, -5): None, (1, 33, -5, -4): None, (1, 33, -5, -3): None, (1, 33, -5, -2): None, (1, 33, -5, -1): None, (1, 33, -5, 0): None, (1, 33, -5, 1): None, (1, 33, -5, 2): None, (1, 33, -5, 3): None, (1, 33, -5, 4): None, (1, 33, -5, 5): None, (1, 33, -4, -5): None, (1, 33, -4, -4): None, (1, 33, -4, -3): None, (1, 33, -4, -2): None, (1, 33, -4, -1): None, (1, 33, -4, 0): None, (1, 33, -4, 1): None, (1, 33, -4, 2): None, (1, 33, -4, 3): None, (1, 33, -4, 4): None, (1, 33, -4, 5): None, (1, 33, -3, -5): None, (1, 33, -3, -4): None, (1, 33, -3, -3): None, (1, 33, -3, -2): None, (1, 33, -3, -1): None, (1, 33, -3, 0): None, (1, 33, -3, 1): None, (1, 33, -3, 2): None, (1, 33, -3, 3): None, (1, 33, -3, 4): None, (1, 33, -3, 5): None, (1, 33, -2, -5): None, (1, 33, -2, -4): None, (1, 33, -2, -3): None, (1, 33, -2, -2): None, (1, 33, -2, -1): None, (1, 33, -2, 0): None, (1, 33, -2, 1): None, (1, 33, -2, 2): None, (1, 33, -2, 3): None, (1, 33, -2, 4): None, (1, 33, -2, 5): None, (1, 33, -1, -5): None, (1, 33, -1, -4): None, (1, 33, -1, -3): None, (1, 33, -1, -2): None, (1, 33, -1, -1): None, (1, 33, -1, 0): None, (1, 33, -1, 1): None, (1, 33, -1, 2): None, (1, 33, -1, 3): None, (1, 33, -1, 4): None, (1, 33, -1, 5): None, (1, 33, 0, -5): None, (1, 33, 0, -4): None, (1, 33, 0, -3): None, (1, 33, 0, -2): None, (1, 33, 0, -1): None, (1, 33, 0, 0): None, (1, 33, 0, 1): None, (1, 33, 0, 2): None, (1, 33, 0, 3): None, (1, 33, 0, 4): None, (1, 33, 0, 5): None, (1, 33, 1, -5): None, (1, 33, 1, -4): None, (1, 33, 1, -3): None, (1, 33, 1, -2): None, (1, 33, 1, -1): None, (1, 33, 1, 0): None, (1, 33, 1, 1): None, (1, 33, 1, 2): None, (1, 33, 1, 3): None, (1, 33, 1, 4): None, (1, 33, 1, 5): None, (1, 33, 2, -5): None, (1, 33, 2, -4): None, (1, 33, 2, -3): None, (1, 33, 2, -2): None, (1, 33, 2, -1): None, (1, 33, 2, 0): None, (1, 33, 2, 1): None, (1, 33, 2, 2): None, (1, 33, 2, 3): None, (1, 33, 2, 4): None, (1, 33, 2, 5): None, (1, 33, 3, -5): None, (1, 33, 3, -4): None, (1, 33, 3, -3): None, (1, 33, 3, -2): None, (1, 33, 3, -1): None, (1, 33, 3, 0): None, (1, 33, 3, 1): None, (1, 33, 3, 2): None, (1, 33, 3, 3): None, (1, 33, 3, 4): None, (1, 33, 3, 5): None, (1, 33, 4, -5): None, (1, 33, 4, -4): None, (1, 33, 4, -3): None, (1, 33, 4, -2): None, (1, 33, 4, -1): None, (1, 33, 4, 0): None, (1, 33, 4, 1): None, (1, 33, 4, 2): None, (1, 33, 4, 3): None, (1, 33, 4, 4): None, (1, 33, 4, 5): None, (1, 33, 5, -5): None, (1, 33, 5, -4): None, (1, 33, 5, -3): None, (1, 33, 5, -2): None, (1, 33, 5, -1): None, (1, 33, 5, 0): None, (1, 33, 5, 1): None, (1, 33, 5, 2): None, (1, 33, 5, 3): None, (1, 33, 5, 4): None, (1, 33, 5, 5): None, (1, 34, -5, -5): None, (1, 34, -5, -4): None, (1, 34, -5, -3): None, (1, 34, -5, -2): None, (1, 34, -5, -1): None, (1, 34, -5, 0): None, (1, 34, -5, 1): None, (1, 34, -5, 2): None, (1, 34, -5, 3): None, (1, 34, -5, 4): None, (1, 34, -5, 5): None, (1, 34, -4, -5): None, (1, 34, -4, -4): None, (1, 34, -4, -3): None, (1, 34, -4, -2): None, (1, 34, -4, -1): None, (1, 34, -4, 0): None, (1, 34, -4, 1): None, (1, 34, -4, 2): None, (1, 34, -4, 3): None, (1, 34, -4, 4): None, (1, 34, -4, 5): None, (1, 34, -3, -5): None, (1, 34, -3, -4): None, (1, 34, -3, -3): None, (1, 34, -3, -2): None, (1, 34, -3, -1): None, (1, 34, -3, 0): None, (1, 34, -3, 1): None, (1, 34, -3, 2): None, (1, 34, -3, 3): None, (1, 34, -3, 4): None, (1, 34, -3, 5): None, (1, 34, -2, -5): None, (1, 34, -2, -4): None, (1, 34, -2, -3): None, (1, 34, -2, -2): None, (1, 34, -2, -1): None, (1, 34, -2, 0): None, (1, 34, -2, 1): None, (1, 34, -2, 2): None, (1, 34, -2, 3): None, (1, 34, -2, 4): None, (1, 34, -2, 5): None, (1, 34, -1, -5): None, (1, 34, -1, -4): None, (1, 34, -1, -3): None, (1, 34, -1, -2): None, (1, 34, -1, -1): None, (1, 34, -1, 0): None, (1, 34, -1, 1): None, (1, 34, -1, 2): None, (1, 34, -1, 3): None, (1, 34, -1, 4): None, (1, 34, -1, 5): None, (1, 34, 0, -5): None, (1, 34, 0, -4): None, (1, 34, 0, -3): None, (1, 34, 0, -2): None, (1, 34, 0, -1): None, (1, 34, 0, 0): None, (1, 34, 0, 1): None, (1, 34, 0, 2): None, (1, 34, 0, 3): None, (1, 34, 0, 4): None, (1, 34, 0, 5): None, (1, 34, 1, -5): None, (1, 34, 1, -4): None, (1, 34, 1, -3): None, (1, 34, 1, -2): None, (1, 34, 1, -1): None, (1, 34, 1, 0): None, (1, 34, 1, 1): None, (1, 34, 1, 2): None, (1, 34, 1, 3): None, (1, 34, 1, 4): None, (1, 34, 1, 5): None, (1, 34, 2, -5): None, (1, 34, 2, -4): None, (1, 34, 2, -3): None, (1, 34, 2, -2): None, (1, 34, 2, -1): None, (1, 34, 2, 0): None, (1, 34, 2, 1): None, (1, 34, 2, 2): None, (1, 34, 2, 3): None, (1, 34, 2, 4): None, (1, 34, 2, 5): None, (1, 34, 3, -5): None, (1, 34, 3, -4): None, (1, 34, 3, -3): None, (1, 34, 3, -2): None, (1, 34, 3, -1): None, (1, 34, 3, 0): None, (1, 34, 3, 1): None, (1, 34, 3, 2): None, (1, 34, 3, 3): None, (1, 34, 3, 4): None, (1, 34, 3, 5): None, (1, 34, 4, -5): None, (1, 34, 4, -4): None, (1, 34, 4, -3): None, (1, 34, 4, -2): None, (1, 34, 4, -1): None, (1, 34, 4, 0): None, (1, 34, 4, 1): None, (1, 34, 4, 2): None, (1, 34, 4, 3): None, (1, 34, 4, 4): None, (1, 34, 4, 5): None, (1, 34, 5, -5): None, (1, 34, 5, -4): None, (1, 34, 5, -3): None, (1, 34, 5, -2): None, (1, 34, 5, -1): None, (1, 34, 5, 0): None, (1, 34, 5, 1): None, (1, 34, 5, 2): None, (1, 34, 5, 3): None, (1, 34, 5, 4): None, (1, 34, 5, 5): None, (1, 35, -5, -5): None, (1, 35, -5, -4): None, (1, 35, -5, -3): None, (1, 35, -5, -2): None, (1, 35, -5, -1): None, (1, 35, -5, 0): None, (1, 35, -5, 1): None, (1, 35, -5, 2): None, (1, 35, -5, 3): None, (1, 35, -5, 4): None, (1, 35, -5, 5): None, (1, 35, -4, -5): None, (1, 35, -4, -4): None, (1, 35, -4, -3): None, (1, 35, -4, -2): None, (1, 35, -4, -1): None, (1, 35, -4, 0): None, (1, 35, -4, 1): None, (1, 35, -4, 2): None, (1, 35, -4, 3): None, (1, 35, -4, 4): None, (1, 35, -4, 5): None, (1, 35, -3, -5): None, (1, 35, -3, -4): None, (1, 35, -3, -3): None, (1, 35, -3, -2): None, (1, 35, -3, -1): None, (1, 35, -3, 0): None, (1, 35, -3, 1): None, (1, 35, -3, 2): None, (1, 35, -3, 3): None, (1, 35, -3, 4): None, (1, 35, -3, 5): None, (1, 35, -2, -5): None, (1, 35, -2, -4): None, (1, 35, -2, -3): None, (1, 35, -2, -2): None, (1, 35, -2, -1): None, (1, 35, -2, 0): None, (1, 35, -2, 1): None, (1, 35, -2, 2): None, (1, 35, -2, 3): None, (1, 35, -2, 4): None, (1, 35, -2, 5): None, (1, 35, -1, -5): None, (1, 35, -1, -4): None, (1, 35, -1, -3): None, (1, 35, -1, -2): None, (1, 35, -1, -1): None, (1, 35, -1, 0): None, (1, 35, -1, 1): None, (1, 35, -1, 2): None, (1, 35, -1, 3): None, (1, 35, -1, 4): None, (1, 35, -1, 5): None, (1, 35, 0, -5): None, (1, 35, 0, -4): None, (1, 35, 0, -3): None, (1, 35, 0, -2): None, (1, 35, 0, -1): None, (1, 35, 0, 0): None, (1, 35, 0, 1): None, (1, 35, 0, 2): None, (1, 35, 0, 3): None, (1, 35, 0, 4): None, (1, 35, 0, 5): None, (1, 35, 1, -5): None, (1, 35, 1, -4): None, (1, 35, 1, -3): None, (1, 35, 1, -2): None, (1, 35, 1, -1): None, (1, 35, 1, 0): None, (1, 35, 1, 1): None, (1, 35, 1, 2): None, (1, 35, 1, 3): None, (1, 35, 1, 4): None, (1, 35, 1, 5): None, (1, 35, 2, -5): None, (1, 35, 2, -4): None, (1, 35, 2, -3): None, (1, 35, 2, -2): None, (1, 35, 2, -1): None, (1, 35, 2, 0): None, (1, 35, 2, 1): None, (1, 35, 2, 2): None, (1, 35, 2, 3): None, (1, 35, 2, 4): None, (1, 35, 2, 5): None, (1, 35, 3, -5): None, (1, 35, 3, -4): None, (1, 35, 3, -3): None, (1, 35, 3, -2): None, (1, 35, 3, -1): None, (1, 35, 3, 0): None, (1, 35, 3, 1): None, (1, 35, 3, 2): None, (1, 35, 3, 3): None, (1, 35, 3, 4): None, (1, 35, 3, 5): None, (1, 35, 4, -5): None, (1, 35, 4, -4): None, (1, 35, 4, -3): None, (1, 35, 4, -2): None, (1, 35, 4, -1): None, (1, 35, 4, 0): None, (1, 35, 4, 1): None, (1, 35, 4, 2): None, (1, 35, 4, 3): None, (1, 35, 4, 4): None, (1, 35, 4, 5): None, (1, 35, 5, -5): None, (1, 35, 5, -4): None, (1, 35, 5, -3): None, (1, 35, 5, -2): None, (1, 35, 5, -1): None, (1, 35, 5, 0): None, (1, 35, 5, 1): None, (1, 35, 5, 2): None, (1, 35, 5, 3): None, (1, 35, 5, 4): None, (1, 35, 5, 5): None, (2, 32, -5, -5): (0, 1), (2, 32, -5, -4): (0, 1), (2, 32, -5, -3): (0, 1), (2, 32, -5, -2): (0, 1), (2, 32, -5, -1): (0, 1), (2, 32, -5, 0): (0, 1), (2, 32, -5, 1): (0, 1), (2, 32, -5, 2): (0, 1), (2, 32, -5, 3): (0, 0), (2, 32, -5, 4): (-1, -1), (2, 32, -5, 5): (0, 1), (2, 32, -4, -5): (0, 1), (2, 32, -4, -4): (0, 1), (2, 32, -4, -3): (0, 1), (2, 32, -4, -2): (0, 1), (2, 32, -4, -1): (0, 1), (2, 32, -4, 0): (0, 1), (2, 32, -4, 1): (0, 1), (2, 32, -4, 2): (0, 1), (2, 32, -4, 3): (0, 0), (2, 32, -4, 4): (-1, -1), (2, 32, -4, 5): (0, 1), (2, 32, -3, -5): (0, 1), (2, 32, -3, -4): (0, 1), (2, 32, -3, -3): (0, 1), (2, 32, -3, -2): (0, 1), (2, 32, -3, -1): (0, 1), (2, 32, -3, 0): (0, 1), (2, 32, -3, 1): (0, 1), (2, 32, -3, 2): (0, 1), (2, 32, -3, 3): (0, 0), (2, 32, -3, 4): (-1, -1), (2, 32, -3, 5): (0, 1), (2, 32, -2, -5): (0, 1), (2, 32, -2, -4): (0, 1), (2, 32, -2, -3): (0, 1), (2, 32, -2, -2): (0, 1), (2, 32, -2, -1): (0, 1), (2, 32, -2, 0): (0, 1), (2, 32, -2, 1): (0, 1), (2, 32, -2, 2): (0, 1), (2, 32, -2, 3): (0, 0), (2, 32, -2, 4): (-1, -1), (2, 32, -2, 5): (0, 1), (2, 32, -1, -5): (-1, 1), (2, 32, -1, -4): (1, 1), (2, 32, -1, -3): (-1, 1), (2, 32, -1, -2): (0, 1), (2, 32, -1, -1): (0, 1), (2, 32, -1, 0): (0, 1), (2, 32, -1, 1): (0, 1), (2, 32, -1, 2): (0, 1), (2, 32, -1, 3): (0, 0), (2, 32, -1, 4): (-1, -1), (2, 32, -1, 5): (0, 1), (2, 32, 0, -5): (-1, 1), (2, 32, 0, -4): (0, 1), (2, 32, 0, -3): (0, 1), (2, 32, 0, -2): (0, 1), (2, 32, 0, -1): (-1, 1), (2, 32, 0, 0): (-1, 1), (2, 32, 0, 1): (-1, 1), (2, 32, 0, 2): (-1, 1), (2, 32, 0, 3): (-1, 0), (2, 32, 0, 4): (-1, -1), (2, 32, 0, 5): (0, 1), (2, 32, 1, -5): (0, 1), (2, 32, 1, -4): (-1, 1), (2, 32, 1, -3): (-1, 1), (2, 32, 1, -2): (-1, 1), (2, 32, 1, -1): (-1, 1), (2, 32, 1, 0): (-1, 1), (2, 32, 1, 1): (-1, 1), (2, 32, 1, 2): (-1, 0), (2, 32, 1, 3): (-1, 1), (2, 32, 1, 4): (-1, 1), (2, 32, 1, 5): (-1, 1), (2, 32, 2, -5): (0, 1), (2, 32, 2, -4): (0, 1), (2, 32, 2, -3): (-1, 1), (2, 32, 2, -2): (-1, 1), (2, 32, 2, -1): (-1, 0), (2, 32, 2, 0): (-1, -1), (2, 32, 2, 1): (-1, 1), (2, 32, 2, 2): (-1, 1), (2, 32, 2, 3): (-1, 1), (2, 32, 2, 4): (-1, 1), (2, 32, 2, 5): (-1, 1), (2, 32, 3, -5): (0, 1), (2, 32, 3, -4): (0, 1), (2, 32, 3, -3): (0, 1), (2, 32, 3, -2): (-1, 1), (2, 32, 3, -1): (-1, 0), (2, 32, 3, 0): (-1, -1), (2, 32, 3, 1): (-1, 1), (2, 32, 3, 2): (-1, 1), (2, 32, 3, 3): (-1, 1), (2, 32, 3, 4): (-1, 1), (2, 32, 3, 5): (-1, 1), (2, 32, 4, -5): (-1, 1), (2, 32, 4, -4): (-1, 1), (2, 32, 4, -3): (-1, 1), (2, 32, 4, -2): (-1, 1), (2, 32, 4, -1): (-1, 0), (2, 32, 4, 0): (-1, -1), (2, 32, 4, 1): (-1, 1), (2, 32, 4, 2): (-1, 1), (2, 32, 4, 3): (-1, 1), (2, 32, 4, 4): (-1, 1), (2, 32, 4, 5): (-1, 1), (2, 32, 5, -5): (0, 1), (2, 32, 5, -4): (0, 1), (2, 32, 5, -3): (0, 1), (2, 32, 5, -2): (0, 1), (2, 32, 5, -1): (0, 1), (2, 32, 5, 0): (0, 1), (2, 32, 5, 1): (0, 1), (2, 32, 5, 2): (0, 1), (2, 32, 5, 3): (-1, 1), (2, 32, 5, 4): (-1, 1), (2, 32, 5, 5): (-1, 1), (2, 33, -5, -5): (0, 1), (2, 33, -5, -4): (0, 1), (2, 33, -5, -3): (0, 1), (2, 33, -5, -2): (0, 1), (2, 33, -5, -1): (0, 1), (2, 33, -5, 0): (0, 1), (2, 33, -5, 1): (0, 1), (2, 33, -5, 2): (0, 0), (2, 33, -5, 3): (-1, -1), (2, 33, -5, 4): (0, 1), (2, 33, -5, 5): (0, 1), (2, 33, -4, -5): (0, 1), (2, 33, -4, -4): (0, 1), (2, 33, -4, -3): (0, 1), (2, 33, -4, -2): (0, 1), (2, 33, -4, -1): (0, 1), (2, 33, -4, 0): (0, 1), (2, 33, -4, 1): (0, 1), (2, 33, -4, 2): (0, 0), (2, 33, -4, 3): (-1, -1), (2, 33, -4, 4): (0, 1), (2, 33, -4, 5): (0, 1), (2, 33, -3, -5): (0, 1), (2, 33, -3, -4): (0, 1), (2, 33, -3, -3): (0, 1), (2, 33, -3, -2): (0, 1), (2, 33, -3, -1): (0, 1), (2, 33, -3, 0): (0, 1), (2, 33, -3, 1): (0, 1), (2, 33, -3, 2): (0, 0), (2, 33, -3, 3): (-1, -1), (2, 33, -3, 4): (0, 1), (2, 33, -3, 5): (0, 1), (2, 33, -2, -5): (0, 1), (2, 33, -2, -4): (0, 1), (2, 33, -2, -3): (0, 1), (2, 33, -2, -2): (0, 1), (2, 33, -2, -1): (0, 1), (2, 33, -2, 0): (0, 1), (2, 33, -2, 1): (0, 1), (2, 33, -2, 2): (0, 0), (2, 33, -2, 3): (-1, -1), (2, 33, -2, 4): (0, 1), (2, 33, -2, 5): (0, 1), (2, 33, -1, -5): (1, 1), (2, 33, -1, -4): (-1, 1), (2, 33, -1, -3): (0, 1), (2, 33, -1, -2): (0, 1), (2, 33, -1, -1): (0, 1), (2, 33, -1, 0): (0, 1), (2, 33, -1, 1): (0, 1), (2, 33, -1, 2): (0, 0), (2, 33, -1, 3): (-1, -1), (2, 33, -1, 4): (0, 1), (2, 33, -1, 5): (0, 1), (2, 33, 0, -5): (0, 1), (2, 33, 0, -4): (0, 1), (2, 33, 0, -3): (0, 1), (2, 33, 0, -2): (-1, 1), (2, 33, 0, -1): (-1, 1), (2, 33, 0, 0): (-1, 1), (2, 33, 0, 1): (-1, 1), (2, 33, 0, 2): (-1, 0), (2, 33, 0, 3): (-1, -1), (2, 33, 0, 4): (0, 1), (2, 33, 0, 5): (0, 1), (2, 33, 1, -5): (-1, 1), (2, 33, 1, -4): (-1, 1), (2, 33, 1, -3): (-1, 1), (2, 33, 1, -2): (-1, 1), (2, 33, 1, -1): (-1, 1), (2, 33, 1, 0): (-1, 1), (2, 33, 1, 1): (-1, 0), (2, 33, 1, 2): (-1, 1), (2, 33, 1, 3): (-1, 1), (2, 33, 1, 4): (-1, 1), (2, 33, 1, 5): (-1, 1), (2, 33, 2, -5): (0, 1), (2, 33, 2, -4): (-1, 1), (2, 33, 2, -3): (-1, 1), (2, 33, 2, -2): (-1, 0), (2, 33, 2, -1): (-1, -1), (2, 33, 2, 0): (-1, -1), (2, 33, 2, 1): (-1, 1), (2, 33, 2, 2): (-1, 1), (2, 33, 2, 3): (-1, 1), (2, 33, 2, 4): (-1, 1), (2, 33, 2, 5): (-1, 1), (2, 33, 3, -5): (0, 1), (2, 33, 3, -4): (0, 1), (2, 33, 3, -3): (-1, 1), (2, 33, 3, -2): (-1, 0), (2, 33, 3, -1): (-1, -1), (2, 33, 3, 0): (-1, 1), (2, 33, 3, 1): (-1, 1), (2, 33, 3, 2): (-1, 1), (2, 33, 3, 3): (-1, 1), (2, 33, 3, 4): (-1, 1), (2, 33, 3, 5): (-1, 1), (2, 33, 4, -5): (-1, 1), (2, 33, 4, -4): (-1, 1), (2, 33, 4, -3): (-1, 1), (2, 33, 4, -2): (-1, 0), (2, 33, 4, -1): (-1, -1), (2, 33, 4, 0): (-1, 1), (2, 33, 4, 1): (-1, 1), (2, 33, 4, 2): (-1, 1), (2, 33, 4, 3): (-1, 1), (2, 33, 4, 4): (-1, 1), (2, 33, 4, 5): (-1, 1), (2, 33, 5, -5): (0, 1), (2, 33, 5, -4): (0, 1), (2, 33, 5, -3): (0, 1), (2, 33, 5, -2): (0, 0), (2, 33, 5, -1): (0, 1), (2, 33, 5, 0): (0, 1), (2, 33, 5, 1): (0, 1), (2, 33, 5, 2): (-1, 1), (2, 33, 5, 3): (-1, 1), (2, 33, 5, 4): (-1, 1), (2, 33, 5, 5): (-1, 1), (2, 34, -5, -5): (0, 1), (2, 34, -5, -4): (0, 1), (2, 34, -5, -3): (0, 1), (2, 34, -5, -2): (0, 1), (2, 34, -5, -1): (0, 1), (2, 34, -5, 0): (0, 1), (2, 34, -5, 1): (0, 0), (2, 34, -5, 2): (-1, -1), (2, 34, -5, 3): (0, 1), (2, 34, -5, 4): (0, 1), (2, 34, -5, 5): (0, 1), (2, 34, -4, -5): (0, 1), (2, 34, -4, -4): (0, 1), (2, 34, -4, -3): (0, 1), (2, 34, -4, -2): (0, 1), (2, 34, -4, -1): (0, 1), (2, 34, -4, 0): (0, 1), (2, 34, -4, 1): (0, 0), (2, 34, -4, 2): (-1, -1), (2, 34, -4, 3): (0, 1), (2, 34, -4, 4): (0, 1), (2, 34, -4, 5): (0, 1), (2, 34, -3, -5): (0, 1), (2, 34, -3, -4): (0, 1), (2, 34, -3, -3): (0, 1), (2, 34, -3, -2): (0, 1), (2, 34, -3, -1): (0, 1), (2, 34, -3, 0): (0, 1), (2, 34, -3, 1): (0, 0), (2, 34, -3, 2): (-1, -1), (2, 34, -3, 3): (0, 1), (2, 34, -3, 4): (0, 1), (2, 34, -3, 5): (0, 1), (2, 34, -2, -5): (0, 1), (2, 34, -2, -4): (0, 1), (2, 34, -2, -3): (0, 1), (2, 34, -2, -2): (0, 1), (2, 34, -2, -1): (0, 1), (2, 34, -2, 0): (0, 1), (2, 34, -2, 1): (0, 0), (2, 34, -2, 2): (-1, -1), (2, 34, -2, 3): (0, 1), (2, 34, -2, 4): (0, 1), (2, 34, -2, 5): (0, 1), (2, 34, -1, -5): (-1, 1), (2, 34, -1, -4): (0, 1), (2, 34, -1, -3): (0, 1), (2, 34, -1, -2): (0, 1), (2, 34, -1, -1): (0, 1), (2, 34, -1, 0): (0, 1), (2, 34, -1, 1): (0, 0), (2, 34, -1, 2): (-1, -1), (2, 34, -1, 3): (0, 1), (2, 34, -1, 4): (0, 1), (2, 34, -1, 5): (0, 1), (2, 34, 0, -5): (0, 1), (2, 34, 0, -4): (0, 1), (2, 34, 0, -3): (-1, 1), (2, 34, 0, -2): (-1, 1), (2, 34, 0, -1): (-1, 1), (2, 34, 0, 0): (-1, 1), (2, 34, 0, 1): (-1, 0), (2, 34, 0, 2): (-1, -1), (2, 34, 0, 3): (0, 1), (2, 34, 0, 4): (0, 1), (2, 34, 0, 5): (0, 1), (2, 34, 1, -5): (-1, 1), (2, 34, 1, -4): (-1, 1), (2, 34, 1, -3): (-1, 0), (2, 34, 1, -2): (-1, 1), (2, 34, 1, -1): (-1, 1), (2, 34, 1, 0): (-1, 1), (2, 34, 1, 1): (-1, 1), (2, 34, 1, 2): (-1, 1), (2, 34, 1, 3): (-1, 1), (2, 34, 1, 4): (-1, 1), (2, 34, 1, 5): (-1, 1), (2, 34, 2, -5): (-1, 1), (2, 34, 2, -4): (-1, 1), (2, 34, 2, -3): (-1, 0), (2, 34, 2, -2): (-1, -1), (2, 34, 2, -1): (-1, 0), (2, 34, 2, 0): (-1, 1), (2, 34, 2, 1): (-1, 1), (2, 34, 2, 2): (-1, 1), (2, 34, 2, 3): (-1, 1), (2, 34, 2, 4): (-1, 1), (2, 34, 2, 5): (-1, 1), (2, 34, 3, -5): (0, 1), (2, 34, 3, -4): (-1, 1), (2, 34, 3, -3): (-1, 0), (2, 34, 3, -2): (-1, -1), (2, 34, 3, -1): (-1, 0), (2, 34, 3, 0): (-1, 1), (2, 34, 3, 1): (-1, 1), (2, 34, 3, 2): (-1, 1), (2, 34, 3, 3): (-1, 1), (2, 34, 3, 4): (-1, 1), (2, 34, 3, 5): (-1, 1), (2, 34, 4, -5): (-1, 1), (2, 34, 4, -4): (-1, 1), (2, 34, 4, -3): (-1, 0), (2, 34, 4, -2): (-1, -1), (2, 34, 4, -1): (0, 1), (2, 34, 4, 0): (-1, 1), (2, 34, 4, 1): (-1, 1), (2, 34, 4, 2): (-1, 1), (2, 34, 4, 3): (-1, 1), (2, 34, 4, 4): (-1, 1), (2, 34, 4, 5): (-1, 1), (2, 34, 5, -5): (0, 1), (2, 34, 5, -4): (0, 1), (2, 34, 5, -3): (0, 1), (2, 34, 5, -2): (0, 1), (2, 34, 5, -1): (0, 1), (2, 34, 5, 0): (0, 1), (2, 34, 5, 1): (-1, 1), (2, 34, 5, 2): (-1, 1), (2, 34, 5, 3): (-1, 1), (2, 34, 5, 4): (-1, 1), (2, 34, 5, 5): (-1, 1), (2, 35, -5, -5): (0, 1), (2, 35, -5, -4): (0, 1), (2, 35, -5, -3): (0, 1), (2, 35, -5, -2): (0, 1), (2, 35, -5, -1): (0, 1), (2, 35, -5, 0): (0, 0), (2, 35, -5, 1): (-1, -1), (2, 35, -5, 2): (0, 1), (2, 35, -5, 3): (0, 1), (2, 35, -5, 4): (0, 1), (2, 35, -5, 5): (0, 1), (2, 35, -4, -5): (0, 1), (2, 35, -4, -4): (0, 1), (2, 35, -4, -3): (0, 1), (2, 35, -4, -2): (0, 1), (2, 35, -4, -1): (0, 1), (2, 35, -4, 0): (0, 0), (2, 35, -4, 1): (-1, -1), (2, 35, -4, 2): (0, 1), (2, 35, -4, 3): (0, 1), (2, 35, -4, 4): (0, 1), (2, 35, -4, 5): (0, 1), (2, 35, -3, -5): (0, 1), (2, 35, -3, -4): (0, 1), (2, 35, -3, -3): (0, 1), (2, 35, -3, -2): (0, 1), (2, 35, -3, -1): (0, 1), (2, 35, -3, 0): (0, 0), (2, 35, -3, 1): (-1, -1), (2, 35, -3, 2): (0, 1), (2, 35, -3, 3): (0, 1), (2, 35, -3, 4): (0, 1), (2, 35, -3, 5): (0, 1), (2, 35, -2, -5): (0, 1), (2, 35, -2, -4): (0, 1), (2, 35, -2, -3): (0, 1), (2, 35, -2, -2): (0, 1), (2, 35, -2, -1): (0, 1), (2, 35, -2, 0): (0, 0), (2, 35, -2, 1): (-1, -1), (2, 35, -2, 2): (0, 1), (2, 35, -2, 3): (0, 1), (2, 35, -2, 4): (0, 1), (2, 35, -2, 5): (0, 1), (2, 35, -1, -5): (0, 1), (2, 35, -1, -4): (0, 1), (2, 35, -1, -3): (0, 1), (2, 35, -1, -2): (0, 1), (2, 35, -1, -1): (0, 1), (2, 35, -1, 0): (0, 0), (2, 35, -1, 1): (-1, -1), (2, 35, -1, 2): (0, 1), (2, 35, -1, 3): (0, 1), (2, 35, -1, 4): (0, 1), (2, 35, -1, 5): (0, 1), (2, 35, 0, -5): (0, 1), (2, 35, 0, -4): (-1, 1), (2, 35, 0, -3): (-1, 1), (2, 35, 0, -2): (-1, 1), (2, 35, 0, -1): (-1, 1), (2, 35, 0, 0): (-1, 0), (2, 35, 0, 1): (-1, -1), (2, 35, 0, 2): (0, 1), (2, 35, 0, 3): (0, 1), (2, 35, 0, 4): (0, 1), (2, 35, 0, 5): (0, 1), (2, 35, 1, -5): (-1, 1), (2, 35, 1, -4): (-1, 0), (2, 35, 1, -3): (-1, 1), (2, 35, 1, -2): (-1, 1), (2, 35, 1, -1): (-1, 1), (2, 35, 1, 0): (-1, 1), (2, 35, 1, 1): (-1, 1), (2, 35, 1, 2): (-1, 1), (2, 35, 1, 3): (-1, 1), (2, 35, 1, 4): (-1, 1), (2, 35, 1, 5): (-1, 1), (2, 35, 2, -5): (-1, 1), (2, 35, 2, -4): (-1, 0), (2, 35, 2, -3): (-1, -1), (2, 35, 2, -2): (-1, 0), (2, 35, 2, -1): (-1, -1), (2, 35, 2, 0): (-1, 1), (2, 35, 2, 1): (-1, 1), (2, 35, 2, 2): (-1, 1), (2, 35, 2, 3): (-1, 1), (2, 35, 2, 4): (-1, 1), (2, 35, 2, 5): (-1, 1), (2, 35, 3, -5): (-1, 1), (2, 35, 3, -4): (-1, 0), (2, 35, 3, -3): (-1, -1), (2, 35, 3, -2): (-1, 0), (2, 35, 3, -1): (-1, 1), (2, 35, 3, 0): (-1, 1), (2, 35, 3, 1): (-1, 1), (2, 35, 3, 2): (-1, 1), (2, 35, 3, 3): (-1, 1), (2, 35, 3, 4): (-1, 1), (2, 35, 3, 5): (-1, 1), (2, 35, 4, -5): (-1, 1), (2, 35, 4, -4): (-1, 0), (2, 35, 4, -3): (-1, -1), (2, 35, 4, -2): (0, 1), (2, 35, 4, -1): (-1, 1), (2, 35, 4, 0): (-1, 1), (2, 35, 4, 1): (-1, 1), (2, 35, 4, 2): (-1, 1), (2, 35, 4, 3): (-1, 1), (2, 35, 4, 4): (-1, 1), (2, 35, 4, 5): (-1, 1), (2, 35, 5, -5): (0, 1), (2, 35, 5, -4): (0, 1), (2, 35, 5, -3): (0, 0), (2, 35, 5, -2): (0, 1), (2, 35, 5, -1): (0, 1), (2, 35, 5, 0): (-1, 1), (2, 35, 5, 1): (-1, 1), (2, 35, 5, 2): (-1, 1), (2, 35, 5, 3): (-1, 1), (2, 35, 5, 4): (-1, 1), (2, 35, 5, 5): (-1, 1), (3, 32, -5, -5): (0, 1), (3, 32, -5, -4): (0, 1), (3, 32, -5, -3): (0, 1), (3, 32, -5, -2): (0, 1), (3, 32, -5, -1): (0, 1), (3, 32, -5, 0): (0, 1), (3, 32, -5, 1): (0, 1), (3, 32, -5, 2): (0, 1), (3, 32, -5, 3): (0, 0), (3, 32, -5, 4): (-1, -1), (3, 32, -5, 5): (0, 1), (3, 32, -4, -5): (0, 1), (3, 32, -4, -4): (0, 1), (3, 32, -4, -3): (0, 1), (3, 32, -4, -2): (0, 1), (3, 32, -4, -1): (0, 1), (3, 32, -4, 0): (0, 1), (3, 32, -4, 1): (0, 1), (3, 32, -4, 2): (0, 1), (3, 32, -4, 3): (0, 0), (3, 32, -4, 4): (-1, -1), (3, 32, -4, 5): (0, 1), (3, 32, -3, -5): (0, 1), (3, 32, -3, -4): (0, 1), (3, 32, -3, -3): (0, 1), (3, 32, -3, -2): (0, 1), (3, 32, -3, -1): (0, 1), (3, 32, -3, 0): (0, 1), (3, 32, -3, 1): (0, 1), (3, 32, -3, 2): (0, 1), (3, 32, -3, 3): (0, 0), (3, 32, -3, 4): (-1, -1), (3, 32, -3, 5): (0, 1), (3, 32, -2, -5): (-1, 1), (3, 32, -2, -4): (1, 1), (3, 32, -2, -3): (-1, 1), (3, 32, -2, -2): (0, 1), (3, 32, -2, -1): (0, 1), (3, 32, -2, 0): (0, 1), (3, 32, -2, 1): (0, 1), (3, 32, -2, 2): (0, 1), (3, 32, -2, 3): (0, 0), (3, 32, -2, 4): (-1, -1), (3, 32, -2, 5): (0, 1), (3, 32, -1, -5): (-1, 1), (3, 32, -1, -4): (0, 1), (3, 32, -1, -3): (0, 1), (3, 32, -1, -2): (0, 1), (3, 32, -1, -1): (-1, 1), (3, 32, -1, 0): (-1, 1), (3, 32, -1, 1): (-1, 1), (3, 32, -1, 2): (-1, 1), (3, 32, -1, 3): (-1, 0), (3, 32, -1, 4): (-1, -1), (3, 32, -1, 5): (0, 1), (3, 32, 0, -5): (0, 1), (3, 32, 0, -4): (-1, 1), (3, 32, 0, -3): (-1, 1), (3, 32, 0, -2): (-1, 1), (3, 32, 0, -1): (-1, 1), (3, 32, 0, 0): (-1, 1), (3, 32, 0, 1): (-1, 0), (3, 32, 0, 2): (-1, -1), (3, 32, 0, 3): (-1, 1), (3, 32, 0, 4): (-1, 1), (3, 32, 0, 5): (-1, 1), (3, 32, 1, -5): (0, 1), (3, 32, 1, -4): (0, 1), (3, 32, 1, -3): (-1, 1), (3, 32, 1, -2): (-1, 1), (3, 32, 1, -1): (-1, 1), (3, 32, 1, 0): (-1, 1), (3, 32, 1, 1): (-1, 0), (3, 32, 1, 2): (-1, -1), (3, 32, 1, 3): (-1, 1), (3, 32, 1, 4): (-1, 1), (3, 32, 1, 5): (-1, 1), (3, 32, 2, -5): (0, 1), (3, 32, 2, -4): (0, 1), (3, 32, 2, -3): (0, 1), (3, 32, 2, -2): (-1, 1), (3, 32, 2, -1): (-1, 0), (3, 32, 2, 0): (-1, -1), (3, 32, 2, 1): (-1, 1), (3, 32, 2, 2): (-1, 1), (3, 32, 2, 3): (-1, 1), (3, 32, 2, 4): (-1, 1), (3, 32, 2, 5): (-1, 1), (3, 32, 3, -5): (-1, 1), (3, 32, 3, -4): (-1, 1), (3, 32, 3, -3): (-1, 1), (3, 32, 3, -2): (-1, 1), (3, 32, 3, -1): (-1, 0), (3, 32, 3, 0): (-1, -1), (3, 32, 3, 1): (-1, 1), (3, 32, 3, 2): (-1, 1), (3, 32, 3, 3): (-1, 1), (3, 32, 3, 4): (-1, 1), (3, 32, 3, 5): (-1, 1), (3, 32, 4, -5): (0, 1), (3, 32, 4, -4): (0, 1), (3, 32, 4, -3): (0, 1), (3, 32, 4, -2): (0, 1), (3, 32, 4, -1): (0, 1), (3, 32, 4, 0): (0, 1), (3, 32, 4, 1): (-1, 1), (3, 32, 4, 2): (-1, 1), (3, 32, 4, 3): (-1, 1), (3, 32, 4, 4): (-1, 1), (3, 32, 4, 5): (-1, 1), (3, 32, 5, -5): (0, 1), (3, 32, 5, -4): (0, 1), (3, 32, 5, -3): (0, 1), (3, 32, 5, -2): (0, 1), (3, 32, 5, -1): (0, 1), (3, 32, 5, 0): (0, 1), (3, 32, 5, 1): (0, 1), (3, 32, 5, 2): (0, 1), (3, 32, 5, 3): (-1, 1), (3, 32, 5, 4): (-1, 1), (3, 32, 5, 5): (-1, 1), (3, 33, -5, -5): (0, 1), (3, 33, -5, -4): (0, 1), (3, 33, -5, -3): (0, 1), (3, 33, -5, -2): (0, 1), (3, 33, -5, -1): (0, 1), (3, 33, -5, 0): (0, 1), (3, 33, -5, 1): (0, 1), (3, 33, -5, 2): (0, 0), (3, 33, -5, 3): (-1, -1), (3, 33, -5, 4): (0, 1), (3, 33, -5, 5): (0, 1), (3, 33, -4, -5): (0, 1), (3, 33, -4, -4): (0, 1), (3, 33, -4, -3): (0, 1), (3, 33, -4, -2): (0, 1), (3, 33, -4, -1): (0, 1), (3, 33, -4, 0): (0, 1), (3, 33, -4, 1): (0, 1), (3, 33, -4, 2): (0, 0), (3, 33, -4, 3): (-1, -1), (3, 33, -4, 4): (0, 1), (3, 33, -4, 5): (0, 1), (3, 33, -3, -5): (0, 1), (3, 33, -3, -4): (0, 1), (3, 33, -3, -3): (0, 1), (3, 33, -3, -2): (0, 1), (3, 33, -3, -1): (0, 1), (3, 33, -3, 0): (0, 1), (3, 33, -3, 1): (0, 1), (3, 33, -3, 2): (0, 0), (3, 33, -3, 3): (-1, -1), (3, 33, -3, 4): (0, 1), (3, 33, -3, 5): (0, 1), (3, 33, -2, -5): (1, 1), (3, 33, -2, -4): (-1, 1), (3, 33, -2, -3): (0, 1), (3, 33, -2, -2): (0, 1), (3, 33, -2, -1): (0, 1), (3, 33, -2, 0): (0, 1), (3, 33, -2, 1): (0, 1), (3, 33, -2, 2): (0, 0), (3, 33, -2, 3): (-1, -1), (3, 33, -2, 4): (0, 1), (3, 33, -2, 5): (0, 1), (3, 33, -1, -5): (0, 1), (3, 33, -1, -4): (0, 1), (3, 33, -1, -3): (0, 1), (3, 33, -1, -2): (-1, 1), (3, 33, -1, -1): (-1, 1), (3, 33, -1, 0): (-1, 1), (3, 33, -1, 1): (-1, 1), (3, 33, -1, 2): (-1, 0), (3, 33, -1, 3): (-1, -1), (3, 33, -1, 4): (0, 1), (3, 33, -1, 5): (0, 1), (3, 33, 0, -5): (-1, 1), (3, 33, 0, -4): (-1, 1), (3, 33, 0, -3): (-1, 1), (3, 33, 0, -2): (-1, 1), (3, 33, 0, -1): (-1, 1), (3, 33, 0, 0): (-1, 1), (3, 33, 0, 1): (-1, 0), (3, 33, 0, 2): (-1, -1), (3, 33, 0, 3): (-1, 1), (3, 33, 0, 4): (-1, 1), (3, 33, 0, 5): (-1, 1), (3, 33, 1, -5): (0, 1), (3, 33, 1, -4): (-1, 1), (3, 33, 1, -3): (-1, 1), (3, 33, 1, -2): (-1, 1), (3, 33, 1, -1): (-1, 1), (3, 33, 1, 0): (-1, 1), (3, 33, 1, 1): (-1, 0), (3, 33, 1, 2): (-1, 1), (3, 33, 1, 3): (-1, 1), (3, 33, 1, 4): (-1, 1), (3, 33, 1, 5): (-1, 1), (3, 33, 2, -5): (0, 1), (3, 33, 2, -4): (0, 1), (3, 33, 2, -3): (-1, 1), (3, 33, 2, -2): (-1, 0), (3, 33, 2, -1): (-1, -1), (3, 33, 2, 0): (-1, -1), (3, 33, 2, 1): (-1, 1), (3, 33, 2, 2): (-1, 1), (3, 33, 2, 3): (-1, 1), (3, 33, 2, 4): (-1, 1), (3, 33, 2, 5): (-1, 1), (3, 33, 3, -5): (-1, 1), (3, 33, 3, -4): (-1, 1), (3, 33, 3, -3): (-1, 1), (3, 33, 3, -2): (-1, 0), (3, 33, 3, -1): (-1, -1), (3, 33, 3, 0): (-1, 1), (3, 33, 3, 1): (-1, 1), (3, 33, 3, 2): (-1, 1), (3, 33, 3, 3): (-1, 1), (3, 33, 3, 4): (-1, 1), (3, 33, 3, 5): (-1, 1), (3, 33, 4, -5): (0, 1), (3, 33, 4, -4): (0, 1), (3, 33, 4, -3): (0, 1), (3, 33, 4, -2): (0, 0), (3, 33, 4, -1): (0, 1), (3, 33, 4, 0): (0, 1), (3, 33, 4, 1): (-1, 1), (3, 33, 4, 2): (-1, 1), (3, 33, 4, 3): (-1, 1), (3, 33, 4, 4): (-1, 1), (3, 33, 4, 5): (-1, 1), (3, 33, 5, -5): (0, 1), (3, 33, 5, -4): (0, 1), (3, 33, 5, -3): (0, 1), (3, 33, 5, -2): (0, 0), (3, 33, 5, -1): (0, 1), (3, 33, 5, 0): (0, 1), (3, 33, 5, 1): (0, 1), (3, 33, 5, 2): (-1, 1), (3, 33, 5, 3): (-1, 1), (3, 33, 5, 4): (-1, 1), (3, 33, 5, 5): (-1, 1), (3, 34, -5, -5): (0, 1), (3, 34, -5, -4): (0, 1), (3, 34, -5, -3): (0, 1), (3, 34, -5, -2): (0, 1), (3, 34, -5, -1): (0, 1), (3, 34, -5, 0): (0, 1), (3, 34, -5, 1): (0, 0), (3, 34, -5, 2): (-1, -1), (3, 34, -5, 3): (0, 1), (3, 34, -5, 4): (0, 1), (3, 34, -5, 5): (0, 1), (3, 34, -4, -5): (0, 1), (3, 34, -4, -4): (0, 1), (3, 34, -4, -3): (0, 1), (3, 34, -4, -2): (0, 1), (3, 34, -4, -1): (0, 1), (3, 34, -4, 0): (0, 1), (3, 34, -4, 1): (0, 0), (3, 34, -4, 2): (-1, -1), (3, 34, -4, 3): (0, 1), (3, 34, -4, 4): (0, 1), (3, 34, -4, 5): (0, 1), (3, 34, -3, -5): (0, 1), (3, 34, -3, -4): (0, 1), (3, 34, -3, -3): (0, 1), (3, 34, -3, -2): (0, 1), (3, 34, -3, -1): (0, 1), (3, 34, -3, 0): (0, 1), (3, 34, -3, 1): (0, 0), (3, 34, -3, 2): (-1, -1), (3, 34, -3, 3): (0, 1), (3, 34, -3, 4): (0, 1), (3, 34, -3, 5): (0, 1), (3, 34, -2, -5): (-1, 1), (3, 34, -2, -4): (0, 1), (3, 34, -2, -3): (0, 1), (3, 34, -2, -2): (0, 1), (3, 34, -2, -1): (0, 1), (3, 34, -2, 0): (0, 1), (3, 34, -2, 1): (0, 0), (3, 34, -2, 2): (-1, -1), (3, 34, -2, 3): (0, 1), (3, 34, -2, 4): (0, 1), (3, 34, -2, 5): (0, 1), (3, 34, -1, -5): (0, 1), (3, 34, -1, -4): (0, 1), (3, 34, -1, -3): (-1, 1), (3, 34, -1, -2): (-1, 1), (3, 34, -1, -1): (-1, 1), (3, 34, -1, 0): (-1, 1), (3, 34, -1, 1): (-1, 0), (3, 34, -1, 2): (-1, -1), (3, 34, -1, 3): (0, 1), (3, 34, -1, 4): (0, 1), (3, 34, -1, 5): (0, 1), (3, 34, 0, -5): (-1, 1), (3, 34, 0, -4): (-1, 1), (3, 34, 0, -3): (-1, 0), (3, 34, 0, -2): (-1, 1), (3, 34, 0, -1): (-1, 1), (3, 34, 0, 0): (-1, 0), (3, 34, 0, 1): (-1, -1), (3, 34, 0, 2): (-1, 1), (3, 34, 0, 3): (-1, 1), (3, 34, 0, 4): (-1, 1), (3, 34, 0, 5): (-1, 1), (3, 34, 1, -5): (-1, 1), (3, 34, 1, -4): (-1, 1), (3, 34, 1, -3): (-1, 0), (3, 34, 1, -2): (-1, 1), (3, 34, 1, -1): (-1, 1), (3, 34, 1, 0): (-1, 1), (3, 34, 1, 1): (-1, 1), (3, 34, 1, 2): (-1, 1), (3, 34, 1, 3): (-1, 1), (3, 34, 1, 4): (-1, 1), (3, 34, 1, 5): (-1, 1), (3, 34, 2, -5): (0, 1), (3, 34, 2, -4): (-1, 1), (3, 34, 2, -3): (-1, 0), (3, 34, 2, -2): (-1, -1), (3, 34, 2, -1): (-1, 1), (3, 34, 2, 0): (-1, 1), (3, 34, 2, 1): (-1, 1), (3, 34, 2, 2): (-1, 1), (3, 34, 2, 3): (-1, 1), (3, 34, 2, 4): (-1, 1), (3, 34, 2, 5): (-1, 1), (3, 34, 3, -5): (-1, 1), (3, 34, 3, -4): (-1, 1), (3, 34, 3, -3): (-1, 0), (3, 34, 3, -2): (-1, -1), (3, 34, 3, -1): (1, 0), (3, 34, 3, 0): (-1, 1), (3, 34, 3, 1): (-1, 1), (3, 34, 3, 2): (-1, 1), (3, 34, 3, 3): (-1, 1), (3, 34, 3, 4): (-1, 1), (3, 34, 3, 5): (-1, 1), (3, 34, 4, -5): (0, 1), (3, 34, 4, -4): (0, 1), (3, 34, 4, -3): (0, 1), (3, 34, 4, -2): (0, 1), (3, 34, 4, -1): (0, 1), (3, 34, 4, 0): (-1, 1), (3, 34, 4, 1): (-1, 1), (3, 34, 4, 2): (-1, 1), (3, 34, 4, 3): (-1, 1), (3, 34, 4, 4): (-1, 1), (3, 34, 4, 5): (-1, 1), (3, 34, 5, -5): (0, 1), (3, 34, 5, -4): (0, 1), (3, 34, 5, -3): (0, 1), (3, 34, 5, -2): (0, 1), (3, 34, 5, -1): (0, 1), (3, 34, 5, 0): (0, 1), (3, 34, 5, 1): (-1, 1), (3, 34, 5, 2): (-1, 1), (3, 34, 5, 3): (-1, 1), (3, 34, 5, 4): (-1, 1), (3, 34, 5, 5): (-1, 1), (3, 35, -5, -5): (0, 1), (3, 35, -5, -4): (0, 1), (3, 35, -5, -3): (0, 1), (3, 35, -5, -2): (0, 1), (3, 35, -5, -1): (0, 1), (3, 35, -5, 0): (0, 0), (3, 35, -5, 1): (-1, -1), (3, 35, -5, 2): (0, 1), (3, 35, -5, 3): (0, 1), (3, 35, -5, 4): (0, 1), (3, 35, -5, 5): (0, 1), (3, 35, -4, -5): (0, 1), (3, 35, -4, -4): (0, 1), (3, 35, -4, -3): (0, 1), (3, 35, -4, -2): (0, 1), (3, 35, -4, -1): (0, 1), (3, 35, -4, 0): (0, 0), (3, 35, -4, 1): (-1, -1), (3, 35, -4, 2): (0, 1), (3, 35, -4, 3): (0, 1), (3, 35, -4, 4): (0, 1), (3, 35, -4, 5): (0, 1), (3, 35, -3, -5): (0, 1), (3, 35, -3, -4): (0, 1), (3, 35, -3, -3): (0, 1), (3, 35, -3, -2): (0, 1), (3, 35, -3, -1): (0, 1), (3, 35, -3, 0): (0, 0), (3, 35, -3, 1): (-1, -1), (3, 35, -3, 2): (0, 1), (3, 35, -3, 3): (0, 1), (3, 35, -3, 4): (0, 1), (3, 35, -3, 5): (0, 1), (3, 35, -2, -5): (0, 1), (3, 35, -2, -4): (0, 1), (3, 35, -2, -3): (0, 1), (3, 35, -2, -2): (0, 1), (3, 35, -2, -1): (0, 1), (3, 35, -2, 0): (0, 0), (3, 35, -2, 1): (-1, -1), (3, 35, -2, 2): (0, 1), (3, 35, -2, 3): (0, 1), (3, 35, -2, 4): (0, 1), (3, 35, -2, 5): (0, 1), (3, 35, -1, -5): (0, 1), (3, 35, -1, -4): (-1, 1), (3, 35, -1, -3): (-1, 1), (3, 35, -1, -2): (-1, 1), (3, 35, -1, -1): (-1, 1), (3, 35, -1, 0): (-1, 0), (3, 35, -1, 1): (-1, -1), (3, 35, -1, 2): (0, 1), (3, 35, -1, 3): (0, 1), (3, 35, -1, 4): (0, 1), (3, 35, -1, 5): (0, 1), (3, 35, 0, -5): (-1, 1), (3, 35, 0, -4): (-1, 0), (3, 35, 0, -3): (-1, 1), (3, 35, 0, -2): (-1, 1), (3, 35, 0, -1): (-1, 1), (3, 35, 0, 0): (-1, 0), (3, 35, 0, 1): (-1, -1), (3, 35, 0, 2): (-1, 1), (3, 35, 0, 3): (-1, 1), (3, 35, 0, 4): (-1, 1), (3, 35, 0, 5): (-1, 1), (3, 35, 1, -5): (-1, 1), (3, 35, 1, -4): (-1, 0), (3, 35, 1, -3): (-1, -1), (3, 35, 1, -2): (-1, 1), (3, 35, 1, -1): (-1, 1), (3, 35, 1, 0): (-1, 1), (3, 35, 1, 1): (-1, 1), (3, 35, 1, 2): (-1, 1), (3, 35, 1, 3): (-1, 1), (3, 35, 1, 4): (-1, 1), (3, 35, 1, 5): (-1, 1), (3, 35, 2, -5): (-1, 1), (3, 35, 2, -4): (-1, 0), (3, 35, 2, -3): (-1, -1), (3, 35, 2, -2): (-1, 0), (3, 35, 2, -1): (-1, -1), (3, 35, 2, 0): (-1, 1), (3, 35, 2, 1): (-1, 1), (3, 35, 2, 2): (-1, 1), (3, 35, 2, 3): (-1, 1), (3, 35, 2, 4): (-1, 1), (3, 35, 2, 5): (-1, 1), (3, 35, 3, -5): (-1, 1), (3, 35, 3, -4): (-1, 0), (3, 35, 3, -3): (-1, -1), (3, 35, 3, -2): (1, 1), (3, 35, 3, -1): (-1, 1), (3, 35, 3, 0): (-1, 1), (3, 35, 3, 1): (-1, 1), (3, 35, 3, 2): (-1, 1), (3, 35, 3, 3): (-1, 1), (3, 35, 3, 4): (-1, 1), (3, 35, 3, 5): (-1, 1), (3, 35, 4, -5): (0, 1), (3, 35, 4, -4): (0, 1), (3, 35, 4, -3): (0, 0), (3, 35, 4, -2): (0, 1), (3, 35, 4, -1): (0, 1), (3, 35, 4, 0): (-1, 1), (3, 35, 4, 1): (-1, 1), (3, 35, 4, 2): (-1, 1), (3, 35, 4, 3): (-1, 1), (3, 35, 4, 4): (-1, 1), (3, 35, 4, 5): (-1, 1), (3, 35, 5, -5): (0, 1), (3, 35, 5, -4): (0, 1), (3, 35, 5, -3): (0, 0), (3, 35, 5, -2): (0, 1), (3, 35, 5, -1): (0, 1), (3, 35, 5, 0): (-1, 1), (3, 35, 5, 1): (-1, 1), (3, 35, 5, 2): (-1, 1), (3, 35, 5, 3): (-1, 1), (3, 35, 5, 4): (-1, 1), (3, 35, 5, 5): (-1, 1), (4, 32, -5, -5): (0, 1), (4, 32, -5, -4): (0, 1), (4, 32, -5, -3): (0, 1), (4, 32, -5, -2): (0, 1), (4, 32, -5, -1): (0, 1), (4, 32, -5, 0): (0, 1), (4, 32, -5, 1): (0, 1), (4, 32, -5, 2): (0, 1), (4, 32, -5, 3): (0, 0), (4, 32, -5, 4): (-1, -1), (4, 32, -5, 5): (0, 1), (4, 32, -4, -5): (0, 1), (4, 32, -4, -4): (0, 1), (4, 32, -4, -3): (0, 1), (4, 32, -4, -2): (0, 1), (4, 32, -4, -1): (0, 1), (4, 32, -4, 0): (0, 1), (4, 32, -4, 1): (0, 1), (4, 32, -4, 2): (0, 1), (4, 32, -4, 3): (0, 0), (4, 32, -4, 4): (-1, -1), (4, 32, -4, 5): (0, 1), (4, 32, -3, -5): (-1, 1), (4, 32, -3, -4): (1, 1), (4, 32, -3, -3): (-1, 1), (4, 32, -3, -2): (0, 1), (4, 32, -3, -1): (0, 1), (4, 32, -3, 0): (0, 1), (4, 32, -3, 1): (0, 1), (4, 32, -3, 2): (0, 1), (4, 32, -3, 3): (0, 0), (4, 32, -3, 4): (-1, -1), (4, 32, -3, 5): (0, 1), (4, 32, -2, -5): (-1, 1), (4, 32, -2, -4): (0, 1), (4, 32, -2, -3): (0, 1), (4, 32, -2, -2): (0, 1), (4, 32, -2, -1): (-1, 1), (4, 32, -2, 0): (-1, 1), (4, 32, -2, 1): (-1, 1), (4, 32, -2, 2): (-1, 1), (4, 32, -2, 3): (-1, 0), (4, 32, -2, 4): (-1, -1), (4, 32, -2, 5): (0, 1), (4, 32, -1, -5): (0, 1), (4, 32, -1, -4): (-1, 1), (4, 32, -1, -3): (-1, 1), (4, 32, -1, -2): (-1, 1), (4, 32, -1, -1): (-1, 1), (4, 32, -1, 0): (-1, 1), (4, 32, -1, 1): (-1, 0), (4, 32, -1, 2): (-1, -1), (4, 32, -1, 3): (-1, 1), (4, 32, -1, 4): (-1, 1), (4, 32, -1, 5): (-1, 1), (4, 32, 0, -5): (0, 1), (4, 32, 0, -4): (0, 1), (4, 32, 0, -3): (-1, 1), (4, 32, 0, -2): (-1, 1), (4, 32, 0, -1): (-1, 1), (4, 32, 0, 0): (-1, 1), (4, 32, 0, 1): (-1, 0), (4, 32, 0, 2): (-1, -1), (4, 32, 0, 3): (-1, -1), (4, 32, 0, 4): (-1, -1), (4, 32, 0, 5): (-1, 1), (4, 32, 1, -5): (0, 1), (4, 32, 1, -4): (0, 1), (4, 32, 1, -3): (0, 1), (4, 32, 1, -2): (-1, 1), (4, 32, 1, -1): (-1, 1), (4, 32, 1, 0): (-1, 1), (4, 32, 1, 1): (-1, 0), (4, 32, 1, 2): (-1, -1), (4, 32, 1, 3): (-1, 1), (4, 32, 1, 4): (-1, 1), (4, 32, 1, 5): (-1, 1), (4, 32, 2, -5): (-1, 1), (4, 32, 2, -4): (-1, 1), (4, 32, 2, -3): (-1, 1), (4, 32, 2, -2): (-1, 1), (4, 32, 2, -1): (-1, 0), (4, 32, 2, 0): (-1, -1), (4, 32, 2, 1): (-1, 1), (4, 32, 2, 2): (-1, 1), (4, 32, 2, 3): (-1, 1), (4, 32, 2, 4): (-1, 1), (4, 32, 2, 5): (-1, 1), (4, 32, 3, -5): (0, 1), (4, 32, 3, -4): (0, 1), (4, 32, 3, -3): (0, 1), (4, 32, 3, -2): (0, 1), (4, 32, 3, -1): (0, 1), (4, 32, 3, 0): (0, 1), (4, 32, 3, 1): (-1, 1), (4, 32, 3, 2): (-1, 1), (4, 32, 3, 3): (-1, 1), (4, 32, 3, 4): (-1, 1), (4, 32, 3, 5): (-1, 1), (4, 32, 4, -5): (0, 1), (4, 32, 4, -4): (0, 1), (4, 32, 4, -3): (0, 1), (4, 32, 4, -2): (0, 1), (4, 32, 4, -1): (0, 1), (4, 32, 4, 0): (0, 1), (4, 32, 4, 1): (0, 1), (4, 32, 4, 2): (0, 1), (4, 32, 4, 3): (-1, 1), (4, 32, 4, 4): (-1, 1), (4, 32, 4, 5): (-1, 1), (4, 32, 5, -5): (0, 1), (4, 32, 5, -4): (0, 1), (4, 32, 5, -3): (0, 1), (4, 32, 5, -2): (0, 1), (4, 32, 5, -1): (0, 1), (4, 32, 5, 0): (0, 1), (4, 32, 5, 1): (0, 1), (4, 32, 5, 2): (0, 1), (4, 32, 5, 3): (-1, 1), (4, 32, 5, 4): (-1, 1), (4, 32, 5, 5): (-1, 1), (4, 33, -5, -5): (0, 1), (4, 33, -5, -4): (0, 1), (4, 33, -5, -3): (0, 1), (4, 33, -5, -2): (0, 1), (4, 33, -5, -1): (0, 1), (4, 33, -5, 0): (0, 1), (4, 33, -5, 1): (0, 1), (4, 33, -5, 2): (0, 0), (4, 33, -5, 3): (-1, -1), (4, 33, -5, 4): (0, 1), (4, 33, -5, 5): (0, 1), (4, 33, -4, -5): (0, 1), (4, 33, -4, -4): (0, 1), (4, 33, -4, -3): (0, 1), (4, 33, -4, -2): (0, 1), (4, 33, -4, -1): (0, 1), (4, 33, -4, 0): (0, 1), (4, 33, -4, 1): (0, 1), (4, 33, -4, 2): (0, 0), (4, 33, -4, 3): (-1, -1), (4, 33, -4, 4): (0, 1), (4, 33, -4, 5): (0, 1), (4, 33, -3, -5): (1, 1), (4, 33, -3, -4): (-1, 1), (4, 33, -3, -3): (0, 1), (4, 33, -3, -2): (0, 1), (4, 33, -3, -1): (0, 1), (4, 33, -3, 0): (0, 1), (4, 33, -3, 1): (0, 1), (4, 33, -3, 2): (0, 0), (4, 33, -3, 3): (-1, -1), (4, 33, -3, 4): (0, 1), (4, 33, -3, 5): (0, 1), (4, 33, -2, -5): (0, 1), (4, 33, -2, -4): (0, 1), (4, 33, -2, -3): (0, 1), (4, 33, -2, -2): (-1, 1), (4, 33, -2, -1): (-1, 1), (4, 33, -2, 0): (-1, 1), (4, 33, -2, 1): (-1, 1), (4, 33, -2, 2): (-1, 0), (4, 33, -2, 3): (-1, -1), (4, 33, -2, 4): (0, 1), (4, 33, -2, 5): (0, 1), (4, 33, -1, -5): (-1, 1), (4, 33, -1, -4): (-1, 1), (4, 33, -1, -3): (-1, 1), (4, 33, -1, -2): (0, 1), (4, 33, -1, -1): (-1, 1), (4, 33, -1, 0): (-1, 1), (4, 33, -1, 1): (-1, 0), (4, 33, -1, 2): (-1, -1), (4, 33, -1, 3): (-1, 1), (4, 33, -1, 4): (-1, 1), (4, 33, -1, 5): (-1, 1), (4, 33, 0, -5): (0, 1), (4, 33, 0, -4): (-1, 1), (4, 33, 0, -3): (-1, 1), (4, 33, 0, -2): (-1, 1), (4, 33, 0, -1): (-1, 1), (4, 33, 0, 0): (-1, 0), (4, 33, 0, 1): (-1, -1), (4, 33, 0, 2): (-1, -1), (4, 33, 0, 3): (-1, -1), (4, 33, 0, 4): (-1, 1), (4, 33, 0, 5): (-1, 1), (4, 33, 1, -5): (0, 1), (4, 33, 1, -4): (0, 1), (4, 33, 1, -3): (-1, 1), (4, 33, 1, -2): (-1, 1), (4, 33, 1, -1): (-1, 1), (4, 33, 1, 0): (-1, 1), (4, 33, 1, 1): (-1, 0), (4, 33, 1, 2): (-1, 1), (4, 33, 1, 3): (-1, 1), (4, 33, 1, 4): (-1, 1), (4, 33, 1, 5): (-1, 1), (4, 33, 2, -5): (-1, 1), (4, 33, 2, -4): (-1, 1), (4, 33, 2, -3): (-1, 1), (4, 33, 2, -2): (-1, 0), (4, 33, 2, -1): (-1, -1), (4, 33, 2, 0): (-1, 1), (4, 33, 2, 1): (-1, 1), (4, 33, 2, 2): (-1, 1), (4, 33, 2, 3): (-1, 1), (4, 33, 2, 4): (-1, 1), (4, 33, 2, 5): (-1, 1), (4, 33, 3, -5): (0, 1), (4, 33, 3, -4): (0, 1), (4, 33, 3, -3): (0, 1), (4, 33, 3, -2): (0, 0), (4, 33, 3, -1): (0, 1), (4, 33, 3, 0): (-1, 1), (4, 33, 3, 1): (-1, 1), (4, 33, 3, 2): (-1, 1), (4, 33, 3, 3): (-1, 1), (4, 33, 3, 4): (-1, 1), (4, 33, 3, 5): (-1, 1), (4, 33, 4, -5): (0, 1), (4, 33, 4, -4): (0, 1), (4, 33, 4, -3): (0, 1), (4, 33, 4, -2): (0, 0), (4, 33, 4, -1): (0, 1), (4, 33, 4, 0): (0, 1), (4, 33, 4, 1): (0, 1), (4, 33, 4, 2): (-1, 1), (4, 33, 4, 3): (-1, 1), (4, 33, 4, 4): (-1, 1), (4, 33, 4, 5): (-1, 1), (4, 33, 5, -5): (0, 1), (4, 33, 5, -4): (0, 1), (4, 33, 5, -3): (0, 1), (4, 33, 5, -2): (0, 0), (4, 33, 5, -1): (0, 1), (4, 33, 5, 0): (0, 1), (4, 33, 5, 1): (0, 1), (4, 33, 5, 2): (-1, 1), (4, 33, 5, 3): (-1, 1), (4, 33, 5, 4): (-1, 1), (4, 33, 5, 5): (-1, 1), (4, 34, -5, -5): (0, 1), (4, 34, -5, -4): (0, 1), (4, 34, -5, -3): (0, 1), (4, 34, -5, -2): (0, 1), (4, 34, -5, -1): (0, 1), (4, 34, -5, 0): (0, 1), (4, 34, -5, 1): (0, 0), (4, 34, -5, 2): (-1, -1), (4, 34, -5, 3): (0, 1), (4, 34, -5, 4): (0, 1), (4, 34, -5, 5): (0, 1), (4, 34, -4, -5): (0, 1), (4, 34, -4, -4): (0, 1), (4, 34, -4, -3): (0, 1), (4, 34, -4, -2): (0, 1), (4, 34, -4, -1): (0, 1), (4, 34, -4, 0): (0, 1), (4, 34, -4, 1): (0, 0), (4, 34, -4, 2): (-1, -1), (4, 34, -4, 3): (0, 1), (4, 34, -4, 4): (0, 1), (4, 34, -4, 5): (0, 1), (4, 34, -3, -5): (-1, 1), (4, 34, -3, -4): (0, 1), (4, 34, -3, -3): (0, 1), (4, 34, -3, -2): (0, 1), (4, 34, -3, -1): (0, 1), (4, 34, -3, 0): (0, 1), (4, 34, -3, 1): (0, 0), (4, 34, -3, 2): (-1, -1), (4, 34, -3, 3): (0, 1), (4, 34, -3, 4): (0, 1), (4, 34, -3, 5): (0, 1), (4, 34, -2, -5): (0, 1), (4, 34, -2, -4): (0, 1), (4, 34, -2, -3): (-1, 1), (4, 34, -2, -2): (-1, 1), (4, 34, -2, -1): (-1, 1), (4, 34, -2, 0): (-1, 1), (4, 34, -2, 1): (-1, 0), (4, 34, -2, 2): (-1, -1), (4, 34, -2, 3): (0, 1), (4, 34, -2, 4): (0, 1), (4, 34, -2, 5): (0, 1), (4, 34, -1, -5): (-1, 1), (4, 34, -1, -4): (-1, 1), (4, 34, -1, -3): (-1, 0), (4, 34, -1, -2): (-1, 1), (4, 34, -1, -1): (-1, 1), (4, 34, -1, 0): (-1, 0), (4, 34, -1, 1): (-1, -1), (4, 34, -1, 2): (-1, 1), (4, 34, -1, 3): (-1, 1), (4, 34, -1, 4): (-1, 1), (4, 34, -1, 5): (-1, 1), (4, 34, 0, -5): (-1, 1), (4, 34, 0, -4): (-1, 1), (4, 34, 0, -3): (-1, 1), (4, 34, 0, -2): (-1, 1), (4, 34, 0, -1): (-1, 1), (4, 34, 0, 0): (-1, 0), (4, 34, 0, 1): (-1, -1), (4, 34, 0, 2): (-1, -1), (4, 34, 0, 3): (-1, 1), (4, 34, 0, 4): (-1, 1), (4, 34, 0, 5): (-1, 1), (4, 34, 1, -5): (0, 1), (4, 34, 1, -4): (-1, 1), (4, 34, 1, -3): (-1, 0), (4, 34, 1, -2): (-1, 1), (4, 34, 1, -1): (-1, 1), (4, 34, 1, 0): (-1, 1), (4, 34, 1, 1): (-1, 1), (4, 34, 1, 2): (-1, 1), (4, 34, 1, 3): (-1, 1), (4, 34, 1, 4): (-1, 1), (4, 34, 1, 5): (-1, 1), (4, 34, 2, -5): (-1, 1), (4, 34, 2, -4): (-1, 1), (4, 34, 2, -3): (-1, 0), (4, 34, 2, -2): (-1, -1), (4, 34, 2, -1): (-1, 1), (4, 34, 2, 0): (-1, 1), (4, 34, 2, 1): (-1, 1), (4, 34, 2, 2): (-1, 1), (4, 34, 2, 3): (-1, 1), (4, 34, 2, 4): (-1, 1), (4, 34, 2, 5): (-1, 1), (4, 34, 3, -5): (0, 1), (4, 34, 3, -4): (0, 1), (4, 34, 3, -3): (0, 1), (4, 34, 3, -2): (0, 1), (4, 34, 3, -1): (0, 1), (4, 34, 3, 0): (-1, 1), (4, 34, 3, 1): (-1, 1), (4, 34, 3, 2): (-1, 1), (4, 34, 3, 3): (-1, 1), (4, 34, 3, 4): (-1, 1), (4, 34, 3, 5): (-1, 1), (4, 34, 4, -5): (0, 1), (4, 34, 4, -4): (0, 1), (4, 34, 4, -3): (0, 1), (4, 34, 4, -2): (0, 1), (4, 34, 4, -1): (0, 1), (4, 34, 4, 0): (0, 1), (4, 34, 4, 1): (-1, 1), (4, 34, 4, 2): (-1, 1), (4, 34, 4, 3): (-1, 1), (4, 34, 4, 4): (-1, 1), (4, 34, 4, 5): (-1, 1), (4, 34, 5, -5): (0, 1), (4, 34, 5, -4): (0, 1), (4, 34, 5, -3): (0, 1), (4, 34, 5, -2): (0, 1), (4, 34, 5, -1): (0, 1), (4, 34, 5, 0): (0, 1), (4, 34, 5, 1): (-1, 1), (4, 34, 5, 2): (-1, 1), (4, 34, 5, 3): (-1, 1), (4, 34, 5, 4): (-1, 1), (4, 34, 5, 5): (-1, 1), (4, 35, -5, -5): (0, 1), (4, 35, -5, -4): (0, 1), (4, 35, -5, -3): (0, 1), (4, 35, -5, -2): (0, 1), (4, 35, -5, -1): (0, 1), (4, 35, -5, 0): (0, 0), (4, 35, -5, 1): (-1, -1), (4, 35, -5, 2): (0, 1), (4, 35, -5, 3): (0, 1), (4, 35, -5, 4): (0, 1), (4, 35, -5, 5): (0, 1), (4, 35, -4, -5): (0, 1), (4, 35, -4, -4): (0, 1), (4, 35, -4, -3): (0, 1), (4, 35, -4, -2): (0, 1), (4, 35, -4, -1): (0, 1), (4, 35, -4, 0): (0, 0), (4, 35, -4, 1): (-1, -1), (4, 35, -4, 2): (0, 1), (4, 35, -4, 3): (0, 1), (4, 35, -4, 4): (0, 1), (4, 35, -4, 5): (0, 1), (4, 35, -3, -5): (0, 1), (4, 35, -3, -4): (0, 1), (4, 35, -3, -3): (0, 1), (4, 35, -3, -2): (0, 1), (4, 35, -3, -1): (0, 1), (4, 35, -3, 0): (0, 0), (4, 35, -3, 1): (-1, -1), (4, 35, -3, 2): (0, 1), (4, 35, -3, 3): (0, 1), (4, 35, -3, 4): (0, 1), (4, 35, -3, 5): (0, 1), (4, 35, -2, -5): (0, 1), (4, 35, -2, -4): (-1, 1), (4, 35, -2, -3): (-1, 1), (4, 35, -2, -2): (-1, 1), (4, 35, -2, -1): (-1, 1), (4, 35, -2, 0): (-1, 0), (4, 35, -2, 1): (-1, -1), (4, 35, -2, 2): (0, 1), (4, 35, -2, 3): (0, 1), (4, 35, -2, 4): (0, 1), (4, 35, -2, 5): (0, 1), (4, 35, -1, -5): (-1, 1), (4, 35, -1, -4): (-1, 0), (4, 35, -1, -3): (0, 1), (4, 35, -1, -2): (-1, 1), (4, 35, -1, -1): (-1, 1), (4, 35, -1, 0): (-1, 0), (4, 35, -1, 1): (-1, -1), (4, 35, -1, 2): (-1, 1), (4, 35, -1, 3): (-1, 1), (4, 35, -1, 4): (-1, 1), (4, 35, -1, 5): (-1, 1), (4, 35, 0, -5): (-1, 1), (4, 35, 0, -4): (-1, 1), (4, 35, 0, -3): (-1, 1), (4, 35, 0, -2): (-1, 1), (4, 35, 0, -1): (-1, 1), (4, 35, 0, 0): (-1, 0), (4, 35, 0, 1): (-1, -1), (4, 35, 0, 2): (-1, 1), (4, 35, 0, 3): (-1, 1), (4, 35, 0, 4): (-1, 1), (4, 35, 0, 5): (-1, 1), (4, 35, 1, -5): (-1, 1), (4, 35, 1, -4): (-1, 0), (4, 35, 1, -3): (-1, -1), (4, 35, 1, -2): (-1, 1), (4, 35, 1, -1): (-1, 1), (4, 35, 1, 0): (-1, 1), (4, 35, 1, 1): (-1, 1), (4, 35, 1, 2): (-1, 1), (4, 35, 1, 3): (-1, 1), (4, 35, 1, 4): (-1, 1), (4, 35, 1, 5): (-1, 1), (4, 35, 2, -5): (-1, 1), (4, 35, 2, -4): (-1, 0), (4, 35, 2, -3): (-1, -1), (4, 35, 2, -2): (-1, 1), (4, 35, 2, -1): (-1, 1), (4, 35, 2, 0): (-1, 1), (4, 35, 2, 1): (-1, 1), (4, 35, 2, 2): (-1, 1), (4, 35, 2, 3): (-1, 1), (4, 35, 2, 4): (-1, 1), (4, 35, 2, 5): (-1, 1), (4, 35, 3, -5): (0, 1), (4, 35, 3, -4): (0, 1), (4, 35, 3, -3): (0, 0), (4, 35, 3, -2): (0, 1), (4, 35, 3, -1): (-1, 1), (4, 35, 3, 0): (-1, 1), (4, 35, 3, 1): (-1, 1), (4, 35, 3, 2): (-1, 1), (4, 35, 3, 3): (-1, 1), (4, 35, 3, 4): (-1, 1), (4, 35, 3, 5): (-1, 1), (4, 35, 4, -5): (0, 1), (4, 35, 4, -4): (0, 1), (4, 35, 4, -3): (0, 0), (4, 35, 4, -2): (0, 1), (4, 35, 4, -1): (0, 1), (4, 35, 4, 0): (-1, 1), (4, 35, 4, 1): (-1, 1), (4, 35, 4, 2): (-1, 1), (4, 35, 4, 3): (-1, 1), (4, 35, 4, 4): (-1, 1), (4, 35, 4, 5): (-1, 1), (4, 35, 5, -5): (0, 1), (4, 35, 5, -4): (0, 1), (4, 35, 5, -3): (0, 0), (4, 35, 5, -2): (0, 1), (4, 35, 5, -1): (0, 1), (4, 35, 5, 0): (-1, 1), (4, 35, 5, 1): (-1, 1), (4, 35, 5, 2): (-1, 1), (4, 35, 5, 3): (-1, 1), (4, 35, 5, 4): (-1, 1), (4, 35, 5, 5): (-1, 1), (5, 32, -5, -5): (0, 1), (5, 32, -5, -4): (0, 1), (5, 32, -5, -3): (0, 1), (5, 32, -5, -2): (0, 1), (5, 32, -5, -1): (0, 1), (5, 32, -5, 0): (0, 1), (5, 32, -5, 1): (0, 1), (5, 32, -5, 2): (0, 1), (5, 32, -5, 3): (0, 0), (5, 32, -5, 4): (-1, -1), (5, 32, -5, 5): (0, 1), (5, 32, -4, -5): (-1, 1), (5, 32, -4, -4): (1, 1), (5, 32, -4, -3): (-1, 1), (5, 32, -4, -2): (0, 1), (5, 32, -4, -1): (0, 1), (5, 32, -4, 0): (0, 1), (5, 32, -4, 1): (0, 1), (5, 32, -4, 2): (0, 1), (5, 32, -4, 3): (0, 0), (5, 32, -4, 4): (-1, -1), (5, 32, -4, 5): (0, 1), (5, 32, -3, -5): (-1, 1), (5, 32, -3, -4): (0, 1), (5, 32, -3, -3): (0, 1), (5, 32, -3, -2): (0, 1), (5, 32, -3, -1): (-1, 1), (5, 32, -3, 0): (-1, 1), (5, 32, -3, 1): (-1, 1), (5, 32, -3, 2): (-1, 1), (5, 32, -3, 3): (-1, 0), (5, 32, -3, 4): (-1, -1), (5, 32, -3, 5): (0, 1), (5, 32, -2, -5): (0, 1), (5, 32, -2, -4): (-1, 1), (5, 32, -2, -3): (-1, 1), (5, 32, -2, -2): (-1, 1), (5, 32, -2, -1): (0, 1), (5, 32, -2, 0): (0, 1), (5, 32, -2, 1): (0, 0), (5, 32, -2, 2): (-1, -1), (5, 32, -2, 3): (-1, 1), (5, 32, -2, 4): (-1, 1), (5, 32, -2, 5): (-1, 1), (5, 32, -1, -5): (0, 1), (5, 32, -1, -4): (0, 1), (5, 32, -1, -3): (-1, 1), (5, 32, -1, -2): (-1, 1), (5, 32, -1, -1): (-1, 1), (5, 32, -1, 0): (-1, 1), (5, 32, -1, 1): (-1, 0), (5, 32, -1, 2): (-1, -1), (5, 32, -1, 3): (-1, -1), (5, 32, -1, 4): (-1, -1), (5, 32, -1, 5): (-1, 1), (5, 32, 0, -5): (0, 1), (5, 32, 0, -4): (0, 1), (5, 32, 0, -3): (0, 1), (5, 32, 0, -2): (-1, 1), (5, 32, 0, -1): (-1, 1), (5, 32, 0, 0): (-1, 0), (5, 32, 0, 1): (-1, -1), (5, 32, 0, 2): (-1, -1), (5, 32, 0, 3): (-1, 1), (5, 32, 0, 4): (-1, 1), (5, 32, 0, 5): (-1, 1), (5, 32, 1, -5): (-1, 1), (5, 32, 1, -4): (-1, 1), (5, 32, 1, -3): (-1, 1), (5, 32, 1, -2): (-1, 1), (5, 32, 1, -1): (-1, 1), (5, 32, 1, 0): (-1, 1), (5, 32, 1, 1): (-1, 0), (5, 32, 1, 2): (-1, -1), (5, 32, 1, 3): (-1, 1), (5, 32, 1, 4): (-1, 1), (5, 32, 1, 5): (-1, 1), (5, 32, 2, -5): (1, 1), (5, 32, 2, -4): (1, 1), (5, 32, 2, -3): (1, 1), (5, 32, 2, -2): (-1, 1), (5, 32, 2, -1): (-1, 1), (5, 32, 2, 0): (-1, 1), (5, 32, 2, 1): (-1, 1), (5, 32, 2, 2): (-1, 1), (5, 32, 2, 3): (-1, 1), (5, 32, 2, 4): (-1, 1), (5, 32, 2, 5): (-1, 1), (5, 32, 3, -5): (0, 1), (5, 32, 3, -4): (0, 1), (5, 32, 3, -3): (0, 1), (5, 32, 3, -2): (0, 1), (5, 32, 3, -1): (0, 1), (5, 32, 3, 0): (0, 1), (5, 32, 3, 1): (-1, 1), (5, 32, 3, 2): (-1, 1), (5, 32, 3, 3): (-1, 1), (5, 32, 3, 4): (-1, 1), (5, 32, 3, 5): (-1, 1), (5, 32, 4, -5): (1, 1), (5, 32, 4, -4): (1, 1), (5, 32, 4, -3): (1, 0), (5, 32, 4, -2): (1, -1), (5, 32, 4, -1): (1, 1), (5, 32, 4, 0): (1, 0), (5, 32, 4, 1): (1, 0), (5, 32, 4, 2): (1, 0), (5, 32, 4, 3): (-1, 1), (5, 32, 4, 4): (-1, 1), (5, 32, 4, 5): (-1, 1), (5, 32, 5, -5): (0, 1), (5, 32, 5, -4): (0, 1), (5, 32, 5, -3): (0, 0), (5, 32, 5, -2): (0, -1), (5, 32, 5, -1): (0, 1), (5, 32, 5, 0): (0, 1), (5, 32, 5, 1): (0, 1), (5, 32, 5, 2): (0, 1), (5, 32, 5, 3): (0, 1), (5, 32, 5, 4): (0, 1), (5, 32, 5, 5): (0, 1), (5, 33, -5, -5): (0, 1), (5, 33, -5, -4): (0, 1), (5, 33, -5, -3): (0, 1), (5, 33, -5, -2): (0, 1), (5, 33, -5, -1): (0, 1), (5, 33, -5, 0): (0, 1), (5, 33, -5, 1): (0, 1), (5, 33, -5, 2): (0, 0), (5, 33, -5, 3): (-1, -1), (5, 33, -5, 4): (0, 1), (5, 33, -5, 5): (0, 1), (5, 33, -4, -5): (1, 1), (5, 33, -4, -4): (-1, 1), (5, 33, -4, -3): (0, 1), (5, 33, -4, -2): (0, 1), (5, 33, -4, -1): (0, 1), (5, 33, -4, 0): (0, 1), (5, 33, -4, 1): (0, 1), (5, 33, -4, 2): (0, 0), (5, 33, -4, 3): (-1, -1), (5, 33, -4, 4): (0, 1), (5, 33, -4, 5): (0, 1), (5, 33, -3, -5): (0, 1), (5, 33, -3, -4): (0, 1), (5, 33, -3, -3): (0, 1), (5, 33, -3, -2): (-1, 1), (5, 33, -3, -1): (-1, 1), (5, 33, -3, 0): (-1, 1), (5, 33, -3, 1): (-1, 1), (5, 33, -3, 2): (-1, 0), (5, 33, -3, 3): (-1, -1), (5, 33, -3, 4): (0, 1), (5, 33, -3, 5): (0, 1), (5, 33, -2, -5): (-1, 1), (5, 33, -2, -4): (-1, 1), (5, 33, -2, -3): (-1, 1), (5, 33, -2, -2): (0, 1), (5, 33, -2, -1): (0, 1), (5, 33, -2, 0): (0, 1), (5, 33, -2, 1): (0, 0), (5, 33, -2, 2): (-1, -1), (5, 33, -2, 3): (-1, 1), (5, 33, -2, 4): (-1, 1), (5, 33, -2, 5): (-1, 1), (5, 33, -1, -5): (0, 1), (5, 33, -1, -4): (-1, 1), (5, 33, -1, -3): (-1, 1), (5, 33, -1, -2): (-1, 1), (5, 33, -1, -1): (-1, 1), (5, 33, -1, 0): (-1, 1), (5, 33, -1, 1): (-1, 0), (5, 33, -1, 2): (-1, -1), (5, 33, -1, 3): (-1, -1), (5, 33, -1, 4): (-1, 1), (5, 33, -1, 5): (-1, 1), (5, 33, 0, -5): (0, 1), (5, 33, 0, -4): (0, 1), (5, 33, 0, -3): (-1, 1), (5, 33, 0, -2): (-1, 1), (5, 33, 0, -1): (-1, 1), (5, 33, 0, 0): (-1, 0), (5, 33, 0, 1): (-1, -1), (5, 33, 0, 2): (-1, -1), (5, 33, 0, 3): (-1, 1), (5, 33, 0, 4): (-1, 1), (5, 33, 0, 5): (-1, 1), (5, 33, 1, -5): (-1, 1), (5, 33, 1, -4): (-1, 1), (5, 33, 1, -3): (-1, 1), (5, 33, 1, -2): (-1, 1), (5, 33, 1, -1): (-1, 1), (5, 33, 1, 0): (-1, 1), (5, 33, 1, 1): (-1, 0), (5, 33, 1, 2): (-1, 1), (5, 33, 1, 3): (-1, 1), (5, 33, 1, 4): (-1, 1), (5, 33, 1, 5): (-1, 1), (5, 33, 2, -5): (1, 1), (5, 33, 2, -4): (1, 1), (5, 33, 2, -3): (1, 1), (5, 33, 2, -2): (-1, 1), (5, 33, 2, -1): (-1, 1), (5, 33, 2, 0): (-1, 1), (5, 33, 2, 1): (-1, 1), (5, 33, 2, 2): (-1, 1), (5, 33, 2, 3): (-1, 1), (5, 33, 2, 4): (-1, 1), (5, 33, 2, 5): (-1, 1), (5, 33, 3, -5): (0, 1), (5, 33, 3, -4): (0, 1), (5, 33, 3, -3): (0, 1), (5, 33, 3, -2): (0, 0), (5, 33, 3, -1): (0, 1), (5, 33, 3, 0): (0, 1), (5, 33, 3, 1): (-1, 1), (5, 33, 3, 2): (-1, 1), (5, 33, 3, 3): (-1, 1), (5, 33, 3, 4): (-1, 1), (5, 33, 3, 5): (-1, 1), (5, 33, 4, -5): (1, 1), (5, 33, 4, -4): (1, 0), (5, 33, 4, -3): (1, -1), (5, 33, 4, -2): (1, 1), (5, 33, 4, -1): (1, 0), (5, 33, 4, 0): (1, 0), (5, 33, 4, 1): (1, 0), (5, 33, 4, 2): (-1, 1), (5, 33, 4, 3): (-1, 1), (5, 33, 4, 4): (-1, 1), (5, 33, 4, 5): (-1, 1), (5, 33, 5, -5): (0, 1), (5, 33, 5, -4): (0, 0), (5, 33, 5, -3): (0, -1), (5, 33, 5, -2): (0, 1), (5, 33, 5, -1): (0, 1), (5, 33, 5, 0): (0, 1), (5, 33, 5, 1): (0, 1), (5, 33, 5, 2): (0, 1), (5, 33, 5, 3): (0, 1), (5, 33, 5, 4): (0, 1), (5, 33, 5, 5): (0, 1), (5, 34, -5, -5): (0, 1), (5, 34, -5, -4): (0, 1), (5, 34, -5, -3): (0, 1), (5, 34, -5, -2): (0, 1), (5, 34, -5, -1): (0, 1), (5, 34, -5, 0): (0, 1), (5, 34, -5, 1): (0, 0), (5, 34, -5, 2): (-1, -1), (5, 34, -5, 3): (0, 1), (5, 34, -5, 4): (0, 1), (5, 34, -5, 5): (0, 1), (5, 34, -4, -5): (-1, 1), (5, 34, -4, -4): (0, 1), (5, 34, -4, -3): (0, 1), (5, 34, -4, -2): (0, 1), (5, 34, -4, -1): (0, 1), (5, 34, -4, 0): (0, 1), (5, 34, -4, 1): (0, 0), (5, 34, -4, 2): (-1, -1), (5, 34, -4, 3): (0, 1), (5, 34, -4, 4): (0, 1), (5, 34, -4, 5): (0, 1), (5, 34, -3, -5): (0, 1), (5, 34, -3, -4): (0, 1), (5, 34, -3, -3): (-1, 1), (5, 34, -3, -2): (-1, 1), (5, 34, -3, -1): (-1, 1), (5, 34, -3, 0): (-1, 1), (5, 34, -3, 1): (-1, 0), (5, 34, -3, 2): (-1, -1), (5, 34, -3, 3): (0, 1), (5, 34, -3, 4): (0, 1), (5, 34, -3, 5): (0, 1), (5, 34, -2, -5): (-1, 1), (5, 34, -2, -4): (-1, 1), (5, 34, -2, -3): (-1, 0), (5, 34, -2, -2): (0, 1), (5, 34, -2, -1): (0, 1), (5, 34, -2, 0): (0, 0), (5, 34, -2, 1): (-1, -1), (5, 34, -2, 2): (-1, 1), (5, 34, -2, 3): (-1, 1), (5, 34, -2, 4): (-1, 1), (5, 34, -2, 5): (-1, 1), (5, 34, -1, -5): (-1, 1), (5, 34, -1, -4): (-1, 1), (5, 34, -1, -3): (-1, 0), (5, 34, -1, -2): (-1, 1), (5, 34, -1, -1): (-1, 1), (5, 34, -1, 0): (-1, 0), (5, 34, -1, 1): (-1, -1), (5, 34, -1, 2): (-1, -1), (5, 34, -1, 3): (-1, 1), (5, 34, -1, 4): (-1, 1), (5, 34, -1, 5): (-1, 1), (5, 34, 0, -5): (0, 1), (5, 34, 0, -4): (-1, 1), (5, 34, 0, -3): (-1, 1), (5, 34, 0, -2): (-1, 1), (5, 34, 0, -1): (-1, 1), (5, 34, 0, 0): (-1, 0), (5, 34, 0, 1): (-1, -1), (5, 34, 0, 2): (-1, -1), (5, 34, 0, 3): (-1, 1), (5, 34, 0, 4): (-1, 1), (5, 34, 0, 5): (-1, 1), (5, 34, 1, -5): (-1, 1), (5, 34, 1, -4): (-1, 1), (5, 34, 1, -3): (-1, 0), (5, 34, 1, -2): (-1, 1), (5, 34, 1, -1): (-1, 1), (5, 34, 1, 0): (-1, 1), (5, 34, 1, 1): (-1, 1), (5, 34, 1, 2): (-1, 1), (5, 34, 1, 3): (-1, 1), (5, 34, 1, 4): (-1, 1), (5, 34, 1, 5): (-1, 1), (5, 34, 2, -5): (1, 1), (5, 34, 2, -4): (1, 1), (5, 34, 2, -3): (1, 1), (5, 34, 2, -2): (-1, 1), (5, 34, 2, -1): (-1, 1), (5, 34, 2, 0): (-1, 1), (5, 34, 2, 1): (-1, 1), (5, 34, 2, 2): (-1, 1), (5, 34, 2, 3): (-1, 1), (5, 34, 2, 4): (-1, 1), (5, 34, 2, 5): (-1, 1), (5, 34, 3, -5): (0, 1), (5, 34, 3, -4): (0, 1), (5, 34, 3, -3): (0, 1), (5, 34, 3, -2): (0, 1), (5, 34, 3, -1): (0, 1), (5, 34, 3, 0): (-1, 1), (5, 34, 3, 1): (-1, 1), (5, 34, 3, 2): (-1, 1), (5, 34, 3, 3): (-1, 1), (5, 34, 3, 4): (-1, 1), (5, 34, 3, 5): (-1, 1), (5, 34, 4, -5): (1, 0), (5, 34, 4, -4): (1, -1), (5, 34, 4, -3): (1, 1), (5, 34, 4, -2): (1, 0), (5, 34, 4, -1): (1, 0), (5, 34, 4, 0): (1, 0), (5, 34, 4, 1): (-1, 1), (5, 34, 4, 2): (-1, 1), (5, 34, 4, 3): (-1, 1), (5, 34, 4, 4): (-1, 1), (5, 34, 4, 5): (-1, 1), (5, 34, 5, -5): (0, 0), (5, 34, 5, -4): (0, -1), (5, 34, 5, -3): (0, 1), (5, 34, 5, -2): (0, 1), (5, 34, 5, -1): (0, 1), (5, 34, 5, 0): (0, 1), (5, 34, 5, 1): (0, 1), (5, 34, 5, 2): (0, 1), (5, 34, 5, 3): (0, 1), (5, 34, 5, 4): (0, 1), (5, 34, 5, 5): (0, 1), (5, 35, -5, -5): (0, 1), (5, 35, -5, -4): (0, 1), (5, 35, -5, -3): (0, 1), (5, 35, -5, -2): (0, 1), (5, 35, -5, -1): (0, 1), (5, 35, -5, 0): (0, 0), (5, 35, -5, 1): (-1, -1), (5, 35, -5, 2): (0, 1), (5, 35, -5, 3): (0, 1), (5, 35, -5, 4): (0, 1), (5, 35, -5, 5): (0, 1), (5, 35, -4, -5): (0, 1), (5, 35, -4, -4): (0, 1), (5, 35, -4, -3): (0, 1), (5, 35, -4, -2): (0, 1), (5, 35, -4, -1): (0, 1), (5, 35, -4, 0): (0, 0), (5, 35, -4, 1): (-1, -1), (5, 35, -4, 2): (0, 1), (5, 35, -4, 3): (0, 1), (5, 35, -4, 4): (0, 1), (5, 35, -4, 5): (0, 1), (5, 35, -3, -5): (0, 1), (5, 35, -3, -4): (-1, 1), (5, 35, -3, -3): (-1, 1), (5, 35, -3, -2): (-1, 1), (5, 35, -3, -1): (-1, 1), (5, 35, -3, 0): (-1, 0), (5, 35, -3, 1): (-1, -1), (5, 35, -3, 2): (0, 1), (5, 35, -3, 3): (0, 1), (5, 35, -3, 4): (0, 1), (5, 35, -3, 5): (0, 1), (5, 35, -2, -5): (-1, 1), (5, 35, -2, -4): (-1, 0), (5, 35, -2, -3): (0, 1), (5, 35, -2, -2): (0, 1), (5, 35, -2, -1): (0, 1), (5, 35, -2, 0): (0, 0), (5, 35, -2, 1): (-1, -1), (5, 35, -2, 2): (-1, 1), (5, 35, -2, 3): (-1, 1), (5, 35, -2, 4): (-1, 1), (5, 35, -2, 5): (-1, 1), (5, 35, -1, -5): (-1, 1), (5, 35, -1, -4): (-1, 0), (5, 35, -1, -3): (-1, 1), (5, 35, -1, -2): (-1, 1), (5, 35, -1, -1): (-1, 1), (5, 35, -1, 0): (-1, 0), (5, 35, -1, 1): (-1, -1), (5, 35, -1, 2): (-1, 1), (5, 35, -1, 3): (-1, 1), (5, 35, -1, 4): (-1, 1), (5, 35, -1, 5): (-1, 1), (5, 35, 0, -5): (-1, 1), (5, 35, 0, -4): (-1, 0), (5, 35, 0, -3): (-1, 1), (5, 35, 0, -2): (-1, 1), (5, 35, 0, -1): (-1, 1), (5, 35, 0, 0): (-1, 0), (5, 35, 0, 1): (-1, -1), (5, 35, 0, 2): (-1, 1), (5, 35, 0, 3): (-1, 1), (5, 35, 0, 4): (-1, 1), (5, 35, 0, 5): (-1, 1), (5, 35, 1, -5): (-1, 1), (5, 35, 1, -4): (-1, 0), (5, 35, 1, -3): (-1, -1), (5, 35, 1, -2): (-1, 1), (5, 35, 1, -1): (-1, 1), (5, 35, 1, 0): (-1, 1), (5, 35, 1, 1): (-1, 1), (5, 35, 1, 2): (-1, 1), (5, 35, 1, 3): (-1, 1), (5, 35, 1, 4): (-1, 1), (5, 35, 1, 5): (-1, 1), (5, 35, 2, -5): (1, 1), (5, 35, 2, -4): (1, 1), (5, 35, 2, -3): (-1, 1), (5, 35, 2, -2): (-1, 1), (5, 35, 2, -1): (-1, 1), (5, 35, 2, 0): (-1, 1), (5, 35, 2, 1): (-1, 1), (5, 35, 2, 2): (-1, 1), (5, 35, 2, 3): (-1, 1), (5, 35, 2, 4): (-1, 1), (5, 35, 2, 5): (-1, 1), (5, 35, 3, -5): (0, 1), (5, 35, 3, -4): (0, 1), (5, 35, 3, -3): (0, 0), (5, 35, 3, -2): (0, 1), (5, 35, 3, -1): (0, 1), (5, 35, 3, 0): (-1, 1), (5, 35, 3, 1): (-1, 1), (5, 35, 3, 2): (-1, 1), (5, 35, 3, 3): (-1, 1), (5, 35, 3, 4): (-1, 1), (5, 35, 3, 5): (-1, 1), (5, 35, 4, -5): (1, 0), (5, 35, 4, -4): (1, 1), (5, 35, 4, -3): (1, 0), (5, 35, 4, -2): (1, 0), (5, 35, 4, -1): (1, 0), (5, 35, 4, 0): (-1, 1), (5, 35, 4, 1): (-1, 1), (5, 35, 4, 2): (-1, 1), (5, 35, 4, 3): (-1, 1), (5, 35, 4, 4): (-1, 1), (5, 35, 4, 5): (-1, 1), (5, 35, 5, -5): (0, 0), (5, 35, 5, -4): (0, 1), (5, 35, 5, -3): (0, 1), (5, 35, 5, -2): (0, 1), (5, 35, 5, -1): (0, 1), (5, 35, 5, 0): (0, 1), (5, 35, 5, 1): (0, 1), (5, 35, 5, 2): (0, 1), (5, 35, 5, 3): (0, 1), (5, 35, 5, 4): (0, 1), (5, 35, 5, 5): (0, 1), (6, 1, -5, -5): (0, 1), (6, 1, -5, -4): (0, 1), (6, 1, -5, -3): (0, 1), (6, 1, -5, -2): (0, 1), (6, 1, -5, -1): (0, 0), (6, 1, -5, 0): (-1, -1), (6, 1, -5, 1): (0, 1), (6, 1, -5, 2): (0, 1), (6, 1, -5, 3): (0, 1), (6, 1, -5, 4): (0, 1), (6, 1, -5, 5): (0, 1), (6, 1, -4, -5): (-1, 1), (6, 1, -4, -4): (-1, 1), (6, 1, -4, -3): (-1, 1), (6, 1, -4, -2): (-1, 1), (6, 1, -4, -1): (-1, 0), (6, 1, -4, 0): (-1, -1), (6, 1, -4, 1): (0, 1), (6, 1, -4, 2): (0, 1), (6, 1, -4, 3): (0, 1), (6, 1, -4, 4): (0, 1), (6, 1, -4, 5): (0, 1), (6, 1, -3, -5): (-1, 1), (6, 1, -3, -4): (-1, 1), (6, 1, -3, -3): (-1, 1), (6, 1, -3, -2): (-1, 1), (6, 1, -3, -1): (-1, 0), (6, 1, -3, 0): (-1, -1), (6, 1, -3, 1): (0, 1), (6, 1, -3, 2): (0, 1), (6, 1, -3, 3): (0, 1), (6, 1, -3, 4): (0, 1), (6, 1, -3, 5): (0, 1), (6, 1, -2, -5): (-1, 1), (6, 1, -2, -4): (-1, 1), (6, 1, -2, -3): (-1, 1), (6, 1, -2, -2): (-1, 1), (6, 1, -2, -1): (-1, 0), (6, 1, -2, 0): (-1, -1), (6, 1, -2, 1): (0, 1), (6, 1, -2, 2): (0, 1), (6, 1, -2, 3): (0, 1), (6, 1, -2, 4): (0, 1), (6, 1, -2, 5): (0, 1), (6, 1, -1, -5): (-1, 1), (6, 1, -1, -4): (-1, 1), (6, 1, -1, -3): (-1, 1), (6, 1, -1, -2): (-1, 1), (6, 1, -1, -1): (-1, 0), (6, 1, -1, 0): (1, 1), (6, 1, -1, 1): (1, 1), (6, 1, -1, 2): (1, 1), (6, 1, -1, 3): (1, 1), (6, 1, -1, 4): (1, 1), (6, 1, -1, 5): (1, 0), (6, 1, 0, -5): (0, 1), (6, 1, 0, -4): (0, 1), (6, 1, 0, -3): (0, 1), (6, 1, 0, -2): (0, 1), (6, 1, 0, -1): (1, 1), (6, 1, 0, 0): (1, 1), (6, 1, 0, 1): (1, 1), (6, 1, 0, 2): (1, 1), (6, 1, 0, 3): (1, 1), (6, 1, 0, 4): (1, 1), (6, 1, 0, 5): (1, 0), (6, 1, 1, -5): (1, 0), (6, 1, 1, -4): (1, 0), (6, 1, 1, -3): (1, 0), (6, 1, 1, -2): (1, 0), (6, 1, 1, -1): (1, 1), (6, 1, 1, 0): (0, 1), (6, 1, 1, 1): (0, 1), (6, 1, 1, 2): (0, 1), (6, 1, 1, 3): (0, 1), (6, 1, 1, 4): (0, 1), (6, 1, 1, 5): (0, 1), (6, 1, 2, -5): (1, 0), (6, 1, 2, -4): (1, 0), (6, 1, 2, -3): (1, 0), (6, 1, 2, -2): (1, 0), (6, 1, 2, -1): (1, 0), (6, 1, 2, 0): (-1, 1), (6, 1, 2, 1): (-1, 1), (6, 1, 2, 2): (-1, 1), (6, 1, 2, 3): (-1, 1), (6, 1, 2, 4): (-1, 1), (6, 1, 2, 5): (-1, 1), (6, 1, 3, -5): (0, 1), (6, 1, 3, -4): (0, 1), (6, 1, 3, -3): (0, 1), (6, 1, 3, -2): (0, 1), (6, 1, 3, -1): (0, 0), (6, 1, 3, 0): (-1, 1), (6, 1, 3, 1): (-1, 1), (6, 1, 3, 2): (-1, 1), (6, 1, 3, 3): (-1, 1), (6, 1, 3, 4): (-1, 1), (6, 1, 3, 5): (-1, 1), (6, 1, 4, -5): (0, 1), (6, 1, 4, -4): (0, 1), (6, 1, 4, -3): (0, 1), (6, 1, 4, -2): (0, 1), (6, 1, 4, -1): (0, 1), (6, 1, 4, 0): (0, 1), (6, 1, 4, 1): (0, 1), (6, 1, 4, 2): (0, 1), (6, 1, 4, 3): (-1, 1), (6, 1, 4, 4): (-1, 1), (6, 1, 4, 5): (-1, 1), (6, 1, 5, -5): (0, 1), (6, 1, 5, -4): (0, 1), (6, 1, 5, -3): (0, 1), (6, 1, 5, -2): (0, 1), (6, 1, 5, -1): (0, 1), (6, 1, 5, 0): (0, 1), (6, 1, 5, 1): (0, 1), (6, 1, 5, 2): (0, 1), (6, 1, 5, 3): (0, 1), (6, 1, 5, 4): (0, 1), (6, 1, 5, 5): (0, 1), (6, 2, -5, -5): (0, 1), (6, 2, -5, -4): (0, 1), (6, 2, -5, -3): (0, 1), (6, 2, -5, -2): (0, 0), (6, 2, -5, -1): (-1, -1), (6, 2, -5, 0): (0, 1), (6, 2, -5, 1): (0, 1), (6, 2, -5, 2): (0, 1), (6, 2, -5, 3): (0, 1), (6, 2, -5, 4): (0, 1), (6, 2, -5, 5): (0, 1), (6, 2, -4, -5): (-1, 1), (6, 2, -4, -4): (-1, 1), (6, 2, -4, -3): (-1, 1), (6, 2, -4, -2): (-1, 0), (6, 2, -4, -1): (-1, -1), (6, 2, -4, 0): (0, 1), (6, 2, -4, 1): (0, 1), (6, 2, -4, 2): (0, 1), (6, 2, -4, 3): (0, 1), (6, 2, -4, 4): (0, 1), (6, 2, -4, 5): (0, 1), (6, 2, -3, -5): (-1, 1), (6, 2, -3, -4): (-1, 1), (6, 2, -3, -3): (-1, 1), (6, 2, -3, -2): (-1, 0), (6, 2, -3, -1): (-1, -1), (6, 2, -3, 0): (0, 1), (6, 2, -3, 1): (0, 1), (6, 2, -3, 2): (0, 1), (6, 2, -3, 3): (0, 1), (6, 2, -3, 4): (0, 1), (6, 2, -3, 5): (0, 1), (6, 2, -2, -5): (-1, 1), (6, 2, -2, -4): (-1, 1), (6, 2, -2, -3): (-1, 1), (6, 2, -2, -2): (-1, 0), (6, 2, -2, -1): (-1, -1), (6, 2, -2, 0): (0, 1), (6, 2, -2, 1): (0, 1), (6, 2, -2, 2): (0, 1), (6, 2, -2, 3): (0, 1), (6, 2, -2, 4): (0, 1), (6, 2, -2, 5): (0, 1), (6, 2, -1, -5): (-1, 1), (6, 2, -1, -4): (-1, 1), (6, 2, -1, -3): (-1, 1), (6, 2, -1, -2): (-1, 0), (6, 2, -1, -1): (0, 1), (6, 2, -1, 0): (1, 1), (6, 2, -1, 1): (1, 1), (6, 2, -1, 2): (1, 1), (6, 2, -1, 3): (1, 1), (6, 2, -1, 4): (1, 1), (6, 2, -1, 5): (1, 0), (6, 2, 0, -5): (0, 1), (6, 2, 0, -4): (0, 1), (6, 2, 0, -3): (0, 1), (6, 2, 0, -2): (-1, 1), (6, 2, 0, -1): (1, 1), (6, 2, 0, 0): (1, 1), (6, 2, 0, 1): (1, 1), (6, 2, 0, 2): (1, 1), (6, 2, 0, 3): (1, 1), (6, 2, 0, 4): (1, 1), (6, 2, 0, 5): (1, 0), (6, 2, 1, -5): (1, 0), (6, 2, 1, -4): (1, 0), (6, 2, 1, -3): (1, 0), (6, 2, 1, -2): (1, 0), (6, 2, 1, -1): (0, 1), (6, 2, 1, 0): (0, 1), (6, 2, 1, 1): (0, 1), (6, 2, 1, 2): (0, 1), (6, 2, 1, 3): (0, 1), (6, 2, 1, 4): (0, 1), (6, 2, 1, 5): (0, 1), (6, 2, 2, -5): (1, 0), (6, 2, 2, -4): (1, 0), (6, 2, 2, -3): (1, 0), (6, 2, 2, -2): (1, 0), (6, 2, 2, -1): (-1, 1), (6, 2, 2, 0): (-1, 1), (6, 2, 2, 1): (-1, 1), (6, 2, 2, 2): (-1, 1), (6, 2, 2, 3): (-1, 1), (6, 2, 2, 4): (-1, 1), (6, 2, 2, 5): (-1, 1), (6, 2, 3, -5): (0, 1), (6, 2, 3, -4): (0, 1), (6, 2, 3, -3): (0, 1), (6, 2, 3, -2): (0, 0), (6, 2, 3, -1): (1, 1), (6, 2, 3, 0): (-1, 1), (6, 2, 3, 1): (-1, 1), (6, 2, 3, 2): (-1, 1), (6, 2, 3, 3): (-1, 1), (6, 2, 3, 4): (-1, 1), (6, 2, 3, 5): (-1, 1), (6, 2, 4, -5): (0, 1), (6, 2, 4, -4): (0, 1), (6, 2, 4, -3): (0, 1), (6, 2, 4, -2): (0, 1), (6, 2, 4, -1): (0, 1), (6, 2, 4, 0): (0, 1), (6, 2, 4, 1): (0, 1), (6, 2, 4, 2): (0, 1), (6, 2, 4, 3): (-1, 1), (6, 2, 4, 4): (-1, 1), (6, 2, 4, 5): (-1, 1), (6, 2, 5, -5): (0, 1), (6, 2, 5, -4): (0, 1), (6, 2, 5, -3): (0, 1), (6, 2, 5, -2): (0, 1), (6, 2, 5, -1): (0, 1), (6, 2, 5, 0): (0, 1), (6, 2, 5, 1): (0, 1), (6, 2, 5, 2): (0, 1), (6, 2, 5, 3): (0, 1), (6, 2, 5, 4): (0, 1), (6, 2, 5, 5): (0, 1), (6, 3, -5, -5): (0, 1), (6, 3, -5, -4): (0, 1), (6, 3, -5, -3): (0, 0), (6, 3, -5, -2): (-1, -1), (6, 3, -5, -1): (0, 1), (6, 3, -5, 0): (0, 1), (6, 3, -5, 1): (0, 1), (6, 3, -5, 2): (0, 1), (6, 3, -5, 3): (0, 1), (6, 3, -5, 4): (0, 1), (6, 3, -5, 5): (0, 1), (6, 3, -4, -5): (-1, 1), (6, 3, -4, -4): (-1, 1), (6, 3, -4, -3): (-1, 0), (6, 3, -4, -2): (-1, -1), (6, 3, -4, -1): (0, 1), (6, 3, -4, 0): (0, 1), (6, 3, -4, 1): (0, 1), (6, 3, -4, 2): (0, 1), (6, 3, -4, 3): (0, 1), (6, 3, -4, 4): (0, 1), (6, 3, -4, 5): (0, 1), (6, 3, -3, -5): (-1, 1), (6, 3, -3, -4): (-1, 1), (6, 3, -3, -3): (-1, 0), (6, 3, -3, -2): (-1, -1), (6, 3, -3, -1): (0, 1), (6, 3, -3, 0): (0, 1), (6, 3, -3, 1): (0, 1), (6, 3, -3, 2): (0, 1), (6, 3, -3, 3): (0, 1), (6, 3, -3, 4): (0, 1), (6, 3, -3, 5): (0, 1), (6, 3, -2, -5): (-1, 1), (6, 3, -2, -4): (-1, 1), (6, 3, -2, -3): (-1, 0), (6, 3, -2, -2): (-1, -1), (6, 3, -2, -1): (0, 1), (6, 3, -2, 0): (0, 1), (6, 3, -2, 1): (0, 1), (6, 3, -2, 2): (0, 1), (6, 3, -2, 3): (0, 1), (6, 3, -2, 4): (0, 1), (6, 3, -2, 5): (0, 1), (6, 3, -1, -5): (-1, 1), (6, 3, -1, -4): (-1, 1), (6, 3, -1, -3): (-1, 0), (6, 3, -1, -2): (0, 1), (6, 3, -1, -1): (0, 1), (6, 3, -1, 0): (1, 1), (6, 3, -1, 1): (1, 1), (6, 3, -1, 2): (1, 1), (6, 3, -1, 3): (1, 1), (6, 3, -1, 4): (1, 1), (6, 3, -1, 5): (1, 0), (6, 3, 0, -5): (0, 1), (6, 3, 0, -4): (0, 1), (6, 3, 0, -3): (-1, 1), (6, 3, 0, -2): (-1, 1), (6, 3, 0, -1): (1, 1), (6, 3, 0, 0): (1, 1), (6, 3, 0, 1): (1, 1), (6, 3, 0, 2): (1, 1), (6, 3, 0, 3): (1, 1), (6, 3, 0, 4): (1, 1), (6, 3, 0, 5): (1, 0), (6, 3, 1, -5): (1, 0), (6, 3, 1, -4): (1, 0), (6, 3, 1, -3): (1, 0), (6, 3, 1, -2): (1, -1), (6, 3, 1, -1): (1, 1), (6, 3, 1, 0): (0, 1), (6, 3, 1, 1): (0, 1), (6, 3, 1, 2): (0, 1), (6, 3, 1, 3): (0, 1), (6, 3, 1, 4): (0, 1), (6, 3, 1, 5): (0, 1), (6, 3, 2, -5): (1, 0), (6, 3, 2, -4): (1, 0), (6, 3, 2, -3): (1, 0), (6, 3, 2, -2): (1, -1), (6, 3, 2, -1): (0, 1), (6, 3, 2, 0): (-1, 1), (6, 3, 2, 1): (-1, 1), (6, 3, 2, 2): (-1, 1), (6, 3, 2, 3): (-1, 1), (6, 3, 2, 4): (-1, 1), (6, 3, 2, 5): (-1, 1), (6, 3, 3, -5): (0, 1), (6, 3, 3, -4): (0, 1), (6, 3, 3, -3): (0, 0), (6, 3, 3, -2): (1, 1), (6, 3, 3, -1): (1, 1), (6, 3, 3, 0): (-1, 1), (6, 3, 3, 1): (-1, 1), (6, 3, 3, 2): (-1, 1), (6, 3, 3, 3): (-1, 1), (6, 3, 3, 4): (-1, 1), (6, 3, 3, 5): (-1, 1), (6, 3, 4, -5): (0, 1), (6, 3, 4, -4): (0, 1), (6, 3, 4, -3): (0, 1), (6, 3, 4, -2): (0, 1), (6, 3, 4, -1): (0, 1), (6, 3, 4, 0): (0, 1), (6, 3, 4, 1): (0, 1), (6, 3, 4, 2): (0, 1), (6, 3, 4, 3): (-1, 1), (6, 3, 4, 4): (-1, 1), (6, 3, 4, 5): (-1, 1), (6, 3, 5, -5): (0, 1), (6, 3, 5, -4): (0, 1), (6, 3, 5, -3): (0, 1), (6, 3, 5, -2): (0, 1), (6, 3, 5, -1): (0, 1), (6, 3, 5, 0): (0, 1), (6, 3, 5, 1): (0, 1), (6, 3, 5, 2): (0, 1), (6, 3, 5, 3): (0, 1), (6, 3, 5, 4): (0, 1), (6, 3, 5, 5): (0, 1), (6, 4, -5, -5): (0, 1), (6, 4, -5, -4): (0, 0), (6, 4, -5, -3): (-1, -1), (6, 4, -5, -2): (0, 1), (6, 4, -5, -1): (0, 1), (6, 4, -5, 0): (0, 1), (6, 4, -5, 1): (0, 1), (6, 4, -5, 2): (0, 1), (6, 4, -5, 3): (0, 1), (6, 4, -5, 4): (0, 1), (6, 4, -5, 5): (0, 1), (6, 4, -4, -5): (-1, 1), (6, 4, -4, -4): (-1, 0), (6, 4, -4, -3): (-1, -1), (6, 4, -4, -2): (0, 1), (6, 4, -4, -1): (0, 1), (6, 4, -4, 0): (0, 1), (6, 4, -4, 1): (0, 1), (6, 4, -4, 2): (0, 1), (6, 4, -4, 3): (0, 1), (6, 4, -4, 4): (0, 1), (6, 4, -4, 5): (0, 1), (6, 4, -3, -5): (-1, 1), (6, 4, -3, -4): (-1, 0), (6, 4, -3, -3): (-1, -1), (6, 4, -3, -2): (0, 1), (6, 4, -3, -1): (0, 1), (6, 4, -3, 0): (0, 1), (6, 4, -3, 1): (0, 1), (6, 4, -3, 2): (0, 1), (6, 4, -3, 3): (0, 1), (6, 4, -3, 4): (0, 1), (6, 4, -3, 5): (0, 1), (6, 4, -2, -5): (-1, 1), (6, 4, -2, -4): (-1, 0), (6, 4, -2, -3): (-1, -1), (6, 4, -2, -2): (0, 1), (6, 4, -2, -1): (0, 1), (6, 4, -2, 0): (0, 1), (6, 4, -2, 1): (0, 1), (6, 4, -2, 2): (0, 1), (6, 4, -2, 3): (0, 1), (6, 4, -2, 4): (0, 1), (6, 4, -2, 5): (0, 1), (6, 4, -1, -5): (-1, 1), (6, 4, -1, -4): (-1, 0), (6, 4, -1, -3): (0, 1), (6, 4, -1, -2): (0, 1), (6, 4, -1, -1): (0, 1), (6, 4, -1, 0): (1, 1), (6, 4, -1, 1): (1, 1), (6, 4, -1, 2): (1, 1), (6, 4, -1, 3): (1, 1), (6, 4, -1, 4): (1, 1), (6, 4, -1, 5): (1, 0), (6, 4, 0, -5): (0, 1), (6, 4, 0, -4): (-1, 1), (6, 4, 0, -3): (-1, 1), (6, 4, 0, -2): (-1, 1), (6, 4, 0, -1): (1, 1), (6, 4, 0, 0): (1, 1), (6, 4, 0, 1): (1, 1), (6, 4, 0, 2): (1, 1), (6, 4, 0, 3): (1, 1), (6, 4, 0, 4): (1, 1), (6, 4, 0, 5): (1, 0), (6, 4, 1, -5): (1, 0), (6, 4, 1, -4): (1, 0), (6, 4, 1, -3): (1, -1), (6, 4, 1, -2): (1, 1), (6, 4, 1, -1): (0, 1), (6, 4, 1, 0): (0, 1), (6, 4, 1, 1): (0, 1), (6, 4, 1, 2): (0, 1), (6, 4, 1, 3): (0, 1), (6, 4, 1, 4): (0, 1), (6, 4, 1, 5): (0, 1), (6, 4, 2, -5): (1, 0), (6, 4, 2, -4): (1, 0), (6, 4, 2, -3): (1, -1), (6, 4, 2, -2): (0, 1), (6, 4, 2, -1): (-1, 1), (6, 4, 2, 0): (-1, 1), (6, 4, 2, 1): (-1, 1), (6, 4, 2, 2): (-1, 1), (6, 4, 2, 3): (-1, 1), (6, 4, 2, 4): (-1, 1), (6, 4, 2, 5): (-1, 1), (6, 4, 3, -5): (0, 1), (6, 4, 3, -4): (0, 0), (6, 4, 3, -3): (1, 1), (6, 4, 3, -2): (1, 1), (6, 4, 3, -1): (1, 1), (6, 4, 3, 0): (-1, 1), (6, 4, 3, 1): (-1, 1), (6, 4, 3, 2): (-1, 1), (6, 4, 3, 3): (-1, 1), (6, 4, 3, 4): (-1, 1), (6, 4, 3, 5): (-1, 1), (6, 4, 4, -5): (0, 1), (6, 4, 4, -4): (0, 1), (6, 4, 4, -3): (0, 1), (6, 4, 4, -2): (0, 1), (6, 4, 4, -1): (0, 1), (6, 4, 4, 0): (0, 1), (6, 4, 4, 1): (0, 1), (6, 4, 4, 2): (0, 1), (6, 4, 4, 3): (-1, 1), (6, 4, 4, 4): (-1, 1), (6, 4, 4, 5): (-1, 1), (6, 4, 5, -5): (0, 1), (6, 4, 5, -4): (0, 1), (6, 4, 5, -3): (0, 1), (6, 4, 5, -2): (0, 1), (6, 4, 5, -1): (0, 1), (6, 4, 5, 0): (0, 1), (6, 4, 5, 1): (0, 1), (6, 4, 5, 2): (0, 1), (6, 4, 5, 3): (0, 1), (6, 4, 5, 4): (0, 1), (6, 4, 5, 5): (0, 1), (6, 5, -5, -5): (0, 0), (6, 5, -5, -4): (-1, -1), (6, 5, -5, -3): (0, 1), (6, 5, -5, -2): (0, 1), (6, 5, -5, -1): (0, 1), (6, 5, -5, 0): (0, 1), (6, 5, -5, 1): (0, 1), (6, 5, -5, 2): (0, 1), (6, 5, -5, 3): (0, 1), (6, 5, -5, 4): (0, 1), (6, 5, -5, 5): (0, 1), (6, 5, -4, -5): (-1, 0), (6, 5, -4, -4): (-1, -1), (6, 5, -4, -3): (0, 1), (6, 5, -4, -2): (0, 1), (6, 5, -4, -1): (0, 1), (6, 5, -4, 0): (0, 1), (6, 5, -4, 1): (0, 1), (6, 5, -4, 2): (0, 1), (6, 5, -4, 3): (0, 1), (6, 5, -4, 4): (0, 1), (6, 5, -4, 5): (0, 1), (6, 5, -3, -5): (-1, 0), (6, 5, -3, -4): (-1, -1), (6, 5, -3, -3): (0, 1), (6, 5, -3, -2): (0, 1), (6, 5, -3, -1): (0, 1), (6, 5, -3, 0): (0, 1), (6, 5, -3, 1): (0, 1), (6, 5, -3, 2): (0, 1), (6, 5, -3, 3): (0, 1), (6, 5, -3, 4): (0, 1), (6, 5, -3, 5): (0, 1), (6, 5, -2, -5): (-1, 0), (6, 5, -2, -4): (-1, -1), (6, 5, -2, -3): (0, 1), (6, 5, -2, -2): (0, 1), (6, 5, -2, -1): (0, 1), (6, 5, -2, 0): (0, 1), (6, 5, -2, 1): (0, 1), (6, 5, -2, 2): (0, 1), (6, 5, -2, 3): (0, 1), (6, 5, -2, 4): (0, 1), (6, 5, -2, 5): (0, 1), (6, 5, -1, -5): (-1, 0), (6, 5, -1, -4): (0, 1), (6, 5, -1, -3): (0, 1), (6, 5, -1, -2): (0, 1), (6, 5, -1, -1): (0, 1), (6, 5, -1, 0): (1, 1), (6, 5, -1, 1): (1, 1), (6, 5, -1, 2): (1, 1), (6, 5, -1, 3): (1, 1), (6, 5, -1, 4): (1, 1), (6, 5, -1, 5): (1, 0), (6, 5, 0, -5): (-1, 1), (6, 5, 0, -4): (-1, 1), (6, 5, 0, -3): (-1, 1), (6, 5, 0, -2): (-1, 1), (6, 5, 0, -1): (1, 1), (6, 5, 0, 0): (1, 1), (6, 5, 0, 1): (1, 1), (6, 5, 0, 2): (1, 1), (6, 5, 0, 3): (1, 1), (6, 5, 0, 4): (1, 1), (6, 5, 0, 5): (1, 0), (6, 5, 1, -5): (1, 0), (6, 5, 1, -4): (1, -1), (6, 5, 1, -3): (1, 1), (6, 5, 1, -2): (1, 1), (6, 5, 1, -1): (1, 1), (6, 5, 1, 0): (0, 1), (6, 5, 1, 1): (0, 1), (6, 5, 1, 2): (0, 1), (6, 5, 1, 3): (0, 1), (6, 5, 1, 4): (0, 1), (6, 5, 1, 5): (0, 1), (6, 5, 2, -5): (1, 0), (6, 5, 2, -4): (1, -1), (6, 5, 2, -3): (0, 1), (6, 5, 2, -2): (0, 1), (6, 5, 2, -1): (0, 1), (6, 5, 2, 0): (-1, 1), (6, 5, 2, 1): (-1, 1), (6, 5, 2, 2): (-1, 1), (6, 5, 2, 3): (-1, 1), (6, 5, 2, 4): (-1, 1), (6, 5, 2, 5): (-1, 1), (6, 5, 3, -5): (0, 0), (6, 5, 3, -4): (1, 1), (6, 5, 3, -3): (1, 1), (6, 5, 3, -2): (1, 1), (6, 5, 3, -1): (1, 1), (6, 5, 3, 0): (-1, 1), (6, 5, 3, 1): (-1, 1), (6, 5, 3, 2): (-1, 1), (6, 5, 3, 3): (-1, 1), (6, 5, 3, 4): (-1, 1), (6, 5, 3, 5): (-1, 1), (6, 5, 4, -5): (0, 1), (6, 5, 4, -4): (0, 1), (6, 5, 4, -3): (0, 1), (6, 5, 4, -2): (0, 1), (6, 5, 4, -1): (0, 1), (6, 5, 4, 0): (0, 1), (6, 5, 4, 1): (0, 1), (6, 5, 4, 2): (0, 1), (6, 5, 4, 3): (-1, 1), (6, 5, 4, 4): (0, 1), (6, 5, 4, 5): (0, 1), (6, 5, 5, -5): (0, 1), (6, 5, 5, -4): (0, 1), (6, 5, 5, -3): (0, 1), (6, 5, 5, -2): (0, 1), (6, 5, 5, -1): (0, 1), (6, 5, 5, 0): (0, 1), (6, 5, 5, 1): (0, 1), (6, 5, 5, 2): (0, 1), (6, 5, 5, 3): (0, 1), (6, 5, 5, 4): (0, 1), (6, 5, 5, 5): (0, 1), (6, 6, -5, -5): (0, 1), (6, 6, -5, -4): (0, 1), (6, 6, -5, -3): (0, 1), (6, 6, -5, -2): (0, 1), (6, 6, -5, -1): (0, 1), (6, 6, -5, 0): (0, 1), (6, 6, -5, 1): (0, 1), (6, 6, -5, 2): (0, 1), (6, 6, -5, 3): (0, 1), (6, 6, -5, 4): (0, 1), (6, 6, -5, 5): (0, 1), (6, 6, -4, -5): (0, 1), (6, 6, -4, -4): (0, 1), (6, 6, -4, -3): (0, 1), (6, 6, -4, -2): (0, 1), (6, 6, -4, -1): (0, 1), (6, 6, -4, 0): (0, 1), (6, 6, -4, 1): (0, 1), (6, 6, -4, 2): (0, 1), (6, 6, -4, 3): (0, 1), (6, 6, -4, 4): (0, 1), (6, 6, -4, 5): (0, 1), (6, 6, -3, -5): (0, 1), (6, 6, -3, -4): (0, 1), (6, 6, -3, -3): (0, 1), (6, 6, -3, -2): (0, 1), (6, 6, -3, -1): (0, 1), (6, 6, -3, 0): (0, 1), (6, 6, -3, 1): (0, 1), (6, 6, -3, 2): (0, 1), (6, 6, -3, 3): (0, 1), (6, 6, -3, 4): (0, 1), (6, 6, -3, 5): (0, 1), (6, 6, -2, -5): (0, 1), (6, 6, -2, -4): (0, 1), (6, 6, -2, -3): (0, 1), (6, 6, -2, -2): (0, 1), (6, 6, -2, -1): (0, 1), (6, 6, -2, 0): (0, 1), (6, 6, -2, 1): (0, 1), (6, 6, -2, 2): (0, 1), (6, 6, -2, 3): (0, 1), (6, 6, -2, 4): (0, 1), (6, 6, -2, 5): (0, 1), (6, 6, -1, -5): (0, 1), (6, 6, -1, -4): (0, 1), (6, 6, -1, -3): (0, 1), (6, 6, -1, -2): (0, 1), (6, 6, -1, -1): (0, 1), (6, 6, -1, 0): (1, 1), (6, 6, -1, 1): (1, 1), (6, 6, -1, 2): (1, 1), (6, 6, -1, 3): (1, 1), (6, 6, -1, 4): (1, 1), (6, 6, -1, 5): (1, 0), (6, 6, 0, -5): (-1, 1), (6, 6, 0, -4): (-1, 1), (6, 6, 0, -3): (-1, 1), (6, 6, 0, -2): (-1, 1), (6, 6, 0, -1): (1, 1), (6, 6, 0, 0): (1, 1), (6, 6, 0, 1): (1, 1), (6, 6, 0, 2): (1, 1), (6, 6, 0, 3): (1, 1), (6, 6, 0, 4): (1, 1), (6, 6, 0, 5): (1, 0), (6, 6, 1, -5): (1, 0), (6, 6, 1, -4): (1, 0), (6, 6, 1, -3): (1, 1), (6, 6, 1, -2): (1, 1), (6, 6, 1, -1): (1, 1), (6, 6, 1, 0): (0, 1), (6, 6, 1, 1): (0, 1), (6, 6, 1, 2): (0, 1), (6, 6, 1, 3): (0, 1), (6, 6, 1, 4): (0, 1), (6, 6, 1, 5): (0, 1), (6, 6, 2, -5): (0, 1), (6, 6, 2, -4): (0, 1), (6, 6, 2, -3): (0, 1), (6, 6, 2, -2): (0, 1), (6, 6, 2, -1): (0, 1), (6, 6, 2, 0): (-1, 1), (6, 6, 2, 1): (-1, 1), (6, 6, 2, 2): (-1, 1), (6, 6, 2, 3): (-1, 1), (6, 6, 2, 4): (-1, 1), (6, 6, 2, 5): (-1, 1), (6, 6, 3, -5): (1, 1), (6, 6, 3, -4): (1, 1), (6, 6, 3, -3): (1, 1), (6, 6, 3, -2): (1, 1), (6, 6, 3, -1): (1, 1), (6, 6, 3, 0): (-1, 1), (6, 6, 3, 1): (-1, 1), (6, 6, 3, 2): (-1, 1), (6, 6, 3, 3): (-1, 1), (6, 6, 3, 4): (-1, 1), (6, 6, 3, 5): (-1, 1), (6, 6, 4, -5): (0, 1), (6, 6, 4, -4): (0, 1), (6, 6, 4, -3): (0, 1), (6, 6, 4, -2): (0, 1), (6, 6, 4, -1): (0, 1), (6, 6, 4, 0): (0, 1), (6, 6, 4, 1): (0, 1), (6, 6, 4, 2): (0, 1), (6, 6, 4, 3): (0, 1), (6, 6, 4, 4): (-1, 1), (6, 6, 4, 5): (-1, 1), (6, 6, 5, -5): (0, 1), (6, 6, 5, -4): (0, 1), (6, 6, 5, -3): (0, 1), (6, 6, 5, -2): (0, 1), (6, 6, 5, -1): (0, 1), (6, 6, 5, 0): (0, 1), (6, 6, 5, 1): (0, 1), (6, 6, 5, 2): (0, 1), (6, 6, 5, 3): (0, 1), (6, 6, 5, 4): (0, 1), (6, 6, 5, 5): (0, 1), (6, 7, -5, -5): (0, 1), (6, 7, -5, -4): (0, 1), (6, 7, -5, -3): (0, 1), (6, 7, -5, -2): (0, 1), (6, 7, -5, -1): (0, 1), (6, 7, -5, 0): (0, 1), (6, 7, -5, 1): (0, 1), (6, 7, -5, 2): (0, 1), (6, 7, -5, 3): (0, 1), (6, 7, -5, 4): (0, 1), (6, 7, -5, 5): (0, 1), (6, 7, -4, -5): (0, 1), (6, 7, -4, -4): (0, 1), (6, 7, -4, -3): (0, 1), (6, 7, -4, -2): (0, 1), (6, 7, -4, -1): (0, 1), (6, 7, -4, 0): (0, 1), (6, 7, -4, 1): (0, 1), (6, 7, -4, 2): (0, 1), (6, 7, -4, 3): (0, 1), (6, 7, -4, 4): (0, 1), (6, 7, -4, 5): (0, 1), (6, 7, -3, -5): (0, 1), (6, 7, -3, -4): (0, 1), (6, 7, -3, -3): (0, 1), (6, 7, -3, -2): (0, 1), (6, 7, -3, -1): (0, 1), (6, 7, -3, 0): (0, 1), (6, 7, -3, 1): (0, 1), (6, 7, -3, 2): (0, 1), (6, 7, -3, 3): (0, 1), (6, 7, -3, 4): (0, 1), (6, 7, -3, 5): (0, 1), (6, 7, -2, -5): (0, 1), (6, 7, -2, -4): (0, 1), (6, 7, -2, -3): (0, 1), (6, 7, -2, -2): (0, 1), (6, 7, -2, -1): (0, 1), (6, 7, -2, 0): (0, 1), (6, 7, -2, 1): (0, 1), (6, 7, -2, 2): (0, 1), (6, 7, -2, 3): (0, 1), (6, 7, -2, 4): (0, 1), (6, 7, -2, 5): (0, 1), (6, 7, -1, -5): (0, 1), (6, 7, -1, -4): (0, 1), (6, 7, -1, -3): (0, 1), (6, 7, -1, -2): (0, 1), (6, 7, -1, -1): (0, 1), (6, 7, -1, 0): (1, 1), (6, 7, -1, 1): (1, 1), (6, 7, -1, 2): (1, 1), (6, 7, -1, 3): (1, 1), (6, 7, -1, 4): (1, 1), (6, 7, -1, 5): (1, 0), (6, 7, 0, -5): (-1, 1), (6, 7, 0, -4): (-1, 1), (6, 7, 0, -3): (-1, 1), (6, 7, 0, -2): (-1, 1), (6, 7, 0, -1): (1, 1), (6, 7, 0, 0): (1, 1), (6, 7, 0, 1): (1, 1), (6, 7, 0, 2): (1, 1), (6, 7, 0, 3): (1, 1), (6, 7, 0, 4): (1, 1), (6, 7, 0, 5): (1, 0), (6, 7, 1, -5): (1, 0), (6, 7, 1, -4): (1, 1), (6, 7, 1, -3): (1, 1), (6, 7, 1, -2): (1, 1), (6, 7, 1, -1): (1, 1), (6, 7, 1, 0): (0, 1), (6, 7, 1, 1): (0, 1), (6, 7, 1, 2): (0, 1), (6, 7, 1, 3): (0, 1), (6, 7, 1, 4): (0, 1), (6, 7, 1, 5): (0, 1), (6, 7, 2, -5): (0, 1), (6, 7, 2, -4): (0, 1), (6, 7, 2, -3): (0, 1), (6, 7, 2, -2): (0, 1), (6, 7, 2, -1): (0, 1), (6, 7, 2, 0): (-1, 1), (6, 7, 2, 1): (-1, 1), (6, 7, 2, 2): (-1, 1), (6, 7, 2, 3): (-1, 1), (6, 7, 2, 4): (-1, 1), (6, 7, 2, 5): (-1, 1), (6, 7, 3, -5): (1, 1), (6, 7, 3, -4): (1, 1), (6, 7, 3, -3): (1, 1), (6, 7, 3, -2): (1, 1), (6, 7, 3, -1): (1, 1), (6, 7, 3, 0): (-1, 1), (6, 7, 3, 1): (-1, 1), (6, 7, 3, 2): (-1, 1), (6, 7, 3, 3): (-1, 1), (6, 7, 3, 4): (-1, 1), (6, 7, 3, 5): (-1, 1), (6, 7, 4, -5): (0, 1), (6, 7, 4, -4): (0, 1), (6, 7, 4, -3): (0, 1), (6, 7, 4, -2): (0, 1), (6, 7, 4, -1): (0, 1), (6, 7, 4, 0): (0, 1), (6, 7, 4, 1): (0, 1), (6, 7, 4, 2): (0, 1), (6, 7, 4, 3): (0, 1), (6, 7, 4, 4): (-1, 1), (6, 7, 4, 5): (-1, 1), (6, 7, 5, -5): (0, 1), (6, 7, 5, -4): (0, 1), (6, 7, 5, -3): (0, 1), (6, 7, 5, -2): (0, 1), (6, 7, 5, -1): (0, 1), (6, 7, 5, 0): (0, 1), (6, 7, 5, 1): (0, 1), (6, 7, 5, 2): (0, 1), (6, 7, 5, 3): (0, 1), (6, 7, 5, 4): (0, 1), (6, 7, 5, 5): (0, 1), (6, 8, -5, -5): (0, 1), (6, 8, -5, -4): (0, 1), (6, 8, -5, -3): (0, 1), (6, 8, -5, -2): (0, 1), (6, 8, -5, -1): (0, 1), (6, 8, -5, 0): (0, 1), (6, 8, -5, 1): (0, 1), (6, 8, -5, 2): (0, 1), (6, 8, -5, 3): (0, 1), (6, 8, -5, 4): (0, 1), (6, 8, -5, 5): (0, 1), (6, 8, -4, -5): (0, 1), (6, 8, -4, -4): (0, 1), (6, 8, -4, -3): (0, 1), (6, 8, -4, -2): (0, 1), (6, 8, -4, -1): (0, 1), (6, 8, -4, 0): (0, 1), (6, 8, -4, 1): (0, 1), (6, 8, -4, 2): (0, 1), (6, 8, -4, 3): (0, 1), (6, 8, -4, 4): (0, 1), (6, 8, -4, 5): (0, 1), (6, 8, -3, -5): (0, 1), (6, 8, -3, -4): (0, 1), (6, 8, -3, -3): (0, 1), (6, 8, -3, -2): (0, 1), (6, 8, -3, -1): (0, 1), (6, 8, -3, 0): (0, 1), (6, 8, -3, 1): (0, 1), (6, 8, -3, 2): (0, 1), (6, 8, -3, 3): (0, 1), (6, 8, -3, 4): (0, 1), (6, 8, -3, 5): (0, 1), (6, 8, -2, -5): (0, 1), (6, 8, -2, -4): (0, 1), (6, 8, -2, -3): (0, 1), (6, 8, -2, -2): (0, 1), (6, 8, -2, -1): (0, 1), (6, 8, -2, 0): (0, 1), (6, 8, -2, 1): (0, 1), (6, 8, -2, 2): (0, 1), (6, 8, -2, 3): (0, 1), (6, 8, -2, 4): (0, 1), (6, 8, -2, 5): (0, 1), (6, 8, -1, -5): (0, 1), (6, 8, -1, -4): (0, 1), (6, 8, -1, -3): (0, 1), (6, 8, -1, -2): (0, 1), (6, 8, -1, -1): (0, 1), (6, 8, -1, 0): (1, 1), (6, 8, -1, 1): (1, 1), (6, 8, -1, 2): (1, 1), (6, 8, -1, 3): (1, 1), (6, 8, -1, 4): (1, 1), (6, 8, -1, 5): (1, 0), (6, 8, 0, -5): (-1, 1), (6, 8, 0, -4): (-1, 1), (6, 8, 0, -3): (-1, 1), (6, 8, 0, -2): (-1, 1), (6, 8, 0, -1): (1, 1), (6, 8, 0, 0): (1, 1), (6, 8, 0, 1): (1, 1), (6, 8, 0, 2): (1, 1), (6, 8, 0, 3): (1, 1), (6, 8, 0, 4): (1, 1), (6, 8, 0, 5): (1, 0), (6, 8, 1, -5): (1, 0), (6, 8, 1, -4): (1, 1), (6, 8, 1, -3): (1, 1), (6, 8, 1, -2): (1, 1), (6, 8, 1, -1): (0, 1), (6, 8, 1, 0): (0, 1), (6, 8, 1, 1): (0, 1), (6, 8, 1, 2): (0, 1), (6, 8, 1, 3): (0, 1), (6, 8, 1, 4): (0, 1), (6, 8, 1, 5): (0, 1), (6, 8, 2, -5): (0, 1), (6, 8, 2, -4): (0, 1), (6, 8, 2, -3): (0, 1), (6, 8, 2, -2): (0, 1), (6, 8, 2, -1): (-1, 1), (6, 8, 2, 0): (-1, 1), (6, 8, 2, 1): (-1, 1), (6, 8, 2, 2): (-1, 1), (6, 8, 2, 3): (-1, 1), (6, 8, 2, 4): (-1, 1), (6, 8, 2, 5): (-1, 1), (6, 8, 3, -5): (1, 1), (6, 8, 3, -4): (1, 1), (6, 8, 3, -3): (1, 1), (6, 8, 3, -2): (1, 1), (6, 8, 3, -1): (1, 1), (6, 8, 3, 0): (-1, 1), (6, 8, 3, 1): (-1, 1), (6, 8, 3, 2): (-1, 1), (6, 8, 3, 3): (-1, 1), (6, 8, 3, 4): (-1, 1), (6, 8, 3, 5): (-1, 1), (6, 8, 4, -5): (0, 1), (6, 8, 4, -4): (0, 1), (6, 8, 4, -3): (0, 1), (6, 8, 4, -2): (0, 1), (6, 8, 4, -1): (0, 1), (6, 8, 4, 0): (0, 1), (6, 8, 4, 1): (0, 1), (6, 8, 4, 2): (0, 1), (6, 8, 4, 3): (-1, 1), (6, 8, 4, 4): (-1, 1), (6, 8, 4, 5): (-1, 1), (6, 8, 5, -5): (0, 1), (6, 8, 5, -4): (0, 1), (6, 8, 5, -3): (0, 1), (6, 8, 5, -2): (0, 1), (6, 8, 5, -1): (0, 1), (6, 8, 5, 0): (0, 1), (6, 8, 5, 1): (0, 1), (6, 8, 5, 2): (0, 1), (6, 8, 5, 3): (0, 1), (6, 8, 5, 4): (0, 1), (6, 8, 5, 5): (0, 1), (6, 9, -5, -5): (0, 1), (6, 9, -5, -4): (0, 1), (6, 9, -5, -3): (0, 1), (6, 9, -5, -2): (0, 1), (6, 9, -5, -1): (0, 1), (6, 9, -5, 0): (0, 1), (6, 9, -5, 1): (0, 1), (6, 9, -5, 2): (0, 1), (6, 9, -5, 3): (0, 1), (6, 9, -5, 4): (0, 1), (6, 9, -5, 5): (0, 1), (6, 9, -4, -5): (0, 1), (6, 9, -4, -4): (0, 1), (6, 9, -4, -3): (0, 1), (6, 9, -4, -2): (0, 1), (6, 9, -4, -1): (0, 1), (6, 9, -4, 0): (0, 1), (6, 9, -4, 1): (0, 1), (6, 9, -4, 2): (0, 1), (6, 9, -4, 3): (0, 1), (6, 9, -4, 4): (0, 1), (6, 9, -4, 5): (0, 1), (6, 9, -3, -5): (0, 1), (6, 9, -3, -4): (0, 1), (6, 9, -3, -3): (0, 1), (6, 9, -3, -2): (0, 1), (6, 9, -3, -1): (0, 1), (6, 9, -3, 0): (0, 1), (6, 9, -3, 1): (0, 1), (6, 9, -3, 2): (0, 1), (6, 9, -3, 3): (0, 1), (6, 9, -3, 4): (0, 1), (6, 9, -3, 5): (0, 1), (6, 9, -2, -5): (0, 1), (6, 9, -2, -4): (0, 1), (6, 9, -2, -3): (0, 1), (6, 9, -2, -2): (0, 1), (6, 9, -2, -1): (0, 1), (6, 9, -2, 0): (0, 1), (6, 9, -2, 1): (0, 1), (6, 9, -2, 2): (0, 1), (6, 9, -2, 3): (0, 1), (6, 9, -2, 4): (0, 1), (6, 9, -2, 5): (0, 1), (6, 9, -1, -5): (0, 1), (6, 9, -1, -4): (0, 1), (6, 9, -1, -3): (0, 1), (6, 9, -1, -2): (0, 1), (6, 9, -1, -1): (0, 1), (6, 9, -1, 0): (1, 1), (6, 9, -1, 1): (1, 1), (6, 9, -1, 2): (1, 1), (6, 9, -1, 3): (1, 1), (6, 9, -1, 4): (1, 1), (6, 9, -1, 5): (1, 0), (6, 9, 0, -5): (-1, 1), (6, 9, 0, -4): (-1, 1), (6, 9, 0, -3): (-1, 1), (6, 9, 0, -2): (-1, 1), (6, 9, 0, -1): (1, 1), (6, 9, 0, 0): (1, 1), (6, 9, 0, 1): (1, 1), (6, 9, 0, 2): (1, 1), (6, 9, 0, 3): (1, 1), (6, 9, 0, 4): (1, 1), (6, 9, 0, 5): (1, 0), (6, 9, 1, -5): (1, 1), (6, 9, 1, -4): (1, 1), (6, 9, 1, -3): (1, 1), (6, 9, 1, -2): (1, 1), (6, 9, 1, -1): (1, 1), (6, 9, 1, 0): (0, 1), (6, 9, 1, 1): (0, 1), (6, 9, 1, 2): (0, 1), (6, 9, 1, 3): (0, 1), (6, 9, 1, 4): (0, 1), (6, 9, 1, 5): (0, 1), (6, 9, 2, -5): (0, 1), (6, 9, 2, -4): (0, 1), (6, 9, 2, -3): (0, 1), (6, 9, 2, -2): (0, 1), (6, 9, 2, -1): (0, 1), (6, 9, 2, 0): (-1, 1), (6, 9, 2, 1): (-1, 1), (6, 9, 2, 2): (-1, 1), (6, 9, 2, 3): (-1, 1), (6, 9, 2, 4): (-1, 1), (6, 9, 2, 5): (-1, 1), (6, 9, 3, -5): (1, 1), (6, 9, 3, -4): (1, 1), (6, 9, 3, -3): (1, 1), (6, 9, 3, -2): (1, 1), (6, 9, 3, -1): (1, 1), (6, 9, 3, 0): (-1, 1), (6, 9, 3, 1): (-1, 1), (6, 9, 3, 2): (-1, 1), (6, 9, 3, 3): (-1, 1), (6, 9, 3, 4): (-1, 1), (6, 9, 3, 5): (-1, 1), (6, 9, 4, -5): (0, 1), (6, 9, 4, -4): (0, 1), (6, 9, 4, -3): (0, 1), (6, 9, 4, -2): (0, 1), (6, 9, 4, -1): (0, 1), (6, 9, 4, 0): (0, 1), (6, 9, 4, 1): (0, 1), (6, 9, 4, 2): (0, 1), (6, 9, 4, 3): (-1, 1), (6, 9, 4, 4): (-1, 1), (6, 9, 4, 5): (-1, 1), (6, 9, 5, -5): (0, 1), (6, 9, 5, -4): (0, 1), (6, 9, 5, -3): (0, 1), (6, 9, 5, -2): (0, 1), (6, 9, 5, -1): (0, 1), (6, 9, 5, 0): (0, 1), (6, 9, 5, 1): (0, 1), (6, 9, 5, 2): (0, 1), (6, 9, 5, 3): (0, 1), (6, 9, 5, 4): (0, 1), (6, 9, 5, 5): (0, 1), (6, 10, -5, -5): (0, 1), (6, 10, -5, -4): (0, 1), (6, 10, -5, -3): (0, 1), (6, 10, -5, -2): (0, 1), (6, 10, -5, -1): (0, 1), (6, 10, -5, 0): (0, 1), (6, 10, -5, 1): (0, 1), (6, 10, -5, 2): (0, 1), (6, 10, -5, 3): (0, 1), (6, 10, -5, 4): (0, 1), (6, 10, -5, 5): (0, 1), (6, 10, -4, -5): (0, 1), (6, 10, -4, -4): (0, 1), (6, 10, -4, -3): (0, 1), (6, 10, -4, -2): (0, 1), (6, 10, -4, -1): (0, 1), (6, 10, -4, 0): (0, 1), (6, 10, -4, 1): (0, 1), (6, 10, -4, 2): (0, 1), (6, 10, -4, 3): (0, 1), (6, 10, -4, 4): (0, 1), (6, 10, -4, 5): (0, 1), (6, 10, -3, -5): (0, 1), (6, 10, -3, -4): (0, 1), (6, 10, -3, -3): (0, 1), (6, 10, -3, -2): (0, 1), (6, 10, -3, -1): (0, 1), (6, 10, -3, 0): (0, 1), (6, 10, -3, 1): (0, 1), (6, 10, -3, 2): (0, 1), (6, 10, -3, 3): (0, 1), (6, 10, -3, 4): (0, 1), (6, 10, -3, 5): (0, 1), (6, 10, -2, -5): (0, 1), (6, 10, -2, -4): (0, 1), (6, 10, -2, -3): (0, 1), (6, 10, -2, -2): (0, 1), (6, 10, -2, -1): (0, 1), (6, 10, -2, 0): (0, 1), (6, 10, -2, 1): (0, 1), (6, 10, -2, 2): (0, 1), (6, 10, -2, 3): (0, 1), (6, 10, -2, 4): (0, 1), (6, 10, -2, 5): (0, 1), (6, 10, -1, -5): (0, 1), (6, 10, -1, -4): (0, 1), (6, 10, -1, -3): (0, 1), (6, 10, -1, -2): (0, 1), (6, 10, -1, -1): (0, 1), (6, 10, -1, 0): (1, 1), (6, 10, -1, 1): (1, 1), (6, 10, -1, 2): (1, 1), (6, 10, -1, 3): (1, 1), (6, 10, -1, 4): (1, 1), (6, 10, -1, 5): (1, 0), (6, 10, 0, -5): (-1, 1), (6, 10, 0, -4): (-1, 1), (6, 10, 0, -3): (-1, 1), (6, 10, 0, -2): (-1, 1), (6, 10, 0, -1): (1, 1), (6, 10, 0, 0): (1, 1), (6, 10, 0, 1): (1, 1), (6, 10, 0, 2): (1, 1), (6, 10, 0, 3): (1, 1), (6, 10, 0, 4): (1, 1), (6, 10, 0, 5): (1, 0), (6, 10, 1, -5): (1, 1), (6, 10, 1, -4): (1, 1), (6, 10, 1, -3): (1, 1), (6, 10, 1, -2): (1, 1), (6, 10, 1, -1): (1, 1), (6, 10, 1, 0): (0, 1), (6, 10, 1, 1): (0, 1), (6, 10, 1, 2): (0, 1), (6, 10, 1, 3): (0, 1), (6, 10, 1, 4): (0, 1), (6, 10, 1, 5): (0, 1), (6, 10, 2, -5): (0, 1), (6, 10, 2, -4): (0, 1), (6, 10, 2, -3): (0, 1), (6, 10, 2, -2): (0, 1), (6, 10, 2, -1): (0, 1), (6, 10, 2, 0): (-1, 1), (6, 10, 2, 1): (-1, 1), (6, 10, 2, 2): (-1, 1), (6, 10, 2, 3): (-1, 1), (6, 10, 2, 4): (-1, 1), (6, 10, 2, 5): (-1, 1), (6, 10, 3, -5): (1, 1), (6, 10, 3, -4): (1, 1), (6, 10, 3, -3): (1, 1), (6, 10, 3, -2): (1, 1), (6, 10, 3, -1): (1, 1), (6, 10, 3, 0): (-1, 1), (6, 10, 3, 1): (-1, 1), (6, 10, 3, 2): (-1, 1), (6, 10, 3, 3): (-1, 1), (6, 10, 3, 4): (-1, 1), (6, 10, 3, 5): (-1, 1), (6, 10, 4, -5): (0, 1), (6, 10, 4, -4): (0, 1), (6, 10, 4, -3): (0, 1), (6, 10, 4, -2): (0, 1), (6, 10, 4, -1): (0, 1), (6, 10, 4, 0): (0, 1), (6, 10, 4, 1): (0, 1), (6, 10, 4, 2): (0, 1), (6, 10, 4, 3): (-1, 1), (6, 10, 4, 4): (-1, 1), (6, 10, 4, 5): (-1, 1), (6, 10, 5, -5): (0, 1), (6, 10, 5, -4): (0, 1), (6, 10, 5, -3): (0, 1), (6, 10, 5, -2): (0, 1), (6, 10, 5, -1): (0, 1), (6, 10, 5, 0): (0, 1), (6, 10, 5, 1): (0, 1), (6, 10, 5, 2): (0, 1), (6, 10, 5, 3): (0, 1), (6, 10, 5, 4): (0, 1), (6, 10, 5, 5): (0, 1), (6, 11, -5, -5): (0, 1), (6, 11, -5, -4): (0, 1), (6, 11, -5, -3): (0, 1), (6, 11, -5, -2): (0, 1), (6, 11, -5, -1): (0, 1), (6, 11, -5, 0): (0, 1), (6, 11, -5, 1): (0, 1), (6, 11, -5, 2): (0, 1), (6, 11, -5, 3): (0, 1), (6, 11, -5, 4): (0, 1), (6, 11, -5, 5): (0, 1), (6, 11, -4, -5): (0, 1), (6, 11, -4, -4): (0, 1), (6, 11, -4, -3): (0, 1), (6, 11, -4, -2): (0, 1), (6, 11, -4, -1): (0, 1), (6, 11, -4, 0): (0, 1), (6, 11, -4, 1): (0, 1), (6, 11, -4, 2): (0, 1), (6, 11, -4, 3): (0, 1), (6, 11, -4, 4): (0, 1), (6, 11, -4, 5): (0, 1), (6, 11, -3, -5): (0, 1), (6, 11, -3, -4): (0, 1), (6, 11, -3, -3): (0, 1), (6, 11, -3, -2): (0, 1), (6, 11, -3, -1): (0, 1), (6, 11, -3, 0): (0, 1), (6, 11, -3, 1): (0, 1), (6, 11, -3, 2): (0, 1), (6, 11, -3, 3): (0, 1), (6, 11, -3, 4): (0, 1), (6, 11, -3, 5): (0, 1), (6, 11, -2, -5): (0, 1), (6, 11, -2, -4): (0, 1), (6, 11, -2, -3): (0, 1), (6, 11, -2, -2): (0, 1), (6, 11, -2, -1): (0, 1), (6, 11, -2, 0): (0, 1), (6, 11, -2, 1): (0, 1), (6, 11, -2, 2): (0, 1), (6, 11, -2, 3): (0, 1), (6, 11, -2, 4): (0, 1), (6, 11, -2, 5): (0, 1), (6, 11, -1, -5): (0, 1), (6, 11, -1, -4): (0, 1), (6, 11, -1, -3): (0, 1), (6, 11, -1, -2): (0, 1), (6, 11, -1, -1): (0, 1), (6, 11, -1, 0): (1, 1), (6, 11, -1, 1): (1, 1), (6, 11, -1, 2): (1, 1), (6, 11, -1, 3): (1, 1), (6, 11, -1, 4): (1, 1), (6, 11, -1, 5): (1, 0), (6, 11, 0, -5): (-1, 1), (6, 11, 0, -4): (-1, 1), (6, 11, 0, -3): (-1, 1), (6, 11, 0, -2): (-1, 1), (6, 11, 0, -1): (1, 1), (6, 11, 0, 0): (0, 1), (6, 11, 0, 1): (1, 1), (6, 11, 0, 2): (1, 1), (6, 11, 0, 3): (1, 1), (6, 11, 0, 4): (1, 1), (6, 11, 0, 5): (1, 0), (6, 11, 1, -5): (1, 1), (6, 11, 1, -4): (1, 1), (6, 11, 1, -3): (1, 1), (6, 11, 1, -2): (1, 1), (6, 11, 1, -1): (1, 1), (6, 11, 1, 0): (-1, 1), (6, 11, 1, 1): (0, 1), (6, 11, 1, 2): (0, 1), (6, 11, 1, 3): (0, 1), (6, 11, 1, 4): (0, 1), (6, 11, 1, 5): (0, 1), (6, 11, 2, -5): (0, 1), (6, 11, 2, -4): (0, 1), (6, 11, 2, -3): (0, 1), (6, 11, 2, -2): (0, 1), (6, 11, 2, -1): (0, 1), (6, 11, 2, 0): (-1, 1), (6, 11, 2, 1): (-1, 1), (6, 11, 2, 2): (-1, 1), (6, 11, 2, 3): (-1, 1), (6, 11, 2, 4): (-1, 1), (6, 11, 2, 5): (-1, 1), (6, 11, 3, -5): (1, 1), (6, 11, 3, -4): (1, 1), (6, 11, 3, -3): (1, 1), (6, 11, 3, -2): (1, 1), (6, 11, 3, -1): (1, 1), (6, 11, 3, 0): (-1, 1), (6, 11, 3, 1): (-1, 1), (6, 11, 3, 2): (-1, 1), (6, 11, 3, 3): (-1, 1), (6, 11, 3, 4): (-1, 1), (6, 11, 3, 5): (-1, 1), (6, 11, 4, -5): (0, 1), (6, 11, 4, -4): (0, 1), (6, 11, 4, -3): (0, 1), (6, 11, 4, -2): (0, 1), (6, 11, 4, -1): (0, 1), (6, 11, 4, 0): (0, 1), (6, 11, 4, 1): (0, 1), (6, 11, 4, 2): (-1, 1), (6, 11, 4, 3): (-1, 1), (6, 11, 4, 4): (-1, 1), (6, 11, 4, 5): (-1, 1), (6, 11, 5, -5): (0, 1), (6, 11, 5, -4): (0, 1), (6, 11, 5, -3): (0, 1), (6, 11, 5, -2): (0, 1), (6, 11, 5, -1): (0, 1), (6, 11, 5, 0): (0, 1), (6, 11, 5, 1): (0, 1), (6, 11, 5, 2): (0, 1), (6, 11, 5, 3): (0, 1), (6, 11, 5, 4): (0, 1), (6, 11, 5, 5): (0, 1), (6, 12, -5, -5): (0, 1), (6, 12, -5, -4): (0, 1), (6, 12, -5, -3): (0, 1), (6, 12, -5, -2): (0, 1), (6, 12, -5, -1): (0, 1), (6, 12, -5, 0): (0, 1), (6, 12, -5, 1): (0, 1), (6, 12, -5, 2): (0, 1), (6, 12, -5, 3): (0, 1), (6, 12, -5, 4): (0, 1), (6, 12, -5, 5): (0, 1), (6, 12, -4, -5): (0, 1), (6, 12, -4, -4): (0, 1), (6, 12, -4, -3): (0, 1), (6, 12, -4, -2): (0, 1), (6, 12, -4, -1): (0, 1), (6, 12, -4, 0): (0, 1), (6, 12, -4, 1): (0, 1), (6, 12, -4, 2): (0, 1), (6, 12, -4, 3): (0, 1), (6, 12, -4, 4): (0, 1), (6, 12, -4, 5): (0, 1), (6, 12, -3, -5): (0, 1), (6, 12, -3, -4): (0, 1), (6, 12, -3, -3): (0, 1), (6, 12, -3, -2): (0, 1), (6, 12, -3, -1): (0, 1), (6, 12, -3, 0): (0, 1), (6, 12, -3, 1): (0, 1), (6, 12, -3, 2): (0, 1), (6, 12, -3, 3): (0, 1), (6, 12, -3, 4): (0, 1), (6, 12, -3, 5): (0, 1), (6, 12, -2, -5): (0, 1), (6, 12, -2, -4): (0, 1), (6, 12, -2, -3): (0, 1), (6, 12, -2, -2): (0, 1), (6, 12, -2, -1): (0, 1), (6, 12, -2, 0): (0, 1), (6, 12, -2, 1): (0, 1), (6, 12, -2, 2): (0, 1), (6, 12, -2, 3): (0, 1), (6, 12, -2, 4): (0, 1), (6, 12, -2, 5): (0, 1), (6, 12, -1, -5): (0, 1), (6, 12, -1, -4): (0, 1), (6, 12, -1, -3): (0, 1), (6, 12, -1, -2): (0, 1), (6, 12, -1, -1): (0, 1), (6, 12, -1, 0): (1, 1), (6, 12, -1, 1): (1, 1), (6, 12, -1, 2): (1, 1), (6, 12, -1, 3): (1, 1), (6, 12, -1, 4): (1, 1), (6, 12, -1, 5): (1, 0), (6, 12, 0, -5): (-1, 1), (6, 12, 0, -4): (-1, 1), (6, 12, 0, -3): (-1, 1), (6, 12, 0, -2): (-1, 1), (6, 12, 0, -1): (1, 1), (6, 12, 0, 0): (1, 1), (6, 12, 0, 1): (1, 1), (6, 12, 0, 2): (1, 1), (6, 12, 0, 3): (1, 1), (6, 12, 0, 4): (1, 1), (6, 12, 0, 5): (1, 0), (6, 12, 1, -5): (1, 1), (6, 12, 1, -4): (1, 1), (6, 12, 1, -3): (1, 1), (6, 12, 1, -2): (1, 1), (6, 12, 1, -1): (1, 1), (6, 12, 1, 0): (0, 1), (6, 12, 1, 1): (0, 1), (6, 12, 1, 2): (0, 1), (6, 12, 1, 3): (0, 1), (6, 12, 1, 4): (0, 1), (6, 12, 1, 5): (0, 1), (6, 12, 2, -5): (0, 1), (6, 12, 2, -4): (0, 1), (6, 12, 2, -3): (0, 1), (6, 12, 2, -2): (0, 1), (6, 12, 2, -1): (0, 1), (6, 12, 2, 0): (-1, 1), (6, 12, 2, 1): (-1, 1), (6, 12, 2, 2): (-1, 1), (6, 12, 2, 3): (-1, 1), (6, 12, 2, 4): (-1, 1), (6, 12, 2, 5): (-1, 1), (6, 12, 3, -5): (1, 1), (6, 12, 3, -4): (1, 1), (6, 12, 3, -3): (1, 1), (6, 12, 3, -2): (1, 1), (6, 12, 3, -1): (1, 1), (6, 12, 3, 0): (-1, 1), (6, 12, 3, 1): (-1, 1), (6, 12, 3, 2): (-1, 1), (6, 12, 3, 3): (-1, 1), (6, 12, 3, 4): (-1, 1), (6, 12, 3, 5): (-1, 1), (6, 12, 4, -5): (0, 1), (6, 12, 4, -4): (0, 1), (6, 12, 4, -3): (0, 1), (6, 12, 4, -2): (0, 1), (6, 12, 4, -1): (0, 1), (6, 12, 4, 0): (0, 1), (6, 12, 4, 1): (0, 1), (6, 12, 4, 2): (-1, 1), (6, 12, 4, 3): (-1, 1), (6, 12, 4, 4): (-1, 1), (6, 12, 4, 5): (-1, 1), (6, 12, 5, -5): (0, 1), (6, 12, 5, -4): (0, 1), (6, 12, 5, -3): (0, 1), (6, 12, 5, -2): (0, 1), (6, 12, 5, -1): (0, 1), (6, 12, 5, 0): (0, 1), (6, 12, 5, 1): (0, 1), (6, 12, 5, 2): (0, 1), (6, 12, 5, 3): (0, 1), (6, 12, 5, 4): (0, 1), (6, 12, 5, 5): (0, 1), (6, 13, -5, -5): (0, 1), (6, 13, -5, -4): (0, 1), (6, 13, -5, -3): (0, 1), (6, 13, -5, -2): (0, 1), (6, 13, -5, -1): (0, 1), (6, 13, -5, 0): (0, 1), (6, 13, -5, 1): (0, 1), (6, 13, -5, 2): (0, 1), (6, 13, -5, 3): (0, 1), (6, 13, -5, 4): (0, 1), (6, 13, -5, 5): (0, 1), (6, 13, -4, -5): (0, 1), (6, 13, -4, -4): (0, 1), (6, 13, -4, -3): (0, 1), (6, 13, -4, -2): (0, 1), (6, 13, -4, -1): (0, 1), (6, 13, -4, 0): (0, 1), (6, 13, -4, 1): (0, 1), (6, 13, -4, 2): (0, 1), (6, 13, -4, 3): (0, 1), (6, 13, -4, 4): (0, 1), (6, 13, -4, 5): (0, 1), (6, 13, -3, -5): (0, 1), (6, 13, -3, -4): (0, 1), (6, 13, -3, -3): (0, 1), (6, 13, -3, -2): (0, 1), (6, 13, -3, -1): (0, 1), (6, 13, -3, 0): (0, 1), (6, 13, -3, 1): (0, 1), (6, 13, -3, 2): (0, 1), (6, 13, -3, 3): (0, 1), (6, 13, -3, 4): (0, 1), (6, 13, -3, 5): (0, 1), (6, 13, -2, -5): (0, 1), (6, 13, -2, -4): (0, 1), (6, 13, -2, -3): (0, 1), (6, 13, -2, -2): (0, 1), (6, 13, -2, -1): (0, 1), (6, 13, -2, 0): (0, 1), (6, 13, -2, 1): (0, 1), (6, 13, -2, 2): (0, 1), (6, 13, -2, 3): (0, 1), (6, 13, -2, 4): (0, 1), (6, 13, -2, 5): (0, 1), (6, 13, -1, -5): (0, 1), (6, 13, -1, -4): (0, 1), (6, 13, -1, -3): (0, 1), (6, 13, -1, -2): (0, 1), (6, 13, -1, -1): (0, 1), (6, 13, -1, 0): (1, 1), (6, 13, -1, 1): (1, 1), (6, 13, -1, 2): (1, 1), (6, 13, -1, 3): (1, 1), (6, 13, -1, 4): (1, 1), (6, 13, -1, 5): (1, 0), (6, 13, 0, -5): (-1, 1), (6, 13, 0, -4): (-1, 1), (6, 13, 0, -3): (-1, 1), (6, 13, 0, -2): (-1, 1), (6, 13, 0, -1): (1, 1), (6, 13, 0, 0): (1, 1), (6, 13, 0, 1): (1, 1), (6, 13, 0, 2): (1, 1), (6, 13, 0, 3): (1, 1), (6, 13, 0, 4): (1, 1), (6, 13, 0, 5): (1, 0), (6, 13, 1, -5): (1, 1), (6, 13, 1, -4): (1, 1), (6, 13, 1, -3): (1, 1), (6, 13, 1, -2): (1, 1), (6, 13, 1, -1): (0, 1), (6, 13, 1, 0): (0, 1), (6, 13, 1, 1): (0, 1), (6, 13, 1, 2): (0, 1), (6, 13, 1, 3): (0, 1), (6, 13, 1, 4): (0, 1), (6, 13, 1, 5): (0, 1), (6, 13, 2, -5): (0, 1), (6, 13, 2, -4): (0, 1), (6, 13, 2, -3): (0, 1), (6, 13, 2, -2): (0, 1), (6, 13, 2, -1): (-1, 1), (6, 13, 2, 0): (-1, 1), (6, 13, 2, 1): (-1, 1), (6, 13, 2, 2): (-1, 1), (6, 13, 2, 3): (-1, 1), (6, 13, 2, 4): (-1, 1), (6, 13, 2, 5): (-1, 1), (6, 13, 3, -5): (1, 1), (6, 13, 3, -4): (1, 1), (6, 13, 3, -3): (1, 1), (6, 13, 3, -2): (1, 1), (6, 13, 3, -1): (1, 1), (6, 13, 3, 0): (-1, 1), (6, 13, 3, 1): (-1, 1), (6, 13, 3, 2): (-1, 1), (6, 13, 3, 3): (-1, 1), (6, 13, 3, 4): (-1, 1), (6, 13, 3, 5): (-1, 1), (6, 13, 4, -5): (0, 1), (6, 13, 4, -4): (0, 1), (6, 13, 4, -3): (0, 1), (6, 13, 4, -2): (0, 1), (6, 13, 4, -1): (0, 1), (6, 13, 4, 0): (0, 1), (6, 13, 4, 1): (0, 1), (6, 13, 4, 2): (0, 1), (6, 13, 4, 3): (-1, 1), (6, 13, 4, 4): (-1, 1), (6, 13, 4, 5): (-1, 1), (6, 13, 5, -5): (0, 1), (6, 13, 5, -4): (0, 1), (6, 13, 5, -3): (0, 1), (6, 13, 5, -2): (0, 1), (6, 13, 5, -1): (0, 1), (6, 13, 5, 0): (0, 1), (6, 13, 5, 1): (0, 1), (6, 13, 5, 2): (0, 1), (6, 13, 5, 3): (0, 1), (6, 13, 5, 4): (0, 1), (6, 13, 5, 5): (0, 1), (6, 14, -5, -5): (0, 1), (6, 14, -5, -4): (0, 1), (6, 14, -5, -3): (0, 1), (6, 14, -5, -2): (0, 1), (6, 14, -5, -1): (0, 1), (6, 14, -5, 0): (0, 1), (6, 14, -5, 1): (0, 1), (6, 14, -5, 2): (0, 1), (6, 14, -5, 3): (0, 1), (6, 14, -5, 4): (0, 0), (6, 14, -5, 5): (-1, -1), (6, 14, -4, -5): (0, 1), (6, 14, -4, -4): (0, 1), (6, 14, -4, -3): (0, 1), (6, 14, -4, -2): (0, 1), (6, 14, -4, -1): (0, 1), (6, 14, -4, 0): (0, 1), (6, 14, -4, 1): (0, 1), (6, 14, -4, 2): (0, 1), (6, 14, -4, 3): (0, 1), (6, 14, -4, 4): (0, 0), (6, 14, -4, 5): (-1, -1), (6, 14, -3, -5): (0, 1), (6, 14, -3, -4): (0, 1), (6, 14, -3, -3): (0, 1), (6, 14, -3, -2): (0, 1), (6, 14, -3, -1): (0, 1), (6, 14, -3, 0): (0, 1), (6, 14, -3, 1): (0, 1), (6, 14, -3, 2): (0, 1), (6, 14, -3, 3): (0, 1), (6, 14, -3, 4): (0, 0), (6, 14, -3, 5): (-1, -1), (6, 14, -2, -5): (0, 1), (6, 14, -2, -4): (0, 1), (6, 14, -2, -3): (0, 1), (6, 14, -2, -2): (0, 1), (6, 14, -2, -1): (0, 1), (6, 14, -2, 0): (0, 1), (6, 14, -2, 1): (0, 1), (6, 14, -2, 2): (0, 1), (6, 14, -2, 3): (0, 1), (6, 14, -2, 4): (0, 0), (6, 14, -2, 5): (-1, -1), (6, 14, -1, -5): (0, 1), (6, 14, -1, -4): (0, 1), (6, 14, -1, -3): (0, 1), (6, 14, -1, -2): (0, 1), (6, 14, -1, -1): (0, 1), (6, 14, -1, 0): (1, 1), (6, 14, -1, 1): (1, 1), (6, 14, -1, 2): (1, 1), (6, 14, -1, 3): (1, 1), (6, 14, -1, 4): (1, 1), (6, 14, -1, 5): (1, 0), (6, 14, 0, -5): (-1, 1), (6, 14, 0, -4): (-1, 1), (6, 14, 0, -3): (-1, 1), (6, 14, 0, -2): (-1, 1), (6, 14, 0, -1): (1, 1), (6, 14, 0, 0): (1, 1), (6, 14, 0, 1): (1, 1), (6, 14, 0, 2): (1, 1), (6, 14, 0, 3): (1, 1), (6, 14, 0, 4): (1, 1), (6, 14, 0, 5): (1, 0), (6, 14, 1, -5): (1, 1), (6, 14, 1, -4): (1, 1), (6, 14, 1, -3): (1, 1), (6, 14, 1, -2): (1, 1), (6, 14, 1, -1): (0, 1), (6, 14, 1, 0): (0, 1), (6, 14, 1, 1): (0, 1), (6, 14, 1, 2): (0, 1), (6, 14, 1, 3): (0, 1), (6, 14, 1, 4): (0, 1), (6, 14, 1, 5): (0, 1), (6, 14, 2, -5): (0, 1), (6, 14, 2, -4): (0, 1), (6, 14, 2, -3): (0, 1), (6, 14, 2, -2): (0, 1), (6, 14, 2, -1): (-1, 1), (6, 14, 2, 0): (-1, 1), (6, 14, 2, 1): (-1, 1), (6, 14, 2, 2): (-1, 1), (6, 14, 2, 3): (-1, 1), (6, 14, 2, 4): (-1, 1), (6, 14, 2, 5): (-1, 1), (6, 14, 3, -5): (1, 1), (6, 14, 3, -4): (1, 1), (6, 14, 3, -3): (1, 1), (6, 14, 3, -2): (1, 1), (6, 14, 3, -1): (1, 1), (6, 14, 3, 0): (-1, 1), (6, 14, 3, 1): (-1, 1), (6, 14, 3, 2): (-1, 1), (6, 14, 3, 3): (-1, 1), (6, 14, 3, 4): (-1, 1), (6, 14, 3, 5): (-1, 1), (6, 14, 4, -5): (0, 1), (6, 14, 4, -4): (0, 1), (6, 14, 4, -3): (0, 1), (6, 14, 4, -2): (0, 1), (6, 14, 4, -1): (0, 1), (6, 14, 4, 0): (0, 1), (6, 14, 4, 1): (0, 1), (6, 14, 4, 2): (0, 1), (6, 14, 4, 3): (-1, 1), (6, 14, 4, 4): (-1, 1), (6, 14, 4, 5): (-1, 1), (6, 14, 5, -5): (0, 1), (6, 14, 5, -4): (0, 1), (6, 14, 5, -3): (0, 1), (6, 14, 5, -2): (0, 1), (6, 14, 5, -1): (0, 1), (6, 14, 5, 0): (0, 1), (6, 14, 5, 1): (0, 1), (6, 14, 5, 2): (0, 1), (6, 14, 5, 3): (0, 1), (6, 14, 5, 4): (0, 0), (6, 14, 5, 5): (-1, -1), (6, 15, -5, -5): (0, 1), (6, 15, -5, -4): (0, 1), (6, 15, -5, -3): (0, 1), (6, 15, -5, -2): (0, 1), (6, 15, -5, -1): (0, 1), (6, 15, -5, 0): (0, 1), (6, 15, -5, 1): (0, 1), (6, 15, -5, 2): (0, 1), (6, 15, -5, 3): (0, 0), (6, 15, -5, 4): (0, 1), (6, 15, -5, 5): (0, 1), (6, 15, -4, -5): (0, 1), (6, 15, -4, -4): (0, 1), (6, 15, -4, -3): (0, 1), (6, 15, -4, -2): (0, 1), (6, 15, -4, -1): (0, 1), (6, 15, -4, 0): (0, 1), (6, 15, -4, 1): (0, 1), (6, 15, -4, 2): (0, 1), (6, 15, -4, 3): (0, 0), (6, 15, -4, 4): (0, 1), (6, 15, -4, 5): (0, 1), (6, 15, -3, -5): (0, 1), (6, 15, -3, -4): (0, 1), (6, 15, -3, -3): (0, 1), (6, 15, -3, -2): (0, 1), (6, 15, -3, -1): (0, 1), (6, 15, -3, 0): (0, 1), (6, 15, -3, 1): (0, 1), (6, 15, -3, 2): (0, 1), (6, 15, -3, 3): (0, 0), (6, 15, -3, 4): (0, 1), (6, 15, -3, 5): (0, 1), (6, 15, -2, -5): (0, 1), (6, 15, -2, -4): (0, 1), (6, 15, -2, -3): (0, 1), (6, 15, -2, -2): (0, 1), (6, 15, -2, -1): (0, 1), (6, 15, -2, 0): (0, 1), (6, 15, -2, 1): (0, 1), (6, 15, -2, 2): (0, 1), (6, 15, -2, 3): (0, 0), (6, 15, -2, 4): (0, 1), (6, 15, -2, 5): (0, 1), (6, 15, -1, -5): (0, 1), (6, 15, -1, -4): (0, 1), (6, 15, -1, -3): (0, 1), (6, 15, -1, -2): (0, 1), (6, 15, -1, -1): (0, 1), (6, 15, -1, 0): (1, 1), (6, 15, -1, 1): (1, 1), (6, 15, -1, 2): (1, 1), (6, 15, -1, 3): (1, 1), (6, 15, -1, 4): (1, 1), (6, 15, -1, 5): (1, 0), (6, 15, 0, -5): (-1, 1), (6, 15, 0, -4): (-1, 1), (6, 15, 0, -3): (-1, 1), (6, 15, 0, -2): (-1, 1), (6, 15, 0, -1): (0, 1), (6, 15, 0, 0): (1, 1), (6, 15, 0, 1): (1, 1), (6, 15, 0, 2): (1, 1), (6, 15, 0, 3): (1, 1), (6, 15, 0, 4): (1, 1), (6, 15, 0, 5): (1, 0), (6, 15, 1, -5): (1, 1), (6, 15, 1, -4): (1, 1), (6, 15, 1, -3): (1, 1), (6, 15, 1, -2): (1, 1), (6, 15, 1, -1): (1, 1), (6, 15, 1, 0): (0, 1), (6, 15, 1, 1): (0, 1), (6, 15, 1, 2): (0, 1), (6, 15, 1, 3): (0, 1), (6, 15, 1, 4): (0, 1), (6, 15, 1, 5): (0, 1), (6, 15, 2, -5): (0, 1), (6, 15, 2, -4): (0, 1), (6, 15, 2, -3): (0, 1), (6, 15, 2, -2): (0, 1), (6, 15, 2, -1): (0, 1), (6, 15, 2, 0): (-1, 1), (6, 15, 2, 1): (-1, 1), (6, 15, 2, 2): (-1, 1), (6, 15, 2, 3): (-1, 1), (6, 15, 2, 4): (-1, 1), (6, 15, 2, 5): (-1, 1), (6, 15, 3, -5): (1, 1), (6, 15, 3, -4): (1, 1), (6, 15, 3, -3): (1, 1), (6, 15, 3, -2): (1, 1), (6, 15, 3, -1): (1, 1), (6, 15, 3, 0): (-1, 1), (6, 15, 3, 1): (-1, 1), (6, 15, 3, 2): (-1, 1), (6, 15, 3, 3): (-1, 1), (6, 15, 3, 4): (-1, 1), (6, 15, 3, 5): (-1, 1), (6, 15, 4, -5): (0, 1), (6, 15, 4, -4): (0, 1), (6, 15, 4, -3): (0, 1), (6, 15, 4, -2): (0, 1), (6, 15, 4, -1): (0, 1), (6, 15, 4, 0): (0, 1), (6, 15, 4, 1): (0, 1), (6, 15, 4, 2): (0, 1), (6, 15, 4, 3): (-1, 1), (6, 15, 4, 4): (-1, 1), (6, 15, 4, 5): (-1, 1), (6, 15, 5, -5): (0, 1), (6, 15, 5, -4): (0, 1), (6, 15, 5, -3): (0, 1), (6, 15, 5, -2): (0, 1), (6, 15, 5, -1): (0, 1), (6, 15, 5, 0): (0, 1), (6, 15, 5, 1): (0, 1), (6, 15, 5, 2): (0, 1), (6, 15, 5, 3): (0, 0), (6, 15, 5, 4): (0, 1), (6, 15, 5, 5): (0, 1), (6, 16, -5, -5): (0, 1), (6, 16, -5, -4): (0, 1), (6, 16, -5, -3): (0, 1), (6, 16, -5, -2): (0, 1), (6, 16, -5, -1): (0, 1), (6, 16, -5, 0): (0, 1), (6, 16, -5, 1): (0, 1), (6, 16, -5, 2): (0, 0), (6, 16, -5, 3): (0, 1), (6, 16, -5, 4): (0, 1), (6, 16, -5, 5): (0, 1), (6, 16, -4, -5): (0, 1), (6, 16, -4, -4): (0, 1), (6, 16, -4, -3): (0, 1), (6, 16, -4, -2): (0, 1), (6, 16, -4, -1): (0, 1), (6, 16, -4, 0): (0, 1), (6, 16, -4, 1): (0, 1), (6, 16, -4, 2): (0, 0), (6, 16, -4, 3): (0, 1), (6, 16, -4, 4): (0, 1), (6, 16, -4, 5): (0, 1), (6, 16, -3, -5): (0, 1), (6, 16, -3, -4): (0, 1), (6, 16, -3, -3): (0, 1), (6, 16, -3, -2): (0, 1), (6, 16, -3, -1): (0, 1), (6, 16, -3, 0): (0, 1), (6, 16, -3, 1): (0, 1), (6, 16, -3, 2): (0, 0), (6, 16, -3, 3): (0, 1), (6, 16, -3, 4): (0, 1), (6, 16, -3, 5): (0, 1), (6, 16, -2, -5): (0, 1), (6, 16, -2, -4): (0, 1), (6, 16, -2, -3): (0, 1), (6, 16, -2, -2): (0, 1), (6, 16, -2, -1): (0, 1), (6, 16, -2, 0): (0, 1), (6, 16, -2, 1): (0, 1), (6, 16, -2, 2): (0, 0), (6, 16, -2, 3): (0, 1), (6, 16, -2, 4): (0, 1), (6, 16, -2, 5): (0, 1), (6, 16, -1, -5): (0, 1), (6, 16, -1, -4): (0, 1), (6, 16, -1, -3): (0, 1), (6, 16, -1, -2): (0, 1), (6, 16, -1, -1): (0, 1), (6, 16, -1, 0): (1, 1), (6, 16, -1, 1): (1, 1), (6, 16, -1, 2): (1, 1), (6, 16, -1, 3): (1, 1), (6, 16, -1, 4): (1, 1), (6, 16, -1, 5): (1, 0), (6, 16, 0, -5): (-1, 1), (6, 16, 0, -4): (-1, 1), (6, 16, 0, -3): (-1, 1), (6, 16, 0, -2): (-1, 1), (6, 16, 0, -1): (1, 1), (6, 16, 0, 0): (1, 1), (6, 16, 0, 1): (1, 1), (6, 16, 0, 2): (1, 1), (6, 16, 0, 3): (1, 1), (6, 16, 0, 4): (1, 0), (6, 16, 0, 5): (1, -1), (6, 16, 1, -5): (1, 1), (6, 16, 1, -4): (1, 1), (6, 16, 1, -3): (1, 1), (6, 16, 1, -2): (1, 1), (6, 16, 1, -1): (1, 1), (6, 16, 1, 0): (0, 1), (6, 16, 1, 1): (0, 1), (6, 16, 1, 2): (0, 1), (6, 16, 1, 3): (0, 1), (6, 16, 1, 4): (0, 0), (6, 16, 1, 5): (0, -1), (6, 16, 2, -5): (0, 1), (6, 16, 2, -4): (0, 1), (6, 16, 2, -3): (0, 1), (6, 16, 2, -2): (0, 1), (6, 16, 2, -1): (0, 1), (6, 16, 2, 0): (-1, 1), (6, 16, 2, 1): (-1, 1), (6, 16, 2, 2): (-1, 1), (6, 16, 2, 3): (-1, 1), (6, 16, 2, 4): (-1, 0), (6, 16, 2, 5): (-1, -1), (6, 16, 3, -5): (1, 1), (6, 16, 3, -4): (1, 1), (6, 16, 3, -3): (1, 1), (6, 16, 3, -2): (1, 1), (6, 16, 3, -1): (1, 1), (6, 16, 3, 0): (-1, 1), (6, 16, 3, 1): (-1, 1), (6, 16, 3, 2): (-1, 1), (6, 16, 3, 3): (-1, 1), (6, 16, 3, 4): (0, 1), (6, 16, 3, 5): (0, 1), (6, 16, 4, -5): (0, 1), (6, 16, 4, -4): (0, 1), (6, 16, 4, -3): (0, 1), (6, 16, 4, -2): (0, 1), (6, 16, 4, -1): (0, 1), (6, 16, 4, 0): (0, 1), (6, 16, 4, 1): (0, 1), (6, 16, 4, 2): (-1, 1), (6, 16, 4, 3): (-1, 1), (6, 16, 4, 4): (-1, 1), (6, 16, 4, 5): (-1, 1), (6, 16, 5, -5): (0, 1), (6, 16, 5, -4): (0, 1), (6, 16, 5, -3): (0, 1), (6, 16, 5, -2): (0, 1), (6, 16, 5, -1): (0, 1), (6, 16, 5, 0): (0, 1), (6, 16, 5, 1): (0, 1), (6, 16, 5, 2): (0, 0), (6, 16, 5, 3): (0, 1), (6, 16, 5, 4): (0, 1), (6, 16, 5, 5): (0, 1), (6, 17, -5, -5): (0, 1), (6, 17, -5, -4): (0, 1), (6, 17, -5, -3): (0, 1), (6, 17, -5, -2): (0, 1), (6, 17, -5, -1): (0, 1), (6, 17, -5, 0): (0, 1), (6, 17, -5, 1): (0, 0), (6, 17, -5, 2): (0, 1), (6, 17, -5, 3): (0, 1), (6, 17, -5, 4): (0, 1), (6, 17, -5, 5): (0, 1), (6, 17, -4, -5): (0, 1), (6, 17, -4, -4): (0, 1), (6, 17, -4, -3): (0, 1), (6, 17, -4, -2): (0, 1), (6, 17, -4, -1): (0, 1), (6, 17, -4, 0): (0, 1), (6, 17, -4, 1): (0, 0), (6, 17, -4, 2): (0, 1), (6, 17, -4, 3): (0, 1), (6, 17, -4, 4): (0, 1), (6, 17, -4, 5): (0, 1), (6, 17, -3, -5): (0, 1), (6, 17, -3, -4): (0, 1), (6, 17, -3, -3): (0, 1), (6, 17, -3, -2): (0, 1), (6, 17, -3, -1): (0, 1), (6, 17, -3, 0): (0, 1), (6, 17, -3, 1): (0, 0), (6, 17, -3, 2): (0, 1), (6, 17, -3, 3): (0, 1), (6, 17, -3, 4): (0, 1), (6, 17, -3, 5): (0, 1), (6, 17, -2, -5): (0, 1), (6, 17, -2, -4): (0, 1), (6, 17, -2, -3): (0, 1), (6, 17, -2, -2): (0, 1), (6, 17, -2, -1): (0, 1), (6, 17, -2, 0): (0, 1), (6, 17, -2, 1): (0, 0), (6, 17, -2, 2): (0, 1), (6, 17, -2, 3): (0, 1), (6, 17, -2, 4): (0, 1), (6, 17, -2, 5): (0, 1), (6, 17, -1, -5): (0, 1), (6, 17, -1, -4): (0, 1), (6, 17, -1, -3): (0, 1), (6, 17, -1, -2): (0, 1), (6, 17, -1, -1): (0, 1), (6, 17, -1, 0): (1, 1), (6, 17, -1, 1): (1, 1), (6, 17, -1, 2): (1, 1), (6, 17, -1, 3): (1, 1), (6, 17, -1, 4): (1, 1), (6, 17, -1, 5): (1, 0), (6, 17, 0, -5): (-1, 1), (6, 17, 0, -4): (-1, 1), (6, 17, 0, -3): (-1, 1), (6, 17, 0, -2): (-1, 1), (6, 17, 0, -1): (1, 1), (6, 17, 0, 0): (1, 1), (6, 17, 0, 1): (1, 1), (6, 17, 0, 2): (1, 1), (6, 17, 0, 3): (1, 1), (6, 17, 0, 4): (1, 0), (6, 17, 0, 5): (1, -1), (6, 17, 1, -5): (1, 1), (6, 17, 1, -4): (1, 1), (6, 17, 1, -3): (1, 1), (6, 17, 1, -2): (1, 1), (6, 17, 1, -1): (1, 1), (6, 17, 1, 0): (0, 1), (6, 17, 1, 1): (0, 1), (6, 17, 1, 2): (0, 1), (6, 17, 1, 3): (0, 1), (6, 17, 1, 4): (0, 0), (6, 17, 1, 5): (0, -1), (6, 17, 2, -5): (0, 1), (6, 17, 2, -4): (0, 1), (6, 17, 2, -3): (0, 1), (6, 17, 2, -2): (0, 1), (6, 17, 2, -1): (0, 1), (6, 17, 2, 0): (-1, 1), (6, 17, 2, 1): (-1, 1), (6, 17, 2, 2): (-1, 1), (6, 17, 2, 3): (-1, 1), (6, 17, 2, 4): (-1, 0), (6, 17, 2, 5): (-1, -1), (6, 17, 3, -5): (1, 1), (6, 17, 3, -4): (1, 1), (6, 17, 3, -3): (1, 1), (6, 17, 3, -2): (1, 1), (6, 17, 3, -1): (1, 1), (6, 17, 3, 0): (1, 1), (6, 17, 3, 1): (-1, 1), (6, 17, 3, 2): (-1, 1), (6, 17, 3, 3): (0, 1), (6, 17, 3, 4): (0, 1), (6, 17, 3, 5): (0, 1), (6, 17, 4, -5): (0, 1), (6, 17, 4, -4): (0, 1), (6, 17, 4, -3): (0, 1), (6, 17, 4, -2): (0, 1), (6, 17, 4, -1): (0, 1), (6, 17, 4, 0): (0, 1), (6, 17, 4, 1): (0, 0), (6, 17, 4, 2): (-1, 1), (6, 17, 4, 3): (-1, 1), (6, 17, 4, 4): (-1, 1), (6, 17, 4, 5): (-1, 1), (6, 17, 5, -5): (0, 1), (6, 17, 5, -4): (0, 1), (6, 17, 5, -3): (0, 1), (6, 17, 5, -2): (0, 1), (6, 17, 5, -1): (0, 1), (6, 17, 5, 0): (0, 1), (6, 17, 5, 1): (0, 0), (6, 17, 5, 2): (0, 1), (6, 17, 5, 3): (0, 1), (6, 17, 5, 4): (0, 1), (6, 17, 5, 5): (0, 1), (6, 18, -5, -5): (0, 1), (6, 18, -5, -4): (0, 1), (6, 18, -5, -3): (0, 1), (6, 18, -5, -2): (0, 1), (6, 18, -5, -1): (0, 1), (6, 18, -5, 0): (0, 0), (6, 18, -5, 1): (0, 1), (6, 18, -5, 2): (0, 1), (6, 18, -5, 3): (0, 1), (6, 18, -5, 4): (0, 1), (6, 18, -5, 5): (0, 1), (6, 18, -4, -5): (0, 1), (6, 18, -4, -4): (0, 1), (6, 18, -4, -3): (0, 1), (6, 18, -4, -2): (0, 1), (6, 18, -4, -1): (0, 1), (6, 18, -4, 0): (0, 0), (6, 18, -4, 1): (0, 1), (6, 18, -4, 2): (0, 1), (6, 18, -4, 3): (0, 1), (6, 18, -4, 4): (0, 1), (6, 18, -4, 5): (0, 1), (6, 18, -3, -5): (0, 1), (6, 18, -3, -4): (0, 1), (6, 18, -3, -3): (0, 1), (6, 18, -3, -2): (0, 1), (6, 18, -3, -1): (0, 1), (6, 18, -3, 0): (0, 0), (6, 18, -3, 1): (0, 1), (6, 18, -3, 2): (0, 1), (6, 18, -3, 3): (0, 1), (6, 18, -3, 4): (0, 1), (6, 18, -3, 5): (0, 1), (6, 18, -2, -5): (0, 1), (6, 18, -2, -4): (0, 1), (6, 18, -2, -3): (0, 1), (6, 18, -2, -2): (0, 1), (6, 18, -2, -1): (0, 1), (6, 18, -2, 0): (0, 0), (6, 18, -2, 1): (0, 1), (6, 18, -2, 2): (0, 1), (6, 18, -2, 3): (0, 1), (6, 18, -2, 4): (0, 1), (6, 18, -2, 5): (0, 1), (6, 18, -1, -5): (0, 1), (6, 18, -1, -4): (0, 1), (6, 18, -1, -3): (0, 1), (6, 18, -1, -2): (0, 1), (6, 18, -1, -1): (0, 1), (6, 18, -1, 0): (1, 1), (6, 18, -1, 1): (1, 1), (6, 18, -1, 2): (1, 1), (6, 18, -1, 3): (1, 1), (6, 18, -1, 4): (1, 1), (6, 18, -1, 5): (1, 0), (6, 18, 0, -5): (-1, 1), (6, 18, 0, -4): (-1, 1), (6, 18, 0, -3): (-1, 1), (6, 18, 0, -2): (-1, 1), (6, 18, 0, -1): (0, 1), (6, 18, 0, 0): (1, 1), (6, 18, 0, 1): (1, 1), (6, 18, 0, 2): (1, 1), (6, 18, 0, 3): (1, 0), (6, 18, 0, 4): (1, -1), (6, 18, 0, 5): (1, -1), (6, 18, 1, -5): (1, 1), (6, 18, 1, -4): (1, 1), (6, 18, 1, -3): (1, 1), (6, 18, 1, -2): (1, 1), (6, 18, 1, -1): (1, 1), (6, 18, 1, 0): (0, 1), (6, 18, 1, 1): (0, 1), (6, 18, 1, 2): (0, 1), (6, 18, 1, 3): (0, 0), (6, 18, 1, 4): (0, -1), (6, 18, 1, 5): (0, -1), (6, 18, 2, -5): (0, 1), (6, 18, 2, -4): (0, 1), (6, 18, 2, -3): (0, 1), (6, 18, 2, -2): (0, 1), (6, 18, 2, -1): (0, 1), (6, 18, 2, 0): (-1, 1), (6, 18, 2, 1): (-1, 1), (6, 18, 2, 2): (-1, 1), (6, 18, 2, 3): (-1, 0), (6, 18, 2, 4): (-1, -1), (6, 18, 2, 5): (-1, -1), (6, 18, 3, -5): (1, 1), (6, 18, 3, -4): (1, 1), (6, 18, 3, -3): (1, 1), (6, 18, 3, -2): (1, 1), (6, 18, 3, -1): (1, 1), (6, 18, 3, 0): (-1, 1), (6, 18, 3, 1): (-1, 1), (6, 18, 3, 2): (-1, 1), (6, 18, 3, 3): (0, 1), (6, 18, 3, 4): (0, 1), (6, 18, 3, 5): (0, 1), (6, 18, 4, -5): (0, 1), (6, 18, 4, -4): (0, 1), (6, 18, 4, -3): (0, 1), (6, 18, 4, -2): (0, 1), (6, 18, 4, -1): (0, 1), (6, 18, 4, 0): (0, 0), (6, 18, 4, 1): (-1, 1), (6, 18, 4, 2): (-1, 1), (6, 18, 4, 3): (-1, 1), (6, 18, 4, 4): (-1, 1), (6, 18, 4, 5): (-1, 1), (6, 18, 5, -5): (0, 1), (6, 18, 5, -4): (0, 1), (6, 18, 5, -3): (0, 1), (6, 18, 5, -2): (0, 1), (6, 18, 5, -1): (0, 1), (6, 18, 5, 0): (0, 0), (6, 18, 5, 1): (0, 1), (6, 18, 5, 2): (0, 1), (6, 18, 5, 3): (0, 1), (6, 18, 5, 4): (0, 1), (6, 18, 5, 5): (0, 1), (6, 19, -5, -5): (0, 1), (6, 19, -5, -4): (0, 1), (6, 19, -5, -3): (0, 1), (6, 19, -5, -2): (0, 1), (6, 19, -5, -1): (0, 0), (6, 19, -5, 0): (0, 1), (6, 19, -5, 1): (0, 1), (6, 19, -5, 2): (0, 1), (6, 19, -5, 3): (0, 1), (6, 19, -5, 4): (0, 1), (6, 19, -5, 5): (0, 1), (6, 19, -4, -5): (0, 1), (6, 19, -4, -4): (0, 1), (6, 19, -4, -3): (0, 1), (6, 19, -4, -2): (0, 1), (6, 19, -4, -1): (0, 0), (6, 19, -4, 0): (0, 1), (6, 19, -4, 1): (0, 1), (6, 19, -4, 2): (0, 1), (6, 19, -4, 3): (0, 1), (6, 19, -4, 4): (0, 1), (6, 19, -4, 5): (0, 1), (6, 19, -3, -5): (0, 1), (6, 19, -3, -4): (0, 1), (6, 19, -3, -3): (0, 1), (6, 19, -3, -2): (0, 1), (6, 19, -3, -1): (0, 0), (6, 19, -3, 0): (0, 1), (6, 19, -3, 1): (0, 1), (6, 19, -3, 2): (0, 1), (6, 19, -3, 3): (0, 1), (6, 19, -3, 4): (0, 1), (6, 19, -3, 5): (0, 1), (6, 19, -2, -5): (0, 1), (6, 19, -2, -4): (0, 1), (6, 19, -2, -3): (0, 1), (6, 19, -2, -2): (0, 1), (6, 19, -2, -1): (0, 0), (6, 19, -2, 0): (0, 1), (6, 19, -2, 1): (0, 1), (6, 19, -2, 2): (0, 1), (6, 19, -2, 3): (0, 1), (6, 19, -2, 4): (0, 1), (6, 19, -2, 5): (0, 1), (6, 19, -1, -5): (0, 1), (6, 19, -1, -4): (0, 1), (6, 19, -1, -3): (0, 1), (6, 19, -1, -2): (0, 1), (6, 19, -1, -1): (0, 0), (6, 19, -1, 0): (1, 1), (6, 19, -1, 1): (1, 1), (6, 19, -1, 2): (1, 1), (6, 19, -1, 3): (1, 1), (6, 19, -1, 4): (1, 1), (6, 19, -1, 5): (1, 0), (6, 19, 0, -5): (-1, 1), (6, 19, 0, -4): (-1, 1), (6, 19, 0, -3): (-1, 1), (6, 19, 0, -2): (-1, 1), (6, 19, 0, -1): (1, 1), (6, 19, 0, 0): (1, 1), (6, 19, 0, 1): (1, 1), (6, 19, 0, 2): (1, 0), (6, 19, 0, 3): (1, 1), (6, 19, 0, 4): (1, 0), (6, 19, 0, 5): (1, -1), (6, 19, 1, -5): (1, 1), (6, 19, 1, -4): (1, 1), (6, 19, 1, -3): (1, 1), (6, 19, 1, -2): (1, 1), (6, 19, 1, -1): (0, 1), (6, 19, 1, 0): (0, 1), (6, 19, 1, 1): (0, 1), (6, 19, 1, 2): (0, 0), (6, 19, 1, 3): (0, 1), (6, 19, 1, 4): (0, 0), (6, 19, 1, 5): (0, -1), (6, 19, 2, -5): (0, 1), (6, 19, 2, -4): (0, 1), (6, 19, 2, -3): (0, 1), (6, 19, 2, -2): (0, 1), (6, 19, 2, -1): (-1, 1), (6, 19, 2, 0): (-1, 1), (6, 19, 2, 1): (-1, 1), (6, 19, 2, 2): (-1, 0), (6, 19, 2, 3): (-1, 1), (6, 19, 2, 4): (-1, 0), (6, 19, 2, 5): (-1, -1), (6, 19, 3, -5): (1, 1), (6, 19, 3, -4): (1, 1), (6, 19, 3, -3): (1, 1), (6, 19, 3, -2): (1, 1), (6, 19, 3, -1): (1, 0), (6, 19, 3, 0): (-1, 1), (6, 19, 3, 1): (-1, 1), (6, 19, 3, 2): (0, 1), (6, 19, 3, 3): (0, 1), (6, 19, 3, 4): (0, 1), (6, 19, 3, 5): (0, 1), (6, 19, 4, -5): (0, 1), (6, 19, 4, -4): (0, 1), (6, 19, 4, -3): (0, 1), (6, 19, 4, -2): (0, 1), (6, 19, 4, -1): (0, 0), (6, 19, 4, 0): (0, 1), (6, 19, 4, 1): (-1, 1), (6, 19, 4, 2): (-1, 1), (6, 19, 4, 3): (-1, 1), (6, 19, 4, 4): (-1, 1), (6, 19, 4, 5): (-1, 1), (6, 19, 5, -5): (0, 1), (6, 19, 5, -4): (0, 1), (6, 19, 5, -3): (0, 1), (6, 19, 5, -2): (0, 1), (6, 19, 5, -1): (0, 0), (6, 19, 5, 0): (0, 1), (6, 19, 5, 1): (0, 1), (6, 19, 5, 2): (0, 1), (6, 19, 5, 3): (0, 1), (6, 19, 5, 4): (0, 1), (6, 19, 5, 5): (0, 1), (6, 20, -5, -5): (0, 1), (6, 20, -5, -4): (0, 1), (6, 20, -5, -3): (0, 1), (6, 20, -5, -2): (0, 0), (6, 20, -5, -1): (0, 1), (6, 20, -5, 0): (0, 1), (6, 20, -5, 1): (0, 1), (6, 20, -5, 2): (0, 1), (6, 20, -5, 3): (0, 1), (6, 20, -5, 4): (0, 1), (6, 20, -5, 5): (0, 1), (6, 20, -4, -5): (0, 1), (6, 20, -4, -4): (0, 1), (6, 20, -4, -3): (0, 1), (6, 20, -4, -2): (0, 0), (6, 20, -4, -1): (0, 1), (6, 20, -4, 0): (0, 1), (6, 20, -4, 1): (0, 1), (6, 20, -4, 2): (0, 1), (6, 20, -4, 3): (0, 1), (6, 20, -4, 4): (0, 1), (6, 20, -4, 5): (0, 1), (6, 20, -3, -5): (0, 1), (6, 20, -3, -4): (0, 1), (6, 20, -3, -3): (0, 1), (6, 20, -3, -2): (0, 0), (6, 20, -3, -1): (0, 1), (6, 20, -3, 0): (0, 1), (6, 20, -3, 1): (0, 1), (6, 20, -3, 2): (0, 1), (6, 20, -3, 3): (0, 1), (6, 20, -3, 4): (0, 1), (6, 20, -3, 5): (0, 1), (6, 20, -2, -5): (0, 1), (6, 20, -2, -4): (0, 1), (6, 20, -2, -3): (0, 1), (6, 20, -2, -2): (0, 0), (6, 20, -2, -1): (0, 1), (6, 20, -2, 0): (0, 1), (6, 20, -2, 1): (0, 1), (6, 20, -2, 2): (0, 1), (6, 20, -2, 3): (0, 1), (6, 20, -2, 4): (0, 1), (6, 20, -2, 5): (0, 1), (6, 20, -1, -5): (0, 1), (6, 20, -1, -4): (0, 1), (6, 20, -1, -3): (0, 1), (6, 20, -1, -2): (0, 0), (6, 20, -1, -1): (0, 1), (6, 20, -1, 0): (1, 1), (6, 20, -1, 1): (1, 1), (6, 20, -1, 2): (1, 1), (6, 20, -1, 3): (1, 1), (6, 20, -1, 4): (1, 1), (6, 20, -1, 5): (1, 0), (6, 20, 0, -5): (-1, 1), (6, 20, 0, -4): (-1, 1), (6, 20, 0, -3): (-1, 1), (6, 20, 0, -2): (-1, 0), (6, 20, 0, -1): (1, 1), (6, 20, 0, 0): (1, 1), (6, 20, 0, 1): (1, 1), (6, 20, 0, 2): (1, 1), (6, 20, 0, 3): (1, 0), (6, 20, 0, 4): (0, 1), (6, 20, 0, 5): (0, 1), (6, 20, 1, -5): (1, 1), (6, 20, 1, -4): (1, 1), (6, 20, 1, -3): (1, 1), (6, 20, 1, -2): (1, 1), (6, 20, 1, -1): (1, 1), (6, 20, 1, 0): (0, 1), (6, 20, 1, 1): (0, 1), (6, 20, 1, 2): (0, 1), (6, 20, 1, 3): (0, 0), (6, 20, 1, 4): (-1, 1), (6, 20, 1, 5): (-1, 1), (6, 20, 2, -5): (0, 1), (6, 20, 2, -4): (0, 1), (6, 20, 2, -3): (0, 1), (6, 20, 2, -2): (0, 1), (6, 20, 2, -1): (0, 1), (6, 20, 2, 0): (-1, 1), (6, 20, 2, 1): (-1, 1), (6, 20, 2, 2): (-1, 1), (6, 20, 2, 3): (-1, 0), (6, 20, 2, 4): (-1, -1), (6, 20, 2, 5): (-1, -1), (6, 20, 3, -5): (1, 1), (6, 20, 3, -4): (1, 1), (6, 20, 3, -3): (1, 1), (6, 20, 3, -2): (1, 0), (6, 20, 3, -1): (1, 1), (6, 20, 3, 0): (1, 1), (6, 20, 3, 1): (1, 1), (6, 20, 3, 2): (0, 1), (6, 20, 3, 3): (0, 1), (6, 20, 3, 4): (0, 1), (6, 20, 3, 5): (0, 1), (6, 20, 4, -5): (0, 1), (6, 20, 4, -4): (0, 1), (6, 20, 4, -3): (0, 1), (6, 20, 4, -2): (0, 0), (6, 20, 4, -1): (0, 1), (6, 20, 4, 0): (0, 1), (6, 20, 4, 1): (0, 1), (6, 20, 4, 2): (-1, 1), (6, 20, 4, 3): (-1, 1), (6, 20, 4, 4): (-1, 1), (6, 20, 4, 5): (-1, 1), (6, 20, 5, -5): (0, 1), (6, 20, 5, -4): (0, 1), (6, 20, 5, -3): (0, 1), (6, 20, 5, -2): (0, 0), (6, 20, 5, -1): (0, 1), (6, 20, 5, 0): (0, 1), (6, 20, 5, 1): (0, 1), (6, 20, 5, 2): (0, 1), (6, 20, 5, 3): (0, 1), (6, 20, 5, 4): (0, 1), (6, 20, 5, 5): (0, 1), (6, 21, -5, -5): (0, 1), (6, 21, -5, -4): (0, 1), (6, 21, -5, -3): (0, 0), (6, 21, -5, -2): (0, 1), (6, 21, -5, -1): (0, 1), (6, 21, -5, 0): (0, 1), (6, 21, -5, 1): (0, 1), (6, 21, -5, 2): (0, 1), (6, 21, -5, 3): (0, 1), (6, 21, -5, 4): (0, 1), (6, 21, -5, 5): (0, 1), (6, 21, -4, -5): (0, 1), (6, 21, -4, -4): (0, 1), (6, 21, -4, -3): (0, 0), (6, 21, -4, -2): (0, 1), (6, 21, -4, -1): (0, 1), (6, 21, -4, 0): (0, 1), (6, 21, -4, 1): (0, 1), (6, 21, -4, 2): (0, 1), (6, 21, -4, 3): (0, 1), (6, 21, -4, 4): (0, 1), (6, 21, -4, 5): (0, 1), (6, 21, -3, -5): (0, 1), (6, 21, -3, -4): (0, 1), (6, 21, -3, -3): (0, 0), (6, 21, -3, -2): (0, 1), (6, 21, -3, -1): (0, 1), (6, 21, -3, 0): (0, 1), (6, 21, -3, 1): (0, 1), (6, 21, -3, 2): (0, 1), (6, 21, -3, 3): (0, 1), (6, 21, -3, 4): (0, 1), (6, 21, -3, 5): (0, 1), (6, 21, -2, -5): (0, 1), (6, 21, -2, -4): (0, 1), (6, 21, -2, -3): (0, 0), (6, 21, -2, -2): (0, 1), (6, 21, -2, -1): (0, 1), (6, 21, -2, 0): (0, 1), (6, 21, -2, 1): (0, 1), (6, 21, -2, 2): (0, 1), (6, 21, -2, 3): (0, 1), (6, 21, -2, 4): (0, 1), (6, 21, -2, 5): (0, 1), (6, 21, -1, -5): (0, 1), (6, 21, -1, -4): (0, 1), (6, 21, -1, -3): (0, 0), (6, 21, -1, -2): (0, 1), (6, 21, -1, -1): (0, 1), (6, 21, -1, 0): (1, 1), (6, 21, -1, 1): (1, 1), (6, 21, -1, 2): (1, 1), (6, 21, -1, 3): (1, 1), (6, 21, -1, 4): (1, 1), (6, 21, -1, 5): (1, 0), (6, 21, 0, -5): (-1, 1), (6, 21, 0, -4): (-1, 1), (6, 21, 0, -3): (-1, 0), (6, 21, 0, -2): (-1, 1), (6, 21, 0, -1): (1, 1), (6, 21, 0, 0): (1, 1), (6, 21, 0, 1): (1, 1), (6, 21, 0, 2): (1, 1), (6, 21, 0, 3): (0, 1), (6, 21, 0, 4): (0, 1), (6, 21, 0, 5): (0, 1), (6, 21, 1, -5): (1, 1), (6, 21, 1, -4): (1, 1), (6, 21, 1, -3): (1, 1), (6, 21, 1, -2): (1, 1), (6, 21, 1, -1): (0, 1), (6, 21, 1, 0): (0, 1), (6, 21, 1, 1): (0, 1), (6, 21, 1, 2): (0, 1), (6, 21, 1, 3): (-1, 1), (6, 21, 1, 4): (-1, 1), (6, 21, 1, 5): (-1, 1), (6, 21, 2, -5): (0, 1), (6, 21, 2, -4): (0, 1), (6, 21, 2, -3): (0, 1), (6, 21, 2, -2): (0, 1), (6, 21, 2, -1): (-1, 1), (6, 21, 2, 0): (-1, 1), (6, 21, 2, 1): (-1, 1), (6, 21, 2, 2): (-1, 1), (6, 21, 2, 3): (-1, 1), (6, 21, 2, 4): (-1, 0), (6, 21, 2, 5): (-1, -1), (6, 21, 3, -5): (1, 1), (6, 21, 3, -4): (1, 1), (6, 21, 3, -3): (1, 0), (6, 21, 3, -2): (1, 1), (6, 21, 3, -1): (1, 1), (6, 21, 3, 0): (1, 1), (6, 21, 3, 1): (1, 1), (6, 21, 3, 2): (0, 1), (6, 21, 3, 3): (0, 1), (6, 21, 3, 4): (1, 1), (6, 21, 3, 5): (1, 0), (6, 21, 4, -5): (0, 1), (6, 21, 4, -4): (0, 1), (6, 21, 4, -3): (0, 0), (6, 21, 4, -2): (0, 1), (6, 21, 4, -1): (0, 1), (6, 21, 4, 0): (0, 1), (6, 21, 4, 1): (0, 1), (6, 21, 4, 2): (-1, 1), (6, 21, 4, 3): (-1, 1), (6, 21, 4, 4): (0, 1), (6, 21, 4, 5): (0, 1), (6, 21, 5, -5): (0, 1), (6, 21, 5, -4): (0, 1), (6, 21, 5, -3): (0, 0), (6, 21, 5, -2): (0, 1), (6, 21, 5, -1): (0, 1), (6, 21, 5, 0): (0, 1), (6, 21, 5, 1): (0, 1), (6, 21, 5, 2): (0, 1), (6, 21, 5, 3): (0, 1), (6, 21, 5, 4): (0, 1), (6, 21, 5, 5): (0, 1), (6, 22, -5, -5): (0, 1), (6, 22, -5, -4): (0, 0), (6, 22, -5, -3): (0, 1), (6, 22, -5, -2): (0, 1), (6, 22, -5, -1): (0, 1), (6, 22, -5, 0): (0, 1), (6, 22, -5, 1): (0, 1), (6, 22, -5, 2): (0, 1), (6, 22, -5, 3): (0, 1), (6, 22, -5, 4): (0, 1), (6, 22, -5, 5): (0, 1), (6, 22, -4, -5): (0, 1), (6, 22, -4, -4): (0, 0), (6, 22, -4, -3): (0, 1), (6, 22, -4, -2): (0, 1), (6, 22, -4, -1): (0, 1), (6, 22, -4, 0): (0, 1), (6, 22, -4, 1): (0, 1), (6, 22, -4, 2): (0, 1), (6, 22, -4, 3): (0, 1), (6, 22, -4, 4): (0, 1), (6, 22, -4, 5): (0, 1), (6, 22, -3, -5): (0, 1), (6, 22, -3, -4): (0, 0), (6, 22, -3, -3): (0, 1), (6, 22, -3, -2): (0, 1), (6, 22, -3, -1): (0, 1), (6, 22, -3, 0): (0, 1), (6, 22, -3, 1): (0, 1), (6, 22, -3, 2): (0, 1), (6, 22, -3, 3): (0, 1), (6, 22, -3, 4): (0, 1), (6, 22, -3, 5): (0, 1), (6, 22, -2, -5): (0, 1), (6, 22, -2, -4): (0, 0), (6, 22, -2, -3): (0, 1), (6, 22, -2, -2): (0, 1), (6, 22, -2, -1): (0, 1), (6, 22, -2, 0): (0, 1), (6, 22, -2, 1): (0, 1), (6, 22, -2, 2): (0, 1), (6, 22, -2, 3): (0, 1), (6, 22, -2, 4): (0, 1), (6, 22, -2, 5): (0, 1), (6, 22, -1, -5): (0, 1), (6, 22, -1, -4): (0, 0), (6, 22, -1, -3): (0, 1), (6, 22, -1, -2): (0, 1), (6, 22, -1, -1): (0, 1), (6, 22, -1, 0): (1, 1), (6, 22, -1, 1): (1, 1), (6, 22, -1, 2): (1, 1), (6, 22, -1, 3): (1, 1), (6, 22, -1, 4): (1, 1), (6, 22, -1, 5): (1, 0), (6, 22, 0, -5): (-1, 1), (6, 22, 0, -4): (-1, 0), (6, 22, 0, -3): (-1, 1), (6, 22, 0, -2): (-1, 1), (6, 22, 0, -1): (1, 1), (6, 22, 0, 0): (1, 1), (6, 22, 0, 1): (1, 1), (6, 22, 0, 2): (0, 1), (6, 22, 0, 3): (0, 1), (6, 22, 0, 4): (0, 1), (6, 22, 0, 5): (0, 1), (6, 22, 1, -5): (1, 1), (6, 22, 1, -4): (1, 1), (6, 22, 1, -3): (1, 1), (6, 22, 1, -2): (1, 1), (6, 22, 1, -1): (0, 1), (6, 22, 1, 0): (0, 1), (6, 22, 1, 1): (0, 1), (6, 22, 1, 2): (-1, 1), (6, 22, 1, 3): (-1, 1), (6, 22, 1, 4): (-1, 1), (6, 22, 1, 5): (-1, 1), (6, 22, 2, -5): (0, 1), (6, 22, 2, -4): (0, 1), (6, 22, 2, -3): (0, 1), (6, 22, 2, -2): (0, 1), (6, 22, 2, -1): (-1, 1), (6, 22, 2, 0): (-1, 1), (6, 22, 2, 1): (-1, 1), (6, 22, 2, 2): (-1, 1), (6, 22, 2, 3): (-1, 0), (6, 22, 2, 4): (-1, -1), (6, 22, 2, 5): (-1, -1), (6, 22, 3, -5): (1, 1), (6, 22, 3, -4): (1, 0), (6, 22, 3, -3): (1, 1), (6, 22, 3, -2): (1, 1), (6, 22, 3, -1): (1, 1), (6, 22, 3, 0): (1, 1), (6, 22, 3, 1): (0, 1), (6, 22, 3, 2): (0, 1), (6, 22, 3, 3): (1, 1), (6, 22, 3, 4): (1, 1), (6, 22, 3, 5): (1, 0), (6, 22, 4, -5): (0, 1), (6, 22, 4, -4): (0, 0), (6, 22, 4, -3): (0, 1), (6, 22, 4, -2): (0, 1), (6, 22, 4, -1): (0, 1), (6, 22, 4, 0): (0, 1), (6, 22, 4, 1): (-1, 1), (6, 22, 4, 2): (-1, 1), (6, 22, 4, 3): (0, 1), (6, 22, 4, 4): (0, 1), (6, 22, 4, 5): (0, 1), (6, 22, 5, -5): (0, 1), (6, 22, 5, -4): (0, 0), (6, 22, 5, -3): (0, 1), (6, 22, 5, -2): (0, 1), (6, 22, 5, -1): (0, 1), (6, 22, 5, 0): (0, 1), (6, 22, 5, 1): (0, 1), (6, 22, 5, 2): (0, 1), (6, 22, 5, 3): (0, 1), (6, 22, 5, 4): (0, 1), (6, 22, 5, 5): (0, 1), (6, 23, -5, -5): (0, 0), (6, 23, -5, -4): (0, 1), (6, 23, -5, -3): (0, 1), (6, 23, -5, -2): (0, 1), (6, 23, -5, -1): (0, 1), (6, 23, -5, 0): (0, 1), (6, 23, -5, 1): (0, 1), (6, 23, -5, 2): (0, 1), (6, 23, -5, 3): (0, 1), (6, 23, -5, 4): (0, 1), (6, 23, -5, 5): (0, 1), (6, 23, -4, -5): (0, 0), (6, 23, -4, -4): (0, 1), (6, 23, -4, -3): (0, 1), (6, 23, -4, -2): (0, 1), (6, 23, -4, -1): (0, 1), (6, 23, -4, 0): (0, 1), (6, 23, -4, 1): (0, 1), (6, 23, -4, 2): (0, 1), (6, 23, -4, 3): (0, 1), (6, 23, -4, 4): (-1, 1), (6, 23, -4, 5): (-1, 1), (6, 23, -3, -5): (0, 0), (6, 23, -3, -4): (0, 1), (6, 23, -3, -3): (0, 1), (6, 23, -3, -2): (0, 1), (6, 23, -3, -1): (0, 1), (6, 23, -3, 0): (0, 1), (6, 23, -3, 1): (0, 1), (6, 23, -3, 2): (0, 1), (6, 23, -3, 3): (0, 1), (6, 23, -3, 4): (0, 1), (6, 23, -3, 5): (0, 1), (6, 23, -2, -5): (0, 0), (6, 23, -2, -4): (0, 1), (6, 23, -2, -3): (0, 1), (6, 23, -2, -2): (0, 1), (6, 23, -2, -1): (0, 1), (6, 23, -2, 0): (0, 1), (6, 23, -2, 1): (0, 1), (6, 23, -2, 2): (0, 1), (6, 23, -2, 3): (0, 1), (6, 23, -2, 4): (0, 1), (6, 23, -2, 5): (0, 1), (6, 23, -1, -5): (0, 0), (6, 23, -1, -4): (0, 1), (6, 23, -1, -3): (0, 1), (6, 23, -1, -2): (0, 1), (6, 23, -1, -1): (0, 1), (6, 23, -1, 0): (1, 1), (6, 23, -1, 1): (1, 1), (6, 23, -1, 2): (1, 1), (6, 23, -1, 3): (1, 1), (6, 23, -1, 4): (1, 1), (6, 23, -1, 5): (1, 0), (6, 23, 0, -5): (-1, 0), (6, 23, 0, -4): (-1, 1), (6, 23, 0, -3): (-1, 1), (6, 23, 0, -2): (-1, 1), (6, 23, 0, -1): (1, 1), (6, 23, 0, 0): (1, 1), (6, 23, 0, 1): (1, 1), (6, 23, 0, 2): (0, 1), (6, 23, 0, 3): (0, 1), (6, 23, 0, 4): (0, 1), (6, 23, 0, 5): (0, 1), (6, 23, 1, -5): (1, 1), (6, 23, 1, -4): (1, 1), (6, 23, 1, -3): (1, 1), (6, 23, 1, -2): (1, 1), (6, 23, 1, -1): (0, 1), (6, 23, 1, 0): (0, 1), (6, 23, 1, 1): (0, 1), (6, 23, 1, 2): (-1, 1), (6, 23, 1, 3): (-1, 1), (6, 23, 1, 4): (-1, 1), (6, 23, 1, 5): (-1, 1), (6, 23, 2, -5): (0, 1), (6, 23, 2, -4): (0, 1), (6, 23, 2, -3): (0, 1), (6, 23, 2, -2): (0, 1), (6, 23, 2, -1): (-1, 1), (6, 23, 2, 0): (-1, 1), (6, 23, 2, 1): (-1, 1), (6, 23, 2, 2): (-1, 1), (6, 23, 2, 3): (-1, 0), (6, 23, 2, 4): (-1, -1), (6, 23, 2, 5): (-1, -1), (6, 23, 3, -5): (1, 0), (6, 23, 3, -4): (1, 1), (6, 23, 3, -3): (1, 1), (6, 23, 3, -2): (1, 1), (6, 23, 3, -1): (1, 1), (6, 23, 3, 0): (1, 1), (6, 23, 3, 1): (0, 1), (6, 23, 3, 2): (1, 1), (6, 23, 3, 3): (1, 1), (6, 23, 3, 4): (1, 1), (6, 23, 3, 5): (1, 0), (6, 23, 4, -5): (0, 0), (6, 23, 4, -4): (0, 1), (6, 23, 4, -3): (0, 1), (6, 23, 4, -2): (0, 1), (6, 23, 4, -1): (0, 1), (6, 23, 4, 0): (0, 1), (6, 23, 4, 1): (-1, 1), (6, 23, 4, 2): (0, 1), (6, 23, 4, 3): (0, 1), (6, 23, 4, 4): (0, 1), (6, 23, 4, 5): (0, 1), (6, 23, 5, -5): (0, 0), (6, 23, 5, -4): (0, 1), (6, 23, 5, -3): (0, 1), (6, 23, 5, -2): (0, 1), (6, 23, 5, -1): (0, 1), (6, 23, 5, 0): (0, 1), (6, 23, 5, 1): (0, 1), (6, 23, 5, 2): (0, 1), (6, 23, 5, 3): (0, 1), (6, 23, 5, 4): (0, 1), (6, 23, 5, 5): (0, 1), (6, 24, -5, -5): (0, 1), (6, 24, -5, -4): (0, 1), (6, 24, -5, -3): (0, 1), (6, 24, -5, -2): (0, 1), (6, 24, -5, -1): (0, 1), (6, 24, -5, 0): (0, 1), (6, 24, -5, 1): (0, 1), (6, 24, -5, 2): (0, 1), (6, 24, -5, 3): (0, 1), (6, 24, -5, 4): (1, 1), (6, 24, -5, 5): (1, 0), (6, 24, -4, -5): (0, 1), (6, 24, -4, -4): (0, 1), (6, 24, -4, -3): (0, 1), (6, 24, -4, -2): (0, 1), (6, 24, -4, -1): (0, 1), (6, 24, -4, 0): (0, 1), (6, 24, -4, 1): (0, 1), (6, 24, -4, 2): (0, 1), (6, 24, -4, 3): (-1, 1), (6, 24, -4, 4): (0, 1), (6, 24, -4, 5): (0, 1), (6, 24, -3, -5): (0, 1), (6, 24, -3, -4): (0, 1), (6, 24, -3, -3): (0, 1), (6, 24, -3, -2): (0, 1), (6, 24, -3, -1): (0, 1), (6, 24, -3, 0): (0, 1), (6, 24, -3, 1): (0, 1), (6, 24, -3, 2): (0, 1), (6, 24, -3, 3): (0, 1), (6, 24, -3, 4): (-1, 1), (6, 24, -3, 5): (-1, 1), (6, 24, -2, -5): (0, 1), (6, 24, -2, -4): (0, 1), (6, 24, -2, -3): (0, 1), (6, 24, -2, -2): (0, 1), (6, 24, -2, -1): (0, 1), (6, 24, -2, 0): (0, 1), (6, 24, -2, 1): (0, 1), (6, 24, -2, 2): (0, 1), (6, 24, -2, 3): (0, 1), (6, 24, -2, 4): (0, 1), (6, 24, -2, 5): (0, 1), (6, 24, -1, -5): (0, 1), (6, 24, -1, -4): (0, 1), (6, 24, -1, -3): (0, 1), (6, 24, -1, -2): (0, 1), (6, 24, -1, -1): (0, 1), (6, 24, -1, 0): (1, 1), (6, 24, -1, 1): (1, 1), (6, 24, -1, 2): (1, 1), (6, 24, -1, 3): (1, 1), (6, 24, -1, 4): (1, 0), (6, 24, -1, 5): (1, -1), (6, 24, 0, -5): (-1, 1), (6, 24, 0, -4): (-1, 1), (6, 24, 0, -3): (-1, 1), (6, 24, 0, -2): (-1, 1), (6, 24, 0, -1): (1, 1), (6, 24, 0, 0): (1, 1), (6, 24, 0, 1): (0, 1), (6, 24, 0, 2): (0, 1), (6, 24, 0, 3): (0, 1), (6, 24, 0, 4): (0, 0), (6, 24, 0, 5): (0, -1), (6, 24, 1, -5): (1, 1), (6, 24, 1, -4): (1, 1), (6, 24, 1, -3): (1, 1), (6, 24, 1, -2): (1, 1), (6, 24, 1, -1): (0, 1), (6, 24, 1, 0): (0, 1), (6, 24, 1, 1): (-1, 1), (6, 24, 1, 2): (-1, 1), (6, 24, 1, 3): (-1, 1), (6, 24, 1, 4): (-1, 0), (6, 24, 1, 5): (-1, -1), (6, 24, 2, -5): (0, 1), (6, 24, 2, -4): (0, 1), (6, 24, 2, -3): (0, 1), (6, 24, 2, -2): (0, 1), (6, 24, 2, -1): (-1, 1), (6, 24, 2, 0): (-1, 1), (6, 24, 2, 1): (-1, 1), (6, 24, 2, 2): (-1, 0), (6, 24, 2, 3): (-1, -1), (6, 24, 2, 4): (-1, -1), (6, 24, 2, 5): (-1, -1), (6, 24, 3, -5): (1, 1), (6, 24, 3, -4): (1, 1), (6, 24, 3, -3): (1, 1), (6, 24, 3, -2): (1, 1), (6, 24, 3, -1): (1, 1), (6, 24, 3, 0): (0, 1), (6, 24, 3, 1): (1, 1), (6, 24, 3, 2): (1, 1), (6, 24, 3, 3): (1, 1), (6, 24, 3, 4): (1, 1), (6, 24, 3, 5): (1, 0), (6, 24, 4, -5): (0, 1), (6, 24, 4, -4): (0, 1), (6, 24, 4, -3): (0, 1), (6, 24, 4, -2): (0, 1), (6, 24, 4, -1): (0, 1), (6, 24, 4, 0): (-1, 1), (6, 24, 4, 1): (0, 1), (6, 24, 4, 2): (0, 1), (6, 24, 4, 3): (0, 1), (6, 24, 4, 4): (0, 1), (6, 24, 4, 5): (0, 1), (6, 24, 5, -5): (0, 1), (6, 24, 5, -4): (0, 1), (6, 24, 5, -3): (0, 1), (6, 24, 5, -2): (0, 1), (6, 24, 5, -1): (0, 1), (6, 24, 5, 0): (0, 1), (6, 24, 5, 1): (0, 1), (6, 24, 5, 2): (0, 1), (6, 24, 5, 3): (0, 1), (6, 24, 5, 4): (0, 1), (6, 24, 5, 5): (0, 1), (6, 25, -5, -5): (0, 1), (6, 25, -5, -4): (0, 1), (6, 25, -5, -3): (0, 1), (6, 25, -5, -2): (0, 1), (6, 25, -5, -1): (0, 1), (6, 25, -5, 0): (0, 1), (6, 25, -5, 1): (0, 1), (6, 25, -5, 2): (0, 1), (6, 25, -5, 3): (1, 1), (6, 25, -5, 4): (1, 0), (6, 25, -5, 5): (1, 0), (6, 25, -4, -5): (0, 1), (6, 25, -4, -4): (0, 1), (6, 25, -4, -3): (0, 1), (6, 25, -4, -2): (0, 1), (6, 25, -4, -1): (0, 1), (6, 25, -4, 0): (0, 1), (6, 25, -4, 1): (0, 1), (6, 25, -4, 2): (-1, 1), (6, 25, -4, 3): (0, 1), (6, 25, -4, 4): (0, 1), (6, 25, -4, 5): (0, 1), (6, 25, -3, -5): (0, 1), (6, 25, -3, -4): (0, 1), (6, 25, -3, -3): (0, 1), (6, 25, -3, -2): (0, 1), (6, 25, -3, -1): (0, 1), (6, 25, -3, 0): (0, 1), (6, 25, -3, 1): (0, 1), (6, 25, -3, 2): (0, 1), (6, 25, -3, 3): (-1, 1), (6, 25, -3, 4): (-1, 1), (6, 25, -3, 5): (-1, 1), (6, 25, -2, -5): (0, 1), (6, 25, -2, -4): (0, 1), (6, 25, -2, -3): (0, 1), (6, 25, -2, -2): (0, 1), (6, 25, -2, -1): (0, 1), (6, 25, -2, 0): (0, 1), (6, 25, -2, 1): (0, 1), (6, 25, -2, 2): (0, 1), (6, 25, -2, 3): (0, 1), (6, 25, -2, 4): (-1, 1), (6, 25, -2, 5): (-1, 1), (6, 25, -1, -5): (0, 1), (6, 25, -1, -4): (0, 1), (6, 25, -1, -3): (0, 1), (6, 25, -1, -2): (0, 1), (6, 25, -1, -1): (0, 1), (6, 25, -1, 0): (1, 1), (6, 25, -1, 1): (1, 1), (6, 25, -1, 2): (1, 1), (6, 25, -1, 3): (1, 1), (6, 25, -1, 4): (1, 0), (6, 25, -1, 5): (1, -1), (6, 25, 0, -5): (-1, 1), (6, 25, 0, -4): (-1, 1), (6, 25, 0, -3): (-1, 1), (6, 25, 0, -2): (-1, 1), (6, 25, 0, -1): (1, 1), (6, 25, 0, 0): (1, 1), (6, 25, 0, 1): (0, 1), (6, 25, 0, 2): (0, 1), (6, 25, 0, 3): (0, 1), (6, 25, 0, 4): (0, 0), (6, 25, 0, 5): (0, -1), (6, 25, 1, -5): (1, 1), (6, 25, 1, -4): (1, 1), (6, 25, 1, -3): (1, 1), (6, 25, 1, -2): (1, 1), (6, 25, 1, -1): (0, 1), (6, 25, 1, 0): (0, 1), (6, 25, 1, 1): (-1, 1), (6, 25, 1, 2): (-1, 1), (6, 25, 1, 3): (-1, 1), (6, 25, 1, 4): (-1, 0), (6, 25, 1, 5): (-1, -1), (6, 25, 2, -5): (0, 1), (6, 25, 2, -4): (0, 1), (6, 25, 2, -3): (0, 1), (6, 25, 2, -2): (0, 1), (6, 25, 2, -1): (-1, 1), (6, 25, 2, 0): (-1, 1), (6, 25, 2, 1): (-1, 1), (6, 25, 2, 2): (-1, 0), (6, 25, 2, 3): (-1, -1), (6, 25, 2, 4): (-1, -1), (6, 25, 2, 5): (-1, -1), (6, 25, 3, -5): (1, 1), (6, 25, 3, -4): (1, 1), (6, 25, 3, -3): (1, 1), (6, 25, 3, -2): (1, 1), (6, 25, 3, -1): (1, 1), (6, 25, 3, 0): (1, 1), (6, 25, 3, 1): (1, 1), (6, 25, 3, 2): (1, 1), (6, 25, 3, 3): (1, 1), (6, 25, 3, 4): (1, 0), (6, 25, 3, 5): (1, -1), (6, 25, 4, -5): (0, 1), (6, 25, 4, -4): (0, 1), (6, 25, 4, -3): (0, 1), (6, 25, 4, -2): (0, 1), (6, 25, 4, -1): (0, 1), (6, 25, 4, 0): (0, 1), (6, 25, 4, 1): (0, 1), (6, 25, 4, 2): (0, 1), (6, 25, 4, 3): (0, 1), (6, 25, 4, 4): (0, 0), (6, 25, 4, 5): (0, -1), (6, 25, 5, -5): (0, 1), (6, 25, 5, -4): (0, 1), (6, 25, 5, -3): (0, 1), (6, 25, 5, -2): (0, 1), (6, 25, 5, -1): (0, 1), (6, 25, 5, 0): (0, 1), (6, 25, 5, 1): (0, 1), (6, 25, 5, 2): (0, 1), (6, 25, 5, 3): (0, 1), (6, 25, 5, 4): (0, 0), (6, 25, 5, 5): (-1, -1), (6, 26, -5, -5): (0, 1), (6, 26, -5, -4): (0, 1), (6, 26, -5, -3): (0, 1), (6, 26, -5, -2): (0, 1), (6, 26, -5, -1): (0, 1), (6, 26, -5, 0): (0, 1), (6, 26, -5, 1): (0, 1), (6, 26, -5, 2): (1, 1), (6, 26, -5, 3): (1, 0), (6, 26, -5, 4): (0, 1), (6, 26, -5, 5): (0, 1), (6, 26, -4, -5): (0, 1), (6, 26, -4, -4): (0, 1), (6, 26, -4, -3): (0, 1), (6, 26, -4, -2): (0, 1), (6, 26, -4, -1): (0, 1), (6, 26, -4, 0): (0, 1), (6, 26, -4, 1): (-1, 1), (6, 26, -4, 2): (0, 1), (6, 26, -4, 3): (0, 1), (6, 26, -4, 4): (0, 1), (6, 26, -4, 5): (0, 1), (6, 26, -3, -5): (0, 1), (6, 26, -3, -4): (0, 1), (6, 26, -3, -3): (0, 1), (6, 26, -3, -2): (0, 1), (6, 26, -3, -1): (0, 1), (6, 26, -3, 0): (0, 1), (6, 26, -3, 1): (0, 1), (6, 26, -3, 2): (-1, 1), (6, 26, -3, 3): (-1, 1), (6, 26, -3, 4): (-1, 1), (6, 26, -3, 5): (-1, 1), (6, 26, -2, -5): (0, 1), (6, 26, -2, -4): (0, 1), (6, 26, -2, -3): (0, 1), (6, 26, -2, -2): (0, 1), (6, 26, -2, -1): (0, 1), (6, 26, -2, 0): (0, 1), (6, 26, -2, 1): (0, 1), (6, 26, -2, 2): (0, 1), (6, 26, -2, 3): (-1, 1), (6, 26, -2, 4): (-1, 1), (6, 26, -2, 5): (-1, 1), (6, 26, -1, -5): (0, 1), (6, 26, -1, -4): (0, 1), (6, 26, -1, -3): (0, 1), (6, 26, -1, -2): (0, 1), (6, 26, -1, -1): (0, 1), (6, 26, -1, 0): (1, 1), (6, 26, -1, 1): (1, 1), (6, 26, -1, 2): (1, 1), (6, 26, -1, 3): (1, 0), (6, 26, -1, 4): (-1, 1), (6, 26, -1, 5): (-1, 1), (6, 26, 0, -5): (-1, 1), (6, 26, 0, -4): (-1, 1), (6, 26, 0, -3): (-1, 1), (6, 26, 0, -2): (-1, 1), (6, 26, 0, -1): (1, 1), (6, 26, 0, 0): (0, 1), (6, 26, 0, 1): (0, 1), (6, 26, 0, 2): (0, 1), (6, 26, 0, 3): (0, 0), (6, 26, 0, 4): (-1, 1), (6, 26, 0, 5): (-1, 1), (6, 26, 1, -5): (1, 1), (6, 26, 1, -4): (1, 1), (6, 26, 1, -3): (1, 1), (6, 26, 1, -2): (1, 1), (6, 26, 1, -1): (0, 1), (6, 26, 1, 0): (-1, 1), (6, 26, 1, 1): (-1, 1), (6, 26, 1, 2): (-1, 1), (6, 26, 1, 3): (-1, 0), (6, 26, 1, 4): (-1, -1), (6, 26, 1, 5): (-1, 1), (6, 26, 2, -5): (0, 1), (6, 26, 2, -4): (0, 1), (6, 26, 2, -3): (0, 1), (6, 26, 2, -2): (0, 1), (6, 26, 2, -1): (-1, 1), (6, 26, 2, 0): (-1, 1), (6, 26, 2, 1): (-1, 1), (6, 26, 2, 2): (-1, 0), (6, 26, 2, 3): (-1, -1), (6, 26, 2, 4): (-1, 1), (6, 26, 2, 5): (-1, 1), (6, 26, 3, -5): (1, 1), (6, 26, 3, -4): (1, 1), (6, 26, 3, -3): (1, 1), (6, 26, 3, -2): (1, 1), (6, 26, 3, -1): (1, 1), (6, 26, 3, 0): (1, 1), (6, 26, 3, 1): (1, 1), (6, 26, 3, 2): (1, 1), (6, 26, 3, 3): (1, 0), (6, 26, 3, 4): (1, -1), (6, 26, 3, 5): (1, -1), (6, 26, 4, -5): (0, 1), (6, 26, 4, -4): (0, 1), (6, 26, 4, -3): (0, 1), (6, 26, 4, -2): (0, 1), (6, 26, 4, -1): (0, 1), (6, 26, 4, 0): (0, 1), (6, 26, 4, 1): (0, 1), (6, 26, 4, 2): (0, 1), (6, 26, 4, 3): (0, 0), (6, 26, 4, 4): (0, -1), (6, 26, 4, 5): (0, -1), (6, 26, 5, -5): (0, 1), (6, 26, 5, -4): (0, 1), (6, 26, 5, -3): (0, 1), (6, 26, 5, -2): (0, 1), (6, 26, 5, -1): (0, 1), (6, 26, 5, 0): (0, 1), (6, 26, 5, 1): (0, 1), (6, 26, 5, 2): (0, 1), (6, 26, 5, 3): (0, 0), (6, 26, 5, 4): (-1, -1), (6, 26, 5, 5): (-1, -1), (6, 27, -5, -5): (0, 1), (6, 27, -5, -4): (0, 1), (6, 27, -5, -3): (0, 1), (6, 27, -5, -2): (0, 1), (6, 27, -5, -1): (0, 1), (6, 27, -5, 0): (0, 1), (6, 27, -5, 1): (1, 1), (6, 27, -5, 2): (1, 0), (6, 27, -5, 3): (0, 1), (6, 27, -5, 4): (0, 1), (6, 27, -5, 5): (0, 1), (6, 27, -4, -5): (0, 1), (6, 27, -4, -4): (0, 1), (6, 27, -4, -3): (0, 1), (6, 27, -4, -2): (0, 1), (6, 27, -4, -1): (0, 1), (6, 27, -4, 0): (-1, 1), (6, 27, -4, 1): (0, 1), (6, 27, -4, 2): (0, 1), (6, 27, -4, 3): (0, 1), (6, 27, -4, 4): (-1, 1), (6, 27, -4, 5): (-1, 1), (6, 27, -3, -5): (0, 1), (6, 27, -3, -4): (0, 1), (6, 27, -3, -3): (0, 1), (6, 27, -3, -2): (0, 1), (6, 27, -3, -1): (0, 1), (6, 27, -3, 0): (0, 1), (6, 27, -3, 1): (-1, 1), (6, 27, -3, 2): (-1, 1), (6, 27, -3, 3): (-1, 1), (6, 27, -3, 4): (-1, 0), (6, 27, -3, 5): (-1, -1), (6, 27, -2, -5): (0, 1), (6, 27, -2, -4): (0, 1), (6, 27, -2, -3): (0, 1), (6, 27, -2, -2): (0, 1), (6, 27, -2, -1): (0, 1), (6, 27, -2, 0): (0, 1), (6, 27, -2, 1): (0, 1), (6, 27, -2, 2): (-1, 1), (6, 27, -2, 3): (-1, 1), (6, 27, -2, 4): (0, 1), (6, 27, -2, 5): (0, 1), (6, 27, -1, -5): (0, 1), (6, 27, -1, -4): (0, 1), (6, 27, -1, -3): (0, 1), (6, 27, -1, -2): (0, 1), (6, 27, -1, -1): (0, 1), (6, 27, -1, 0): (1, 1), (6, 27, -1, 1): (1, 1), (6, 27, -1, 2): (1, 0), (6, 27, -1, 3): (-1, 1), (6, 27, -1, 4): (-1, 1), (6, 27, -1, 5): (-1, 1), (6, 27, 0, -5): (-1, 1), (6, 27, 0, -4): (-1, 1), (6, 27, 0, -3): (-1, 1), (6, 27, 0, -2): (-1, 1), (6, 27, 0, -1): (1, 1), (6, 27, 0, 0): (0, 1), (6, 27, 0, 1): (0, 1), (6, 27, 0, 2): (0, 0), (6, 27, 0, 3): (-1, 1), (6, 27, 0, 4): (-1, 1), (6, 27, 0, 5): (-1, 1), (6, 27, 1, -5): (1, 1), (6, 27, 1, -4): (1, 1), (6, 27, 1, -3): (1, 1), (6, 27, 1, -2): (1, 1), (6, 27, 1, -1): (0, 1), (6, 27, 1, 0): (-1, 1), (6, 27, 1, 1): (-1, 1), (6, 27, 1, 2): (-1, 0), (6, 27, 1, 3): (-1, -1), (6, 27, 1, 4): (-1, -1), (6, 27, 1, 5): (-1, 1), (6, 27, 2, -5): (0, 1), (6, 27, 2, -4): (0, 1), (6, 27, 2, -3): (0, 1), (6, 27, 2, -2): (0, 1), (6, 27, 2, -1): (-1, 1), (6, 27, 2, 0): (-1, 1), (6, 27, 2, 1): (-1, 1), (6, 27, 2, 2): (-1, 1), (6, 27, 2, 3): (-1, 1), (6, 27, 2, 4): (-1, 1), (6, 27, 2, 5): (-1, 1), (6, 27, 3, -5): (1, 1), (6, 27, 3, -4): (1, 1), (6, 27, 3, -3): (1, 1), (6, 27, 3, -2): (1, 1), (6, 27, 3, -1): (1, 1), (6, 27, 3, 0): (1, 1), (6, 27, 3, 1): (1, 1), (6, 27, 3, 2): (1, 0), (6, 27, 3, 3): (1, -1), (6, 27, 3, 4): (1, 1), (6, 27, 3, 5): (1, 0), (6, 27, 4, -5): (0, 1), (6, 27, 4, -4): (0, 1), (6, 27, 4, -3): (0, 1), (6, 27, 4, -2): (0, 1), (6, 27, 4, -1): (0, 1), (6, 27, 4, 0): (0, 1), (6, 27, 4, 1): (0, 1), (6, 27, 4, 2): (0, 0), (6, 27, 4, 3): (0, -1), (6, 27, 4, 4): (0, 1), (6, 27, 4, 5): (0, 1), (6, 27, 5, -5): (0, 1), (6, 27, 5, -4): (0, 1), (6, 27, 5, -3): (0, 1), (6, 27, 5, -2): (0, 1), (6, 27, 5, -1): (0, 1), (6, 27, 5, 0): (0, 1), (6, 27, 5, 1): (0, 1), (6, 27, 5, 2): (0, 0), (6, 27, 5, 3): (-1, -1), (6, 27, 5, 4): (0, 1), (6, 27, 5, 5): (0, 1), (6, 28, -5, -5): (0, 1), (6, 28, -5, -4): (0, 1), (6, 28, -5, -3): (0, 1), (6, 28, -5, -2): (0, 1), (6, 28, -5, -1): (0, 1), (6, 28, -5, 0): (1, 1), (6, 28, -5, 1): (1, 0), (6, 28, -5, 2): (0, 1), (6, 28, -5, 3): (0, 1), (6, 28, -5, 4): (0, 1), (6, 28, -5, 5): (0, 1), (6, 28, -4, -5): (0, 1), (6, 28, -4, -4): (0, 1), (6, 28, -4, -3): (0, 1), (6, 28, -4, -2): (0, 1), (6, 28, -4, -1): (-1, 1), (6, 28, -4, 0): (0, 1), (6, 28, -4, 1): (0, 1), (6, 28, -4, 2): (0, 1), (6, 28, -4, 3): (-1, 1), (6, 28, -4, 4): (-1, 1), (6, 28, -4, 5): (-1, 1), (6, 28, -3, -5): (0, 1), (6, 28, -3, -4): (0, 1), (6, 28, -3, -3): (0, 1), (6, 28, -3, -2): (0, 1), (6, 28, -3, -1): (0, 1), (6, 28, -3, 0): (-1, 1), (6, 28, -3, 1): (-1, 1), (6, 28, -3, 2): (-1, 1), (6, 28, -3, 3): (0, 1), (6, 28, -3, 4): (0, 0), (6, 28, -3, 5): (-1, -1), (6, 28, -2, -5): (0, 1), (6, 28, -2, -4): (0, 1), (6, 28, -2, -3): (0, 1), (6, 28, -2, -2): (0, 1), (6, 28, -2, -1): (0, 1), (6, 28, -2, 0): (0, 1), (6, 28, -2, 1): (-1, 1), (6, 28, -2, 2): (-1, 1), (6, 28, -2, 3): (0, 1), (6, 28, -2, 4): (0, 0), (6, 28, -2, 5): (-1, -1), (6, 28, -1, -5): (0, 1), (6, 28, -1, -4): (0, 1), (6, 28, -1, -3): (0, 1), (6, 28, -1, -2): (0, 1), (6, 28, -1, -1): (0, 1), (6, 28, -1, 0): (1, 1), (6, 28, -1, 1): (1, 1), (6, 28, -1, 2): (-1, 1), (6, 28, -1, 3): (-1, 1), (6, 28, -1, 4): (-1, 0), (6, 28, -1, 5): (-1, -1), (6, 28, 0, -5): (-1, 1), (6, 28, 0, -4): (-1, 1), (6, 28, 0, -3): (-1, 1), (6, 28, 0, -2): (-1, 1), (6, 28, 0, -1): (1, 1), (6, 28, 0, 0): (0, 1), (6, 28, 0, 1): (0, 1), (6, 28, 0, 2): (-1, 1), (6, 28, 0, 3): (-1, 1), (6, 28, 0, 4): (-1, 0), (6, 28, 0, 5): (-1, -1), (6, 28, 1, -5): (1, 1), (6, 28, 1, -4): (1, 1), (6, 28, 1, -3): (1, 1), (6, 28, 1, -2): (1, 1), (6, 28, 1, -1): (0, 1), (6, 28, 1, 0): (-1, 1), (6, 28, 1, 1): (-1, 1), (6, 28, 1, 2): (-1, 0), (6, 28, 1, 3): (-1, -1), (6, 28, 1, 4): (-1, -1), (6, 28, 1, 5): (-1, 1), (6, 28, 2, -5): (0, 1), (6, 28, 2, -4): (0, 1), (6, 28, 2, -3): (0, 1), (6, 28, 2, -2): (0, 1), (6, 28, 2, -1): (-1, 1), (6, 28, 2, 0): (-1, 1), (6, 28, 2, 1): (-1, 1), (6, 28, 2, 2): (-1, 0), (6, 28, 2, 3): (-1, 1), (6, 28, 2, 4): (-1, 1), (6, 28, 2, 5): (-1, 1), (6, 28, 3, -5): (1, 1), (6, 28, 3, -4): (1, 1), (6, 28, 3, -3): (1, 1), (6, 28, 3, -2): (1, 1), (6, 28, 3, -1): (1, 1), (6, 28, 3, 0): (1, 1), (6, 28, 3, 1): (1, 0), (6, 28, 3, 2): (1, -1), (6, 28, 3, 3): (1, 1), (6, 28, 3, 4): (1, 0), (6, 28, 3, 5): (1, 0), (6, 28, 4, -5): (0, 1), (6, 28, 4, -4): (0, 1), (6, 28, 4, -3): (0, 1), (6, 28, 4, -2): (0, 1), (6, 28, 4, -1): (0, 1), (6, 28, 4, 0): (0, 1), (6, 28, 4, 1): (0, 0), (6, 28, 4, 2): (0, -1), (6, 28, 4, 3): (0, 1), (6, 28, 4, 4): (0, 1), (6, 28, 4, 5): (0, 1), (6, 28, 5, -5): (0, 1), (6, 28, 5, -4): (0, 1), (6, 28, 5, -3): (0, 1), (6, 28, 5, -2): (0, 1), (6, 28, 5, -1): (0, 1), (6, 28, 5, 0): (0, 1), (6, 28, 5, 1): (0, 0), (6, 28, 5, 2): (-1, -1), (6, 28, 5, 3): (0, 1), (6, 28, 5, 4): (0, 1), (6, 28, 5, 5): (0, 1), (6, 29, -5, -5): (0, 1), (6, 29, -5, -4): (0, 1), (6, 29, -5, -3): (0, 1), (6, 29, -5, -2): (0, 1), (6, 29, -5, -1): (1, 1), (6, 29, -5, 0): (1, 0), (6, 29, -5, 1): (0, 1), (6, 29, -5, 2): (0, 1), (6, 29, -5, 3): (0, 1), (6, 29, -5, 4): (0, 1), (6, 29, -5, 5): (0, 1), (6, 29, -4, -5): (0, 1), (6, 29, -4, -4): (0, 1), (6, 29, -4, -3): (0, 1), (6, 29, -4, -2): (-1, 1), (6, 29, -4, -1): (0, 1), (6, 29, -4, 0): (0, 1), (6, 29, -4, 1): (0, 1), (6, 29, -4, 2): (-1, 1), (6, 29, -4, 3): (-1, 1), (6, 29, -4, 4): (-1, 1), (6, 29, -4, 5): (-1, 1), (6, 29, -3, -5): (0, 1), (6, 29, -3, -4): (0, 1), (6, 29, -3, -3): (0, 1), (6, 29, -3, -2): (0, 1), (6, 29, -3, -1): (-1, 1), (6, 29, -3, 0): (-1, 1), (6, 29, -3, 1): (-1, 1), (6, 29, -3, 2): (0, 1), (6, 29, -3, 3): (0, 0), (6, 29, -3, 4): (-1, -1), (6, 29, -3, 5): (0, 1), (6, 29, -2, -5): (0, 1), (6, 29, -2, -4): (0, 1), (6, 29, -2, -3): (0, 1), (6, 29, -2, -2): (0, 1), (6, 29, -2, -1): (0, 1), (6, 29, -2, 0): (-1, 1), (6, 29, -2, 1): (-1, 1), (6, 29, -2, 2): (-1, 1), (6, 29, -2, 3): (-1, 0), (6, 29, -2, 4): (-1, -1), (6, 29, -2, 5): (0, 1), (6, 29, -1, -5): (0, 1), (6, 29, -1, -4): (0, 1), (6, 29, -1, -3): (0, 1), (6, 29, -1, -2): (0, 1), (6, 29, -1, -1): (0, 1), (6, 29, -1, 0): (1, 1), (6, 29, -1, 1): (-1, 1), (6, 29, -1, 2): (-1, 1), (6, 29, -1, 3): (-1, 0), (6, 29, -1, 4): (-1, -1), (6, 29, -1, 5): (-1, 1), (6, 29, 0, -5): (-1, 1), (6, 29, 0, -4): (-1, 1), (6, 29, 0, -3): (-1, 1), (6, 29, 0, -2): (-1, 1), (6, 29, 0, -1): (0, 1), (6, 29, 0, 0): (0, 1), (6, 29, 0, 1): (-1, 1), (6, 29, 0, 2): (-1, 1), (6, 29, 0, 3): (-1, 0), (6, 29, 0, 4): (-1, -1), (6, 29, 0, 5): (-1, 1), (6, 29, 1, -5): (1, 1), (6, 29, 1, -4): (1, 1), (6, 29, 1, -3): (1, 1), (6, 29, 1, -2): (1, 1), (6, 29, 1, -1): (-1, 1), (6, 29, 1, 0): (-1, 1), (6, 29, 1, 1): (-1, 0), (6, 29, 1, 2): (-1, -1), (6, 29, 1, 3): (-1, -1), (6, 29, 1, 4): (-1, -1), (6, 29, 1, 5): (-1, 1), (6, 29, 2, -5): (0, 1), (6, 29, 2, -4): (0, 1), (6, 29, 2, -3): (0, 1), (6, 29, 2, -2): (0, 1), (6, 29, 2, -1): (-1, 1), (6, 29, 2, 0): (-1, 1), (6, 29, 2, 1): (-1, 1), (6, 29, 2, 2): (-1, 1), (6, 29, 2, 3): (-1, 1), (6, 29, 2, 4): (-1, 1), (6, 29, 2, 5): (-1, 1), (6, 29, 3, -5): (1, 1), (6, 29, 3, -4): (1, 1), (6, 29, 3, -3): (1, 1), (6, 29, 3, -2): (1, 1), (6, 29, 3, -1): (1, 1), (6, 29, 3, 0): (1, 0), (6, 29, 3, 1): (1, -1), (6, 29, 3, 2): (1, 1), (6, 29, 3, 3): (1, 0), (6, 29, 3, 4): (1, 0), (6, 29, 3, 5): (1, 0), (6, 29, 4, -5): (0, 1), (6, 29, 4, -4): (0, 1), (6, 29, 4, -3): (0, 1), (6, 29, 4, -2): (0, 1), (6, 29, 4, -1): (0, 1), (6, 29, 4, 0): (0, 0), (6, 29, 4, 1): (0, -1), (6, 29, 4, 2): (0, 1), (6, 29, 4, 3): (0, 1), (6, 29, 4, 4): (0, 1), (6, 29, 4, 5): (0, 1), (6, 29, 5, -5): (0, 1), (6, 29, 5, -4): (0, 1), (6, 29, 5, -3): (0, 1), (6, 29, 5, -2): (0, 1), (6, 29, 5, -1): (0, 1), (6, 29, 5, 0): (0, 0), (6, 29, 5, 1): (-1, -1), (6, 29, 5, 2): (0, 1), (6, 29, 5, 3): (0, 1), (6, 29, 5, 4): (0, 1), (6, 29, 5, 5): (0, 1), (6, 30, -5, -5): (0, 1), (6, 30, -5, -4): (0, 1), (6, 30, -5, -3): (0, 1), (6, 30, -5, -2): (1, 1), (6, 30, -5, -1): (1, 0), (6, 30, -5, 0): (0, 1), (6, 30, -5, 1): (0, 1), (6, 30, -5, 2): (0, 1), (6, 30, -5, 3): (0, 1), (6, 30, -5, 4): (0, 1), (6, 30, -5, 5): (0, 1), (6, 30, -4, -5): (0, 1), (6, 30, -4, -4): (0, 1), (6, 30, -4, -3): (-1, 1), (6, 30, -4, -2): (0, 1), (6, 30, -4, -1): (0, 1), (6, 30, -4, 0): (0, 1), (6, 30, -4, 1): (-1, 1), (6, 30, -4, 2): (-1, 1), (6, 30, -4, 3): (-1, 1), (6, 30, -4, 4): (-1, 1), (6, 30, -4, 5): (-1, 1), (6, 30, -3, -5): (0, 1), (6, 30, -3, -4): (0, 1), (6, 30, -3, -3): (0, 1), (6, 30, -3, -2): (-1, 1), (6, 30, -3, -1): (-1, 1), (6, 30, -3, 0): (-1, 1), (6, 30, -3, 1): (0, 1), (6, 30, -3, 2): (0, 0), (6, 30, -3, 3): (-1, -1), (6, 30, -3, 4): (-1, -1), (6, 30, -3, 5): (0, 1), (6, 30, -2, -5): (0, 1), (6, 30, -2, -4): (0, 1), (6, 30, -2, -3): (0, 1), (6, 30, -2, -2): (0, 1), (6, 30, -2, -1): (-1, 1), (6, 30, -2, 0): (-1, 1), (6, 30, -2, 1): (-1, 1), (6, 30, -2, 2): (-1, 0), (6, 30, -2, 3): (-1, -1), (6, 30, -2, 4): (-1, -1), (6, 30, -2, 5): (0, 1), (6, 30, -1, -5): (0, 1), (6, 30, -1, -4): (0, 1), (6, 30, -1, -3): (0, 1), (6, 30, -1, -2): (0, 1), (6, 30, -1, -1): (0, 1), (6, 30, -1, 0): (-1, 1), (6, 30, -1, 1): (-1, 1), (6, 30, -1, 2): (-1, 1), (6, 30, -1, 3): (-1, 0), (6, 30, -1, 4): (-1, -1), (6, 30, -1, 5): (-1, 1), (6, 30, 0, -5): (-1, 1), (6, 30, 0, -4): (-1, 1), (6, 30, 0, -3): (-1, 1), (6, 30, 0, -2): (-1, 1), (6, 30, 0, -1): (0, 1), (6, 30, 0, 0): (0, 1), (6, 30, 0, 1): (-1, 1), (6, 30, 0, 2): (-1, 0), (6, 30, 0, 3): (-1, -1), (6, 30, 0, 4): (-1, -1), (6, 30, 0, 5): (-1, 1), (6, 30, 1, -5): (1, 1), (6, 30, 1, -4): (1, 1), (6, 30, 1, -3): (1, 1), (6, 30, 1, -2): (0, 1), (6, 30, 1, -1): (-1, 1), (6, 30, 1, 0): (-1, 1), (6, 30, 1, 1): (-1, 0), (6, 30, 1, 2): (-1, -1), (6, 30, 1, 3): (-1, -1), (6, 30, 1, 4): (-1, 1), (6, 30, 1, 5): (-1, 1), (6, 30, 2, -5): (0, 1), (6, 30, 2, -4): (0, 1), (6, 30, 2, -3): (0, 1), (6, 30, 2, -2): (-1, 1), (6, 30, 2, -1): (-1, 1), (6, 30, 2, 0): (-1, 1), (6, 30, 2, 1): (-1, 1), (6, 30, 2, 2): (-1, 1), (6, 30, 2, 3): (-1, 1), (6, 30, 2, 4): (-1, 1), (6, 30, 2, 5): (-1, 1), (6, 30, 3, -5): (1, 1), (6, 30, 3, -4): (1, 1), (6, 30, 3, -3): (1, 1), (6, 30, 3, -2): (1, 1), (6, 30, 3, -1): (1, 0), (6, 30, 3, 0): (1, -1), (6, 30, 3, 1): (1, 1), (6, 30, 3, 2): (1, 0), (6, 30, 3, 3): (1, 0), (6, 30, 3, 4): (1, 0), (6, 30, 3, 5): (1, 0), (6, 30, 4, -5): (0, 1), (6, 30, 4, -4): (0, 1), (6, 30, 4, -3): (0, 1), (6, 30, 4, -2): (0, 1), (6, 30, 4, -1): (0, 0), (6, 30, 4, 0): (0, -1), (6, 30, 4, 1): (0, 1), (6, 30, 4, 2): (0, 1), (6, 30, 4, 3): (0, 1), (6, 30, 4, 4): (0, 1), (6, 30, 4, 5): (0, 1), (6, 30, 5, -5): (0, 1), (6, 30, 5, -4): (0, 1), (6, 30, 5, -3): (0, 1), (6, 30, 5, -2): (0, 1), (6, 30, 5, -1): (0, 0), (6, 30, 5, 0): (-1, -1), (6, 30, 5, 1): (0, 1), (6, 30, 5, 2): (0, 1), (6, 30, 5, 3): (0, 1), (6, 30, 5, 4): (0, 1), (6, 30, 5, 5): (0, 1), (6, 31, -5, -5): (0, 1), (6, 31, -5, -4): (0, 1), (6, 31, -5, -3): (1, 1), (6, 31, -5, -2): (1, 0), (6, 31, -5, -1): (0, 1), (6, 31, -5, 0): (0, 1), (6, 31, -5, 1): (0, 1), (6, 31, -5, 2): (0, 1), (6, 31, -5, 3): (0, 1), (6, 31, -5, 4): (0, 0), (6, 31, -5, 5): (-1, -1), (6, 31, -4, -5): (0, 1), (6, 31, -4, -4): (-1, 1), (6, 31, -4, -3): (0, 1), (6, 31, -4, -2): (0, 1), (6, 31, -4, -1): (0, 1), (6, 31, -4, 0): (-1, 1), (6, 31, -4, 1): (-1, 1), (6, 31, -4, 2): (-1, 1), (6, 31, -4, 3): (-1, 1), (6, 31, -4, 4): (-1, 0), (6, 31, -4, 5): (-1, -1), (6, 31, -3, -5): (0, 1), (6, 31, -3, -4): (0, 1), (6, 31, -3, -3): (-1, 1), (6, 31, -3, -2): (-1, 1), (6, 31, -3, -1): (-1, 1), (6, 31, -3, 0): (0, 1), (6, 31, -3, 1): (0, 1), (6, 31, -3, 2): (0, 0), (6, 31, -3, 3): (-1, -1), (6, 31, -3, 4): (-1, 1), (6, 31, -3, 5): (-1, 1), (6, 31, -2, -5): (0, 1), (6, 31, -2, -4): (0, 1), (6, 31, -2, -3): (0, 1), (6, 31, -2, -2): (-1, 1), (6, 31, -2, -1): (-1, 1), (6, 31, -2, 0): (-1, 1), (6, 31, -2, 1): (-1, 1), (6, 31, -2, 2): (-1, 0), (6, 31, -2, 3): (-1, -1), (6, 31, -2, 4): (0, 0), (6, 31, -2, 5): (-1, -1), (6, 31, -1, -5): (0, 1), (6, 31, -1, -4): (0, 1), (6, 31, -1, -3): (0, 1), (6, 31, -1, -2): (0, 1), (6, 31, -1, -1): (-1, 1), (6, 31, -1, 0): (-1, 1), (6, 31, -1, 1): (-1, 0), (6, 31, -1, 2): (-1, -1), (6, 31, -1, 3): (-1, -1), (6, 31, -1, 4): (-1, 0), (6, 31, -1, 5): (-1, -1), (6, 31, 0, -5): (-1, 1), (6, 31, 0, -4): (-1, 1), (6, 31, 0, -3): (-1, 1), (6, 31, 0, -2): (-1, 1), (6, 31, 0, -1): (0, 1), (6, 31, 0, 0): (-1, 1), (6, 31, 0, 1): (-1, 0), (6, 31, 0, 2): (-1, -1), (6, 31, 0, 3): (-1, -1), (6, 31, 0, 4): (-1, 1), (6, 31, 0, 5): (-1, 1), (6, 31, 1, -5): (1, 1), (6, 31, 1, -4): (1, 1), (6, 31, 1, -3): (1, 1), (6, 31, 1, -2): (0, 1), (6, 31, 1, -1): (-1, 1), (6, 31, 1, 0): (-1, 1), (6, 31, 1, 1): (-1, 0), (6, 31, 1, 2): (-1, -1), (6, 31, 1, 3): (-1, -1), (6, 31, 1, 4): (-1, 1), (6, 31, 1, 5): (-1, 1), (6, 31, 2, -5): (0, 1), (6, 31, 2, -4): (0, 1), (6, 31, 2, -3): (0, 1), (6, 31, 2, -2): (-1, 1), (6, 31, 2, -1): (-1, 1), (6, 31, 2, 0): (-1, 1), (6, 31, 2, 1): (-1, 1), (6, 31, 2, 2): (-1, 1), (6, 31, 2, 3): (-1, 1), (6, 31, 2, 4): (-1, 1), (6, 31, 2, 5): (-1, 1), (6, 31, 3, -5): (1, 1), (6, 31, 3, -4): (1, 1), (6, 31, 3, -3): (1, 1), (6, 31, 3, -2): (1, 0), (6, 31, 3, -1): (1, -1), (6, 31, 3, 0): (1, 1), (6, 31, 3, 1): (1, 0), (6, 31, 3, 2): (1, 0), (6, 31, 3, 3): (1, 0), (6, 31, 3, 4): (-1, 1), (6, 31, 3, 5): (-1, 1), (6, 31, 4, -5): (0, 1), (6, 31, 4, -4): (0, 1), (6, 31, 4, -3): (0, 1), (6, 31, 4, -2): (0, 0), (6, 31, 4, -1): (0, -1), (6, 31, 4, 0): (0, 1), (6, 31, 4, 1): (0, 1), (6, 31, 4, 2): (0, 1), (6, 31, 4, 3): (0, 1), (6, 31, 4, 4): (0, 1), (6, 31, 4, 5): (0, 1), (6, 31, 5, -5): (0, 1), (6, 31, 5, -4): (0, 1), (6, 31, 5, -3): (0, 1), (6, 31, 5, -2): (0, 0), (6, 31, 5, -1): (-1, -1), (6, 31, 5, 0): (0, 1), (6, 31, 5, 1): (0, 1), (6, 31, 5, 2): (0, 1), (6, 31, 5, 3): (0, 1), (6, 31, 5, 4): (0, 1), (6, 31, 5, 5): (0, 1), (6, 32, -5, -5): (0, 1), (6, 32, -5, -4): (1, 1), (6, 32, -5, -3): (1, 0), (6, 32, -5, -2): (0, 1), (6, 32, -5, -1): (0, 1), (6, 32, -5, 0): (0, 1), (6, 32, -5, 1): (0, 1), (6, 32, -5, 2): (0, 1), (6, 32, -5, 3): (0, 0), (6, 32, -5, 4): (-1, -1), (6, 32, -5, 5): (0, 1), (6, 32, -4, -5): (-1, 1), (6, 32, -4, -4): (0, 1), (6, 32, -4, -3): (0, 1), (6, 32, -4, -2): (0, 1), (6, 32, -4, -1): (-1, 1), (6, 32, -4, 0): (-1, 1), (6, 32, -4, 1): (-1, 1), (6, 32, -4, 2): (-1, 1), (6, 32, -4, 3): (-1, 0), (6, 32, -4, 4): (-1, -1), (6, 32, -4, 5): (0, 1), (6, 32, -3, -5): (0, 1), (6, 32, -3, -4): (-1, 1), (6, 32, -3, -3): (-1, 1), (6, 32, -3, -2): (-1, 1), (6, 32, -3, -1): (0, 1), (6, 32, -3, 0): (0, 1), (6, 32, -3, 1): (0, 0), (6, 32, -3, 2): (-1, -1), (6, 32, -3, 3): (-1, 1), (6, 32, -3, 4): (-1, 1), (6, 32, -3, 5): (-1, 1), (6, 32, -2, -5): (0, 1), (6, 32, -2, -4): (0, 1), (6, 32, -2, -3): (-1, 1), (6, 32, -2, -2): (-1, 1), (6, 32, -2, -1): (-1, 1), (6, 32, -2, 0): (-1, 1), (6, 32, -2, 1): (-1, 0), (6, 32, -2, 2): (-1, -1), (6, 32, -2, 3): (-1, -1), (6, 32, -2, 4): (-1, -1), (6, 32, -2, 5): (-1, 1), (6, 32, -1, -5): (0, 1), (6, 32, -1, -4): (0, 1), (6, 32, -1, -3): (0, 1), (6, 32, -1, -2): (-1, 1), (6, 32, -1, -1): (-1, 1), (6, 32, -1, 0): (-1, 1), (6, 32, -1, 1): (-1, 0), (6, 32, -1, 2): (-1, -1), (6, 32, -1, 3): (-1, -1), (6, 32, -1, 4): (-1, -1), (6, 32, -1, 5): (-1, 1), (6, 32, 0, -5): (-1, 1), (6, 32, 0, -4): (-1, 1), (6, 32, 0, -3): (-1, 1), (6, 32, 0, -2): (-1, 1), (6, 32, 0, -1): (-1, 1), (6, 32, 0, 0): (-1, 0), (6, 32, 0, 1): (-1, -1), (6, 32, 0, 2): (-1, -1), (6, 32, 0, 3): (-1, -1), (6, 32, 0, 4): (-1, 1), (6, 32, 0, 5): (-1, 1), (6, 32, 1, -5): (1, 1), (6, 32, 1, -4): (1, 1), (6, 32, 1, -3): (1, 1), (6, 32, 1, -2): (0, 1), (6, 32, 1, -1): (-1, 1), (6, 32, 1, 0): (-1, 1), (6, 32, 1, 1): (-1, 0), (6, 32, 1, 2): (-1, -1), (6, 32, 1, 3): (-1, 1), (6, 32, 1, 4): (-1, 1), (6, 32, 1, 5): (-1, 1), (6, 32, 2, -5): (0, 1), (6, 32, 2, -4): (0, 1), (6, 32, 2, -3): (0, 1), (6, 32, 2, -2): (-1, 1), (6, 32, 2, -1): (-1, 1), (6, 32, 2, 0): (-1, 1), (6, 32, 2, 1): (-1, 1), (6, 32, 2, 2): (-1, 1), (6, 32, 2, 3): (-1, 1), (6, 32, 2, 4): (-1, 1), (6, 32, 2, 5): (-1, 1), (6, 32, 3, -5): (1, 1), (6, 32, 3, -4): (1, 1), (6, 32, 3, -3): (1, 0), (6, 32, 3, -2): (1, -1), (6, 32, 3, -1): (1, 1), (6, 32, 3, 0): (1, 0), (6, 32, 3, 1): (1, 0), (6, 32, 3, 2): (1, 0), (6, 32, 3, 3): (-1, 1), (6, 32, 3, 4): (-1, 1), (6, 32, 3, 5): (-1, 1), (6, 32, 4, -5): (0, 1), (6, 32, 4, -4): (0, 1), (6, 32, 4, -3): (0, 0), (6, 32, 4, -2): (0, -1), (6, 32, 4, -1): (0, 1), (6, 32, 4, 0): (0, 1), (6, 32, 4, 1): (0, 1), (6, 32, 4, 2): (0, 1), (6, 32, 4, 3): (0, 1), (6, 32, 4, 4): (0, 1), (6, 32, 4, 5): (0, 1), (6, 32, 5, -5): (0, 1), (6, 32, 5, -4): (0, 1), (6, 32, 5, -3): (0, 0), (6, 32, 5, -2): (-1, -1), (6, 32, 5, -1): (0, 1), (6, 32, 5, 0): (0, 1), (6, 32, 5, 1): (0, 1), (6, 32, 5, 2): (0, 1), (6, 32, 5, 3): (0, 1), (6, 32, 5, 4): (0, 1), (6, 32, 5, 5): (0, 1), (6, 33, -5, -5): (1, 1), (6, 33, -5, -4): (1, 0), (6, 33, -5, -3): (0, 1), (6, 33, -5, -2): (0, 1), (6, 33, -5, -1): (0, 1), (6, 33, -5, 0): (0, 1), (6, 33, -5, 1): (0, 1), (6, 33, -5, 2): (0, 0), (6, 33, -5, 3): (-1, -1), (6, 33, -5, 4): (0, 1), (6, 33, -5, 5): (0, 1), (6, 33, -4, -5): (0, 1), (6, 33, -4, -4): (0, 1), (6, 33, -4, -3): (0, 1), (6, 33, -4, -2): (-1, 1), (6, 33, -4, -1): (-1, 1), (6, 33, -4, 0): (-1, 1), (6, 33, -4, 1): (-1, 1), (6, 33, -4, 2): (-1, 0), (6, 33, -4, 3): (-1, -1), (6, 33, -4, 4): (0, 1), (6, 33, -4, 5): (0, 1), (6, 33, -3, -5): (-1, 1), (6, 33, -3, -4): (-1, 1), (6, 33, -3, -3): (-1, 1), (6, 33, -3, -2): (0, 1), (6, 33, -3, -1): (0, 1), (6, 33, -3, 0): (0, 1), (6, 33, -3, 1): (0, 0), (6, 33, -3, 2): (-1, -1), (6, 33, -3, 3): (-1, 1), (6, 33, -3, 4): (-1, 1), (6, 33, -3, 5): (-1, 1), (6, 33, -2, -5): (0, 1), (6, 33, -2, -4): (-1, 1), (6, 33, -2, -3): (-1, 1), (6, 33, -2, -2): (0, 1), (6, 33, -2, -1): (-1, 1), (6, 33, -2, 0): (-1, 1), (6, 33, -2, 1): (-1, 0), (6, 33, -2, 2): (-1, -1), (6, 33, -2, 3): (-1, -1), (6, 33, -2, 4): (-1, 1), (6, 33, -2, 5): (-1, 1), (6, 33, -1, -5): (0, 1), (6, 33, -1, -4): (0, 1), (6, 33, -1, -3): (-1, 1), (6, 33, -1, -2): (-1, 1), (6, 33, -1, -1): (-1, 1), (6, 33, -1, 0): (-1, 0), (6, 33, -1, 1): (-1, -1), (6, 33, -1, 2): (-1, -1), (6, 33, -1, 3): (-1, -1), (6, 33, -1, 4): (-1, 1), (6, 33, -1, 5): (-1, 1), (6, 33, 0, -5): (-1, 1), (6, 33, 0, -4): (-1, 1), (6, 33, 0, -3): (-1, 1), (6, 33, 0, -2): (-1, 1), (6, 33, 0, -1): (-1, 1), (6, 33, 0, 0): (-1, 0), (6, 33, 0, 1): (-1, -1), (6, 33, 0, 2): (-1, -1), (6, 33, 0, 3): (-1, 1), (6, 33, 0, 4): (-1, 1), (6, 33, 0, 5): (-1, 1), (6, 33, 1, -5): (1, 1), (6, 33, 1, -4): (1, 1), (6, 33, 1, -3): (1, 1), (6, 33, 1, -2): (-1, 1), (6, 33, 1, -1): (-1, 1), (6, 33, 1, 0): (-1, 1), (6, 33, 1, 1): (-1, 0), (6, 33, 1, 2): (-1, 1), (6, 33, 1, 3): (-1, 1), (6, 33, 1, 4): (-1, 1), (6, 33, 1, 5): (-1, 1), (6, 33, 2, -5): (0, 1), (6, 33, 2, -4): (0, 1), (6, 33, 2, -3): (0, 1), (6, 33, 2, -2): (-1, 1), (6, 33, 2, -1): (-1, 1), (6, 33, 2, 0): (-1, 1), (6, 33, 2, 1): (-1, 1), (6, 33, 2, 2): (-1, 1), (6, 33, 2, 3): (-1, 1), (6, 33, 2, 4): (-1, 1), (6, 33, 2, 5): (-1, 1), (6, 33, 3, -5): (1, 1), (6, 33, 3, -4): (1, 0), (6, 33, 3, -3): (1, -1), (6, 33, 3, -2): (1, 1), (6, 33, 3, -1): (1, 0), (6, 33, 3, 0): (1, 0), (6, 33, 3, 1): (1, 0), (6, 33, 3, 2): (-1, 1), (6, 33, 3, 3): (-1, 1), (6, 33, 3, 4): (-1, 1), (6, 33, 3, 5): (-1, 1), (6, 33, 4, -5): (0, 1), (6, 33, 4, -4): (0, 0), (6, 33, 4, -3): (0, -1), (6, 33, 4, -2): (0, 1), (6, 33, 4, -1): (0, 1), (6, 33, 4, 0): (0, 1), (6, 33, 4, 1): (0, 1), (6, 33, 4, 2): (0, 1), (6, 33, 4, 3): (0, 1), (6, 33, 4, 4): (0, 1), (6, 33, 4, 5): (0, 1), (6, 33, 5, -5): (0, 1), (6, 33, 5, -4): (0, 0), (6, 33, 5, -3): (-1, -1), (6, 33, 5, -2): (0, 1), (6, 33, 5, -1): (0, 1), (6, 33, 5, 0): (0, 1), (6, 33, 5, 1): (0, 1), (6, 33, 5, 2): (0, 1), (6, 33, 5, 3): (0, 1), (6, 33, 5, 4): (0, 1), (6, 33, 5, 5): (0, 1), (6, 34, -5, -5): (1, 0), (6, 34, -5, -4): (0, 1), (6, 34, -5, -3): (0, 1), (6, 34, -5, -2): (0, 1), (6, 34, -5, -1): (0, 1), (6, 34, -5, 0): (0, 1), (6, 34, -5, 1): (0, 0), (6, 34, -5, 2): (-1, -1), (6, 34, -5, 3): (0, 1), (6, 34, -5, 4): (0, 1), (6, 34, -5, 5): (0, 1), (6, 34, -4, -5): (0, 1), (6, 34, -4, -4): (0, 1), (6, 34, -4, -3): (-1, 1), (6, 34, -4, -2): (-1, 1), (6, 34, -4, -1): (-1, 1), (6, 34, -4, 0): (-1, 1), (6, 34, -4, 1): (-1, 0), (6, 34, -4, 2): (-1, -1), (6, 34, -4, 3): (0, 1), (6, 34, -4, 4): (0, 1), (6, 34, -4, 5): (0, 1), (6, 34, -3, -5): (-1, 1), (6, 34, -3, -4): (-1, 1), (6, 34, -3, -3): (-1, 0), (6, 34, -3, -2): (0, 1), (6, 34, -3, -1): (0, 1), (6, 34, -3, 0): (0, 0), (6, 34, -3, 1): (-1, -1), (6, 34, -3, 2): (-1, 1), (6, 34, -3, 3): (-1, 1), (6, 34, -3, 4): (-1, 1), (6, 34, -3, 5): (-1, 1), (6, 34, -2, -5): (-1, 1), (6, 34, -2, -4): (-1, 1), (6, 34, -2, -3): (0, 1), (6, 34, -2, -2): (-1, 1), (6, 34, -2, -1): (-1, 1), (6, 34, -2, 0): (-1, 0), (6, 34, -2, 1): (-1, -1), (6, 34, -2, 2): (-1, -1), (6, 34, -2, 3): (-1, 1), (6, 34, -2, 4): (-1, 1), (6, 34, -2, 5): (-1, 1), (6, 34, -1, -5): (0, 1), (6, 34, -1, -4): (-1, 1), (6, 34, -1, -3): (-1, 1), (6, 34, -1, -2): (-1, 1), (6, 34, -1, -1): (-1, 1), (6, 34, -1, 0): (-1, 0), (6, 34, -1, 1): (-1, -1), (6, 34, -1, 2): (-1, -1), (6, 34, -1, 3): (-1, 1), (6, 34, -1, 4): (-1, 1), (6, 34, -1, 5): (-1, 1), (6, 34, 0, -5): (-1, 1), (6, 34, 0, -4): (-1, 1), (6, 34, 0, -3): (-1, 0), (6, 34, 0, -2): (-1, 1), (6, 34, 0, -1): (-1, 1), (6, 34, 0, 0): (-1, 0), (6, 34, 0, 1): (-1, -1), (6, 34, 0, 2): (-1, -1), (6, 34, 0, 3): (-1, 1), (6, 34, 0, 4): (-1, 1), (6, 34, 0, 5): (-1, 1), (6, 34, 1, -5): (1, 1), (6, 34, 1, -4): (1, 1), (6, 34, 1, -3): (-1, 1), (6, 34, 1, -2): (-1, 1), (6, 34, 1, -1): (-1, 1), (6, 34, 1, 0): (-1, 1), (6, 34, 1, 1): (-1, 1), (6, 34, 1, 2): (-1, 1), (6, 34, 1, 3): (-1, 1), (6, 34, 1, 4): (-1, 1), (6, 34, 1, 5): (-1, 1), (6, 34, 2, -5): (0, 1), (6, 34, 2, -4): (0, 1), (6, 34, 2, -3): (-1, 1), (6, 34, 2, -2): (-1, 1), (6, 34, 2, -1): (-1, 1), (6, 34, 2, 0): (-1, 1), (6, 34, 2, 1): (-1, 1), (6, 34, 2, 2): (-1, 1), (6, 34, 2, 3): (-1, 1), (6, 34, 2, 4): (-1, 1), (6, 34, 2, 5): (-1, 1), (6, 34, 3, -5): (1, 0), (6, 34, 3, -4): (1, -1), (6, 34, 3, -3): (1, 1), (6, 34, 3, -2): (1, 0), (6, 34, 3, -1): (1, 0), (6, 34, 3, 0): (1, 0), (6, 34, 3, 1): (-1, 1), (6, 34, 3, 2): (-1, 1), (6, 34, 3, 3): (-1, 1), (6, 34, 3, 4): (-1, 1), (6, 34, 3, 5): (-1, 1), (6, 34, 4, -5): (0, 0), (6, 34, 4, -4): (0, -1), (6, 34, 4, -3): (0, 1), (6, 34, 4, -2): (0, 1), (6, 34, 4, -1): (0, 1), (6, 34, 4, 0): (0, 1), (6, 34, 4, 1): (0, 1), (6, 34, 4, 2): (0, 1), (6, 34, 4, 3): (0, 1), (6, 34, 4, 4): (0, 1), (6, 34, 4, 5): (0, 1), (6, 34, 5, -5): (0, 0), (6, 34, 5, -4): (-1, -1), (6, 34, 5, -3): (0, 1), (6, 34, 5, -2): (0, 1), (6, 34, 5, -1): (0, 1), (6, 34, 5, 0): (0, 1), (6, 34, 5, 1): (0, 1), (6, 34, 5, 2): (0, 1), (6, 34, 5, 3): (0, 1), (6, 34, 5, 4): (0, 1), (6, 34, 5, 5): (0, 1), (6, 35, -5, -5): (0, 1), (6, 35, -5, -4): (0, 1), (6, 35, -5, -3): (0, 1), (6, 35, -5, -2): (0, 1), (6, 35, -5, -1): (0, 1), (6, 35, -5, 0): (0, 0), (6, 35, -5, 1): (-1, -1), (6, 35, -5, 2): (0, 1), (6, 35, -5, 3): (0, 1), (6, 35, -5, 4): (0, 1), (6, 35, -5, 5): (0, 1), (6, 35, -4, -5): (0, 1), (6, 35, -4, -4): (-1, 1), (6, 35, -4, -3): (-1, 1), (6, 35, -4, -2): (-1, 1), (6, 35, -4, -1): (-1, 1), (6, 35, -4, 0): (-1, 0), (6, 35, -4, 1): (-1, -1), (6, 35, -4, 2): (0, 1), (6, 35, -4, 3): (0, 1), (6, 35, -4, 4): (0, 1), (6, 35, -4, 5): (0, 1), (6, 35, -3, -5): (-1, 1), (6, 35, -3, -4): (-1, 0), (6, 35, -3, -3): (0, 1), (6, 35, -3, -2): (0, 1), (6, 35, -3, -1): (0, 1), (6, 35, -3, 0): (0, 0), (6, 35, -3, 1): (-1, -1), (6, 35, -3, 2): (-1, 1), (6, 35, -3, 3): (-1, 1), (6, 35, -3, 4): (-1, 1), (6, 35, -3, 5): (-1, 1), (6, 35, -2, -5): (-1, 1), (6, 35, -2, -4): (0, 1), (6, 35, -2, -3): (0, 1), (6, 35, -2, -2): (-1, 1), (6, 35, -2, -1): (-1, 1), (6, 35, -2, 0): (-1, 0), (6, 35, -2, 1): (-1, -1), (6, 35, -2, 2): (-1, 1), (6, 35, -2, 3): (-1, 1), (6, 35, -2, 4): (-1, 1), (6, 35, -2, 5): (-1, 1), (6, 35, -1, -5): (-1, 1), (6, 35, -1, -4): (-1, 1), (6, 35, -1, -3): (-1, 1), (6, 35, -1, -2): (-1, 1), (6, 35, -1, -1): (-1, 1), (6, 35, -1, 0): (-1, 0), (6, 35, -1, 1): (-1, -1), (6, 35, -1, 2): (-1, 1), (6, 35, -1, 3): (-1, 1), (6, 35, -1, 4): (-1, 1), (6, 35, -1, 5): (-1, 1), (6, 35, 0, -5): (-1, 1), (6, 35, 0, -4): (-1, 0), (6, 35, 0, -3): (-1, 1), (6, 35, 0, -2): (-1, 1), (6, 35, 0, -1): (-1, 1), (6, 35, 0, 0): (-1, 0), (6, 35, 0, 1): (-1, -1), (6, 35, 0, 2): (-1, 1), (6, 35, 0, 3): (-1, 1), (6, 35, 0, 4): (-1, 1), (6, 35, 0, 5): (-1, 1), (6, 35, 1, -5): (1, 1), (6, 35, 1, -4): (1, 1), (6, 35, 1, -3): (-1, 1), (6, 35, 1, -2): (-1, 1), (6, 35, 1, -1): (-1, 1), (6, 35, 1, 0): (-1, 1), (6, 35, 1, 1): (-1, 1), (6, 35, 1, 2): (-1, 1), (6, 35, 1, 3): (-1, 1), (6, 35, 1, 4): (-1, 1), (6, 35, 1, 5): (-1, 1), (6, 35, 2, -5): (0, 1), (6, 35, 2, -4): (0, 1), (6, 35, 2, -3): (-1, 1), (6, 35, 2, -2): (-1, 1), (6, 35, 2, -1): (-1, 1), (6, 35, 2, 0): (-1, 1), (6, 35, 2, 1): (-1, 1), (6, 35, 2, 2): (-1, 1), (6, 35, 2, 3): (-1, 1), (6, 35, 2, 4): (-1, 1), (6, 35, 2, 5): (-1, 1), (6, 35, 3, -5): (1, 0), (6, 35, 3, -4): (1, 1), (6, 35, 3, -3): (1, 0), (6, 35, 3, -2): (1, 0), (6, 35, 3, -1): (1, 0), (6, 35, 3, 0): (-1, 1), (6, 35, 3, 1): (-1, 1), (6, 35, 3, 2): (-1, 1), (6, 35, 3, 3): (-1, 1), (6, 35, 3, 4): (-1, 1), (6, 35, 3, 5): (-1, 1), (6, 35, 4, -5): (0, 0), (6, 35, 4, -4): (0, 1), (6, 35, 4, -3): (0, 1), (6, 35, 4, -2): (0, 1), (6, 35, 4, -1): (0, 1), (6, 35, 4, 0): (0, 1), (6, 35, 4, 1): (0, 1), (6, 35, 4, 2): (0, 1), (6, 35, 4, 3): (0, 1), (6, 35, 4, 4): (0, 1), (6, 35, 4, 5): (0, 1), (6, 35, 5, -5): (0, 0), (6, 35, 5, -4): (0, 1), (6, 35, 5, -3): (0, 1), (6, 35, 5, -2): (0, 1), (6, 35, 5, -1): (0, 1), (6, 35, 5, 0): (0, 1), (6, 35, 5, 1): (0, 1), (6, 35, 5, 2): (0, 1), (6, 35, 5, 3): (0, 1), (6, 35, 5, 4): (0, 1), (6, 35, 5, 5): (0, 1), (7, 1, -5, -5): (0, 1), (7, 1, -5, -4): (0, 1), (7, 1, -5, -3): (0, 1), (7, 1, -5, -2): (0, 1), (7, 1, -5, -1): (0, 0), (7, 1, -5, 0): (-1, -1), (7, 1, -5, 1): (0, 1), (7, 1, -5, 2): (0, 1), (7, 1, -5, 3): (0, 1), (7, 1, -5, 4): (0, 1), (7, 1, -5, 5): (0, 1), (7, 1, -4, -5): (-1, 1), (7, 1, -4, -4): (-1, 1), (7, 1, -4, -3): (-1, 1), (7, 1, -4, -2): (-1, 1), (7, 1, -4, -1): (-1, 0), (7, 1, -4, 0): (-1, -1), (7, 1, -4, 1): (0, 1), (7, 1, -4, 2): (0, 1), (7, 1, -4, 3): (0, 1), (7, 1, -4, 4): (0, 1), (7, 1, -4, 5): (0, 1), (7, 1, -3, -5): (-1, 1), (7, 1, -3, -4): (-1, 1), (7, 1, -3, -3): (-1, 1), (7, 1, -3, -2): (-1, 1), (7, 1, -3, -1): (-1, 0), (7, 1, -3, 0): (-1, -1), (7, 1, -3, 1): (0, 1), (7, 1, -3, 2): (0, 1), (7, 1, -3, 3): (0, 1), (7, 1, -3, 4): (0, 1), (7, 1, -3, 5): (0, 1), (7, 1, -2, -5): (-1, 1), (7, 1, -2, -4): (-1, 1), (7, 1, -2, -3): (-1, 1), (7, 1, -2, -2): (-1, 1), (7, 1, -2, -1): (-1, 0), (7, 1, -2, 0): (1, 1), (7, 1, -2, 1): (1, 1), (7, 1, -2, 2): (1, 1), (7, 1, -2, 3): (1, 1), (7, 1, -2, 4): (1, 1), (7, 1, -2, 5): (1, 0), (7, 1, -1, -5): (0, 1), (7, 1, -1, -4): (0, 1), (7, 1, -1, -3): (0, 1), (7, 1, -1, -2): (0, 1), (7, 1, -1, -1): (-1, 1), (7, 1, -1, 0): (1, 1), (7, 1, -1, 1): (1, 1), (7, 1, -1, 2): (1, 1), (7, 1, -1, 3): (1, 1), (7, 1, -1, 4): (1, 1), (7, 1, -1, 5): (1, 0), (7, 1, 0, -5): (1, 0), (7, 1, 0, -4): (1, 0), (7, 1, 0, -3): (1, 0), (7, 1, 0, -2): (1, 0), (7, 1, 0, -1): (1, 1), (7, 1, 0, 0): (1, 1), (7, 1, 0, 1): (0, 1), (7, 1, 0, 2): (1, 1), (7, 1, 0, 3): (0, 1), (7, 1, 0, 4): (0, 1), (7, 1, 0, 5): (0, 1), (7, 1, 1, -5): (1, 0), (7, 1, 1, -4): (1, 0), (7, 1, 1, -3): (1, 0), (7, 1, 1, -2): (1, 0), (7, 1, 1, -1): (1, 0), (7, 1, 1, 0): (0, 1), (7, 1, 1, 1): (-1, 1), (7, 1, 1, 2): (0, 1), (7, 1, 1, 3): (-1, 1), (7, 1, 1, 4): (-1, 1), (7, 1, 1, 5): (-1, 1), (7, 1, 2, -5): (0, 1), (7, 1, 2, -4): (0, 1), (7, 1, 2, -3): (0, 1), (7, 1, 2, -2): (0, 1), (7, 1, 2, -1): (0, 0), (7, 1, 2, 0): (-1, 1), (7, 1, 2, 1): (-1, 1), (7, 1, 2, 2): (-1, 1), (7, 1, 2, 3): (-1, 1), (7, 1, 2, 4): (-1, 1), (7, 1, 2, 5): (-1, 1), (7, 1, 3, -5): (0, 1), (7, 1, 3, -4): (0, 1), (7, 1, 3, -3): (0, 1), (7, 1, 3, -2): (0, 1), (7, 1, 3, -1): (0, 1), (7, 1, 3, 0): (0, 1), (7, 1, 3, 1): (0, 1), (7, 1, 3, 2): (0, 1), (7, 1, 3, 3): (-1, 1), (7, 1, 3, 4): (-1, 1), (7, 1, 3, 5): (-1, 1), (7, 1, 4, -5): (0, 1), (7, 1, 4, -4): (0, 1), (7, 1, 4, -3): (0, 1), (7, 1, 4, -2): (0, 1), (7, 1, 4, -1): (0, 1), (7, 1, 4, 0): (0, 1), (7, 1, 4, 1): (0, 1), (7, 1, 4, 2): (0, 1), (7, 1, 4, 3): (0, 1), (7, 1, 4, 4): (0, 1), (7, 1, 4, 5): (0, 1), (7, 1, 5, -5): (0, 1), (7, 1, 5, -4): (0, 1), (7, 1, 5, -3): (0, 1), (7, 1, 5, -2): (0, 1), (7, 1, 5, -1): (0, 1), (7, 1, 5, 0): (0, 1), (7, 1, 5, 1): (0, 1), (7, 1, 5, 2): (0, 1), (7, 1, 5, 3): (0, 1), (7, 1, 5, 4): (0, 1), (7, 1, 5, 5): (0, 1), (7, 2, -5, -5): (0, 1), (7, 2, -5, -4): (0, 1), (7, 2, -5, -3): (0, 1), (7, 2, -5, -2): (0, 0), (7, 2, -5, -1): (-1, -1), (7, 2, -5, 0): (0, 1), (7, 2, -5, 1): (0, 1), (7, 2, -5, 2): (0, 1), (7, 2, -5, 3): (0, 1), (7, 2, -5, 4): (0, 1), (7, 2, -5, 5): (0, 1), (7, 2, -4, -5): (-1, 1), (7, 2, -4, -4): (-1, 1), (7, 2, -4, -3): (-1, 1), (7, 2, -4, -2): (-1, 0), (7, 2, -4, -1): (-1, -1), (7, 2, -4, 0): (0, 1), (7, 2, -4, 1): (0, 1), (7, 2, -4, 2): (0, 1), (7, 2, -4, 3): (0, 1), (7, 2, -4, 4): (0, 1), (7, 2, -4, 5): (0, 1), (7, 2, -3, -5): (-1, 1), (7, 2, -3, -4): (-1, 1), (7, 2, -3, -3): (-1, 1), (7, 2, -3, -2): (-1, 0), (7, 2, -3, -1): (-1, -1), (7, 2, -3, 0): (0, 1), (7, 2, -3, 1): (0, 1), (7, 2, -3, 2): (0, 1), (7, 2, -3, 3): (0, 1), (7, 2, -3, 4): (0, 1), (7, 2, -3, 5): (0, 1), (7, 2, -2, -5): (-1, 1), (7, 2, -2, -4): (-1, 1), (7, 2, -2, -3): (-1, 1), (7, 2, -2, -2): (-1, 0), (7, 2, -2, -1): (0, 1), (7, 2, -2, 0): (1, 1), (7, 2, -2, 1): (1, 1), (7, 2, -2, 2): (1, 1), (7, 2, -2, 3): (1, 1), (7, 2, -2, 4): (1, 1), (7, 2, -2, 5): (1, 0), (7, 2, -1, -5): (0, 1), (7, 2, -1, -4): (0, 1), (7, 2, -1, -3): (0, 1), (7, 2, -1, -2): (-1, 1), (7, 2, -1, -1): (1, 1), (7, 2, -1, 0): (1, 1), (7, 2, -1, 1): (1, 1), (7, 2, -1, 2): (1, 1), (7, 2, -1, 3): (1, 1), (7, 2, -1, 4): (1, 1), (7, 2, -1, 5): (1, 0), (7, 2, 0, -5): (1, 0), (7, 2, 0, -4): (1, 0), (7, 2, 0, -3): (1, 0), (7, 2, 0, -2): (1, 0), (7, 2, 0, -1): (1, 1), (7, 2, 0, 0): (1, 1), (7, 2, 0, 1): (1, 1), (7, 2, 0, 2): (0, 1), (7, 2, 0, 3): (0, 1), (7, 2, 0, 4): (1, 1), (7, 2, 0, 5): (1, 0), (7, 2, 1, -5): (1, 0), (7, 2, 1, -4): (1, 0), (7, 2, 1, -3): (1, 0), (7, 2, 1, -2): (1, 0), (7, 2, 1, -1): (0, 1), (7, 2, 1, 0): (0, 1), (7, 2, 1, 1): (0, 1), (7, 2, 1, 2): (-1, 1), (7, 2, 1, 3): (-1, 1), (7, 2, 1, 4): (0, 1), (7, 2, 1, 5): (0, 1), (7, 2, 2, -5): (0, 1), (7, 2, 2, -4): (0, 1), (7, 2, 2, -3): (0, 1), (7, 2, 2, -2): (0, 0), (7, 2, 2, -1): (1, 1), (7, 2, 2, 0): (-1, 1), (7, 2, 2, 1): (-1, 1), (7, 2, 2, 2): (-1, 1), (7, 2, 2, 3): (-1, 1), (7, 2, 2, 4): (-1, 1), (7, 2, 2, 5): (-1, 1), (7, 2, 3, -5): (0, 1), (7, 2, 3, -4): (0, 1), (7, 2, 3, -3): (0, 1), (7, 2, 3, -2): (0, 1), (7, 2, 3, -1): (0, 1), (7, 2, 3, 0): (0, 1), (7, 2, 3, 1): (0, 1), (7, 2, 3, 2): (0, 1), (7, 2, 3, 3): (-1, 1), (7, 2, 3, 4): (-1, 1), (7, 2, 3, 5): (-1, 1), (7, 2, 4, -5): (0, 1), (7, 2, 4, -4): (0, 1), (7, 2, 4, -3): (0, 1), (7, 2, 4, -2): (0, 1), (7, 2, 4, -1): (0, 1), (7, 2, 4, 0): (0, 1), (7, 2, 4, 1): (0, 1), (7, 2, 4, 2): (0, 1), (7, 2, 4, 3): (0, 1), (7, 2, 4, 4): (0, 1), (7, 2, 4, 5): (0, 1), (7, 2, 5, -5): (0, 1), (7, 2, 5, -4): (0, 1), (7, 2, 5, -3): (0, 1), (7, 2, 5, -2): (0, 1), (7, 2, 5, -1): (0, 1), (7, 2, 5, 0): (0, 1), (7, 2, 5, 1): (0, 1), (7, 2, 5, 2): (0, 1), (7, 2, 5, 3): (0, 1), (7, 2, 5, 4): (0, 1), (7, 2, 5, 5): (0, 1), (7, 3, -5, -5): (0, 1), (7, 3, -5, -4): (0, 1), (7, 3, -5, -3): (0, 0), (7, 3, -5, -2): (-1, -1), (7, 3, -5, -1): (0, 1), (7, 3, -5, 0): (0, 1), (7, 3, -5, 1): (0, 1), (7, 3, -5, 2): (0, 1), (7, 3, -5, 3): (0, 1), (7, 3, -5, 4): (0, 1), (7, 3, -5, 5): (0, 1), (7, 3, -4, -5): (-1, 1), (7, 3, -4, -4): (-1, 1), (7, 3, -4, -3): (-1, 0), (7, 3, -4, -2): (-1, -1), (7, 3, -4, -1): (0, 1), (7, 3, -4, 0): (0, 1), (7, 3, -4, 1): (0, 1), (7, 3, -4, 2): (0, 1), (7, 3, -4, 3): (0, 1), (7, 3, -4, 4): (0, 1), (7, 3, -4, 5): (0, 1), (7, 3, -3, -5): (-1, 1), (7, 3, -3, -4): (-1, 1), (7, 3, -3, -3): (-1, 0), (7, 3, -3, -2): (-1, -1), (7, 3, -3, -1): (0, 1), (7, 3, -3, 0): (0, 1), (7, 3, -3, 1): (0, 1), (7, 3, -3, 2): (0, 1), (7, 3, -3, 3): (0, 1), (7, 3, -3, 4): (0, 1), (7, 3, -3, 5): (0, 1), (7, 3, -2, -5): (-1, 1), (7, 3, -2, -4): (-1, 1), (7, 3, -2, -3): (-1, 0), (7, 3, -2, -2): (0, 1), (7, 3, -2, -1): (0, 1), (7, 3, -2, 0): (1, 1), (7, 3, -2, 1): (1, 1), (7, 3, -2, 2): (1, 1), (7, 3, -2, 3): (1, 1), (7, 3, -2, 4): (1, 1), (7, 3, -2, 5): (1, 0), (7, 3, -1, -5): (0, 1), (7, 3, -1, -4): (0, 1), (7, 3, -1, -3): (-1, 1), (7, 3, -1, -2): (-1, 1), (7, 3, -1, -1): (1, 1), (7, 3, -1, 0): (1, 1), (7, 3, -1, 1): (1, 1), (7, 3, -1, 2): (1, 1), (7, 3, -1, 3): (1, 1), (7, 3, -1, 4): (1, 1), (7, 3, -1, 5): (1, 0), (7, 3, 0, -5): (1, 0), (7, 3, 0, -4): (1, 0), (7, 3, 0, -3): (1, 0), (7, 3, 0, -2): (1, -1), (7, 3, 0, -1): (1, 1), (7, 3, 0, 0): (1, 1), (7, 3, 0, 1): (1, 1), (7, 3, 0, 2): (1, 1), (7, 3, 0, 3): (1, 1), (7, 3, 0, 4): (1, 1), (7, 3, 0, 5): (1, 0), (7, 3, 1, -5): (1, 0), (7, 3, 1, -4): (1, 0), (7, 3, 1, -3): (1, 0), (7, 3, 1, -2): (1, -1), (7, 3, 1, -1): (0, 1), (7, 3, 1, 0): (0, 1), (7, 3, 1, 1): (0, 1), (7, 3, 1, 2): (0, 1), (7, 3, 1, 3): (0, 1), (7, 3, 1, 4): (0, 1), (7, 3, 1, 5): (0, 1), (7, 3, 2, -5): (0, 1), (7, 3, 2, -4): (0, 1), (7, 3, 2, -3): (0, 0), (7, 3, 2, -2): (1, 1), (7, 3, 2, -1): (1, 1), (7, 3, 2, 0): (-1, 1), (7, 3, 2, 1): (-1, 1), (7, 3, 2, 2): (-1, 1), (7, 3, 2, 3): (-1, 1), (7, 3, 2, 4): (-1, 1), (7, 3, 2, 5): (-1, 1), (7, 3, 3, -5): (0, 1), (7, 3, 3, -4): (0, 1), (7, 3, 3, -3): (0, 1), (7, 3, 3, -2): (0, 1), (7, 3, 3, -1): (0, 1), (7, 3, 3, 0): (0, 1), (7, 3, 3, 1): (0, 1), (7, 3, 3, 2): (0, 1), (7, 3, 3, 3): (-1, 1), (7, 3, 3, 4): (-1, 1), (7, 3, 3, 5): (-1, 1), (7, 3, 4, -5): (0, 1), (7, 3, 4, -4): (0, 1), (7, 3, 4, -3): (0, 1), (7, 3, 4, -2): (0, 1), (7, 3, 4, -1): (0, 1), (7, 3, 4, 0): (0, 1), (7, 3, 4, 1): (0, 1), (7, 3, 4, 2): (0, 1), (7, 3, 4, 3): (0, 1), (7, 3, 4, 4): (0, 1), (7, 3, 4, 5): (0, 1), (7, 3, 5, -5): (0, 1), (7, 3, 5, -4): (0, 1), (7, 3, 5, -3): (0, 1), (7, 3, 5, -2): (0, 1), (7, 3, 5, -1): (0, 1), (7, 3, 5, 0): (0, 1), (7, 3, 5, 1): (0, 1), (7, 3, 5, 2): (0, 1), (7, 3, 5, 3): (0, 1), (7, 3, 5, 4): (0, 1), (7, 3, 5, 5): (0, 1), (7, 4, -5, -5): (0, 1), (7, 4, -5, -4): (0, 0), (7, 4, -5, -3): (-1, -1), (7, 4, -5, -2): (0, 1), (7, 4, -5, -1): (0, 1), (7, 4, -5, 0): (0, 1), (7, 4, -5, 1): (0, 1), (7, 4, -5, 2): (0, 1), (7, 4, -5, 3): (0, 1), (7, 4, -5, 4): (0, 1), (7, 4, -5, 5): (0, 1), (7, 4, -4, -5): (-1, 1), (7, 4, -4, -4): (-1, 0), (7, 4, -4, -3): (-1, -1), (7, 4, -4, -2): (0, 1), (7, 4, -4, -1): (0, 1), (7, 4, -4, 0): (0, 1), (7, 4, -4, 1): (0, 1), (7, 4, -4, 2): (0, 1), (7, 4, -4, 3): (0, 1), (7, 4, -4, 4): (0, 1), (7, 4, -4, 5): (0, 1), (7, 4, -3, -5): (-1, 1), (7, 4, -3, -4): (-1, 0), (7, 4, -3, -3): (-1, -1), (7, 4, -3, -2): (0, 1), (7, 4, -3, -1): (0, 1), (7, 4, -3, 0): (0, 1), (7, 4, -3, 1): (0, 1), (7, 4, -3, 2): (0, 1), (7, 4, -3, 3): (0, 1), (7, 4, -3, 4): (0, 1), (7, 4, -3, 5): (0, 1), (7, 4, -2, -5): (-1, 1), (7, 4, -2, -4): (-1, 0), (7, 4, -2, -3): (0, 1), (7, 4, -2, -2): (0, 1), (7, 4, -2, -1): (0, 1), (7, 4, -2, 0): (1, 1), (7, 4, -2, 1): (1, 1), (7, 4, -2, 2): (1, 1), (7, 4, -2, 3): (1, 1), (7, 4, -2, 4): (1, 1), (7, 4, -2, 5): (1, 0), (7, 4, -1, -5): (0, 1), (7, 4, -1, -4): (-1, 1), (7, 4, -1, -3): (-1, 1), (7, 4, -1, -2): (-1, 1), (7, 4, -1, -1): (1, 1), (7, 4, -1, 0): (1, 1), (7, 4, -1, 1): (1, 1), (7, 4, -1, 2): (1, 1), (7, 4, -1, 3): (1, 1), (7, 4, -1, 4): (1, 1), (7, 4, -1, 5): (1, 0), (7, 4, 0, -5): (1, 0), (7, 4, 0, -4): (1, 0), (7, 4, 0, -3): (1, -1), (7, 4, 0, -2): (-1, 1), (7, 4, 0, -1): (1, 1), (7, 4, 0, 0): (1, 1), (7, 4, 0, 1): (1, 1), (7, 4, 0, 2): (0, 1), (7, 4, 0, 3): (1, 1), (7, 4, 0, 4): (0, 1), (7, 4, 0, 5): (0, 1), (7, 4, 1, -5): (1, 0), (7, 4, 1, -4): (1, 0), (7, 4, 1, -3): (1, -1), (7, 4, 1, -2): (1, 1), (7, 4, 1, -1): (0, 1), (7, 4, 1, 0): (0, 1), (7, 4, 1, 1): (0, 1), (7, 4, 1, 2): (-1, 1), (7, 4, 1, 3): (0, 1), (7, 4, 1, 4): (-1, 1), (7, 4, 1, 5): (-1, 1), (7, 4, 2, -5): (0, 1), (7, 4, 2, -4): (0, 0), (7, 4, 2, -3): (1, 1), (7, 4, 2, -2): (1, 1), (7, 4, 2, -1): (1, 1), (7, 4, 2, 0): (-1, 1), (7, 4, 2, 1): (-1, 1), (7, 4, 2, 2): (-1, 1), (7, 4, 2, 3): (-1, 1), (7, 4, 2, 4): (-1, 1), (7, 4, 2, 5): (-1, 1), (7, 4, 3, -5): (0, 1), (7, 4, 3, -4): (0, 1), (7, 4, 3, -3): (0, 1), (7, 4, 3, -2): (0, 1), (7, 4, 3, -1): (0, 1), (7, 4, 3, 0): (0, 1), (7, 4, 3, 1): (0, 1), (7, 4, 3, 2): (0, 1), (7, 4, 3, 3): (-1, 1), (7, 4, 3, 4): (-1, 1), (7, 4, 3, 5): (-1, 1), (7, 4, 4, -5): (0, 1), (7, 4, 4, -4): (0, 1), (7, 4, 4, -3): (0, 1), (7, 4, 4, -2): (0, 1), (7, 4, 4, -1): (0, 1), (7, 4, 4, 0): (0, 1), (7, 4, 4, 1): (0, 1), (7, 4, 4, 2): (0, 1), (7, 4, 4, 3): (0, 1), (7, 4, 4, 4): (0, 1), (7, 4, 4, 5): (0, 1), (7, 4, 5, -5): (0, 1), (7, 4, 5, -4): (0, 1), (7, 4, 5, -3): (0, 1), (7, 4, 5, -2): (0, 1), (7, 4, 5, -1): (0, 1), (7, 4, 5, 0): (0, 1), (7, 4, 5, 1): (0, 1), (7, 4, 5, 2): (0, 1), (7, 4, 5, 3): (0, 1), (7, 4, 5, 4): (0, 1), (7, 4, 5, 5): (0, 1), (7, 5, -5, -5): (0, 0), (7, 5, -5, -4): (-1, -1), (7, 5, -5, -3): (0, 1), (7, 5, -5, -2): (0, 1), (7, 5, -5, -1): (0, 1), (7, 5, -5, 0): (0, 1), (7, 5, -5, 1): (0, 1), (7, 5, -5, 2): (0, 1), (7, 5, -5, 3): (0, 1), (7, 5, -5, 4): (0, 1), (7, 5, -5, 5): (0, 1), (7, 5, -4, -5): (-1, 0), (7, 5, -4, -4): (-1, -1), (7, 5, -4, -3): (0, 1), (7, 5, -4, -2): (0, 1), (7, 5, -4, -1): (0, 1), (7, 5, -4, 0): (0, 1), (7, 5, -4, 1): (0, 1), (7, 5, -4, 2): (0, 1), (7, 5, -4, 3): (0, 1), (7, 5, -4, 4): (0, 1), (7, 5, -4, 5): (0, 1), (7, 5, -3, -5): (-1, 0), (7, 5, -3, -4): (-1, -1), (7, 5, -3, -3): (0, 1), (7, 5, -3, -2): (0, 1), (7, 5, -3, -1): (0, 1), (7, 5, -3, 0): (0, 1), (7, 5, -3, 1): (0, 1), (7, 5, -3, 2): (0, 1), (7, 5, -3, 3): (0, 1), (7, 5, -3, 4): (0, 1), (7, 5, -3, 5): (0, 1), (7, 5, -2, -5): (-1, 0), (7, 5, -2, -4): (0, 1), (7, 5, -2, -3): (0, 1), (7, 5, -2, -2): (0, 1), (7, 5, -2, -1): (0, 1), (7, 5, -2, 0): (1, 1), (7, 5, -2, 1): (1, 1), (7, 5, -2, 2): (1, 1), (7, 5, -2, 3): (1, 1), (7, 5, -2, 4): (1, 1), (7, 5, -2, 5): (1, 0), (7, 5, -1, -5): (-1, 1), (7, 5, -1, -4): (-1, 1), (7, 5, -1, -3): (-1, 1), (7, 5, -1, -2): (-1, 1), (7, 5, -1, -1): (1, 1), (7, 5, -1, 0): (1, 1), (7, 5, -1, 1): (1, 1), (7, 5, -1, 2): (1, 1), (7, 5, -1, 3): (1, 1), (7, 5, -1, 4): (1, 1), (7, 5, -1, 5): (1, 0), (7, 5, 0, -5): (1, 0), (7, 5, 0, -4): (1, -1), (7, 5, 0, -3): (-1, 1), (7, 5, 0, -2): (-1, 1), (7, 5, 0, -1): (1, 1), (7, 5, 0, 0): (1, 1), (7, 5, 0, 1): (1, 1), (7, 5, 0, 2): (1, 1), (7, 5, 0, 3): (0, 1), (7, 5, 0, 4): (0, 1), (7, 5, 0, 5): (0, 1), (7, 5, 1, -5): (1, 0), (7, 5, 1, -4): (1, -1), (7, 5, 1, -3): (1, 1), (7, 5, 1, -2): (1, 1), (7, 5, 1, -1): (0, 1), (7, 5, 1, 0): (0, 1), (7, 5, 1, 1): (0, 1), (7, 5, 1, 2): (0, 1), (7, 5, 1, 3): (-1, 1), (7, 5, 1, 4): (-1, 1), (7, 5, 1, 5): (-1, 1), (7, 5, 2, -5): (0, 0), (7, 5, 2, -4): (1, 1), (7, 5, 2, -3): (1, 1), (7, 5, 2, -2): (1, 1), (7, 5, 2, -1): (1, 1), (7, 5, 2, 0): (-1, 1), (7, 5, 2, 1): (-1, 1), (7, 5, 2, 2): (-1, 1), (7, 5, 2, 3): (-1, 1), (7, 5, 2, 4): (-1, 1), (7, 5, 2, 5): (-1, 1), (7, 5, 3, -5): (0, 1), (7, 5, 3, -4): (0, 1), (7, 5, 3, -3): (0, 1), (7, 5, 3, -2): (0, 1), (7, 5, 3, -1): (0, 1), (7, 5, 3, 0): (0, 1), (7, 5, 3, 1): (0, 1), (7, 5, 3, 2): (0, 1), (7, 5, 3, 3): (-1, 1), (7, 5, 3, 4): (0, 1), (7, 5, 3, 5): (0, 1), (7, 5, 4, -5): (0, 1), (7, 5, 4, -4): (0, 1), (7, 5, 4, -3): (0, 1), (7, 5, 4, -2): (0, 1), (7, 5, 4, -1): (0, 1), (7, 5, 4, 0): (0, 1), (7, 5, 4, 1): (0, 1), (7, 5, 4, 2): (0, 1), (7, 5, 4, 3): (0, 1), (7, 5, 4, 4): (0, 1), (7, 5, 4, 5): (0, 1), (7, 5, 5, -5): (0, 1), (7, 5, 5, -4): (0, 1), (7, 5, 5, -3): (0, 1), (7, 5, 5, -2): (0, 1), (7, 5, 5, -1): (0, 1), (7, 5, 5, 0): (0, 1), (7, 5, 5, 1): (0, 1), (7, 5, 5, 2): (0, 1), (7, 5, 5, 3): (0, 1), (7, 5, 5, 4): (0, 1), (7, 5, 5, 5): (0, 1), (7, 6, -5, -5): (0, 1), (7, 6, -5, -4): (0, 1), (7, 6, -5, -3): (0, 1), (7, 6, -5, -2): (0, 1), (7, 6, -5, -1): (0, 1), (7, 6, -5, 0): (0, 1), (7, 6, -5, 1): (0, 1), (7, 6, -5, 2): (0, 1), (7, 6, -5, 3): (0, 1), (7, 6, -5, 4): (0, 1), (7, 6, -5, 5): (0, 1), (7, 6, -4, -5): (0, 1), (7, 6, -4, -4): (0, 1), (7, 6, -4, -3): (0, 1), (7, 6, -4, -2): (0, 1), (7, 6, -4, -1): (0, 1), (7, 6, -4, 0): (0, 1), (7, 6, -4, 1): (0, 1), (7, 6, -4, 2): (0, 1), (7, 6, -4, 3): (0, 1), (7, 6, -4, 4): (0, 1), (7, 6, -4, 5): (0, 1), (7, 6, -3, -5): (0, 1), (7, 6, -3, -4): (0, 1), (7, 6, -3, -3): (0, 1), (7, 6, -3, -2): (0, 1), (7, 6, -3, -1): (0, 1), (7, 6, -3, 0): (0, 1), (7, 6, -3, 1): (0, 1), (7, 6, -3, 2): (0, 1), (7, 6, -3, 3): (0, 1), (7, 6, -3, 4): (0, 1), (7, 6, -3, 5): (0, 1), (7, 6, -2, -5): (0, 1), (7, 6, -2, -4): (0, 1), (7, 6, -2, -3): (0, 1), (7, 6, -2, -2): (0, 1), (7, 6, -2, -1): (0, 1), (7, 6, -2, 0): (1, 1), (7, 6, -2, 1): (1, 1), (7, 6, -2, 2): (1, 1), (7, 6, -2, 3): (1, 1), (7, 6, -2, 4): (1, 1), (7, 6, -2, 5): (1, 0), (7, 6, -1, -5): (-1, 1), (7, 6, -1, -4): (-1, 1), (7, 6, -1, -3): (-1, 1), (7, 6, -1, -2): (-1, 1), (7, 6, -1, -1): (1, 1), (7, 6, -1, 0): (1, 1), (7, 6, -1, 1): (1, 1), (7, 6, -1, 2): (1, 1), (7, 6, -1, 3): (1, 1), (7, 6, -1, 4): (1, 1), (7, 6, -1, 5): (1, 0), (7, 6, 0, -5): (-1, 1), (7, 6, 0, -4): (-1, 1), (7, 6, 0, -3): (-1, 1), (7, 6, 0, -2): (1, 1), (7, 6, 0, -1): (1, 1), (7, 6, 0, 0): (1, 1), (7, 6, 0, 1): (1, 1), (7, 6, 0, 2): (1, 1), (7, 6, 0, 3): (0, 1), (7, 6, 0, 4): (0, 1), (7, 6, 0, 5): (0, 1), (7, 6, 1, -5): (0, 1), (7, 6, 1, -4): (0, 1), (7, 6, 1, -3): (1, 1), (7, 6, 1, -2): (1, 1), (7, 6, 1, -1): (0, 1), (7, 6, 1, 0): (0, 1), (7, 6, 1, 1): (0, 1), (7, 6, 1, 2): (0, 1), (7, 6, 1, 3): (-1, 1), (7, 6, 1, 4): (-1, 1), (7, 6, 1, 5): (-1, 1), (7, 6, 2, -5): (1, 1), (7, 6, 2, -4): (1, 1), (7, 6, 2, -3): (1, 1), (7, 6, 2, -2): (1, 1), (7, 6, 2, -1): (1, 1), (7, 6, 2, 0): (-1, 1), (7, 6, 2, 1): (-1, 1), (7, 6, 2, 2): (-1, 1), (7, 6, 2, 3): (-1, 1), (7, 6, 2, 4): (-1, 1), (7, 6, 2, 5): (-1, 1), (7, 6, 3, -5): (0, 1), (7, 6, 3, -4): (0, 1), (7, 6, 3, -3): (0, 1), (7, 6, 3, -2): (0, 1), (7, 6, 3, -1): (0, 1), (7, 6, 3, 0): (0, 1), (7, 6, 3, 1): (0, 1), (7, 6, 3, 2): (0, 1), (7, 6, 3, 3): (0, 1), (7, 6, 3, 4): (-1, 1), (7, 6, 3, 5): (-1, 1), (7, 6, 4, -5): (0, 1), (7, 6, 4, -4): (0, 1), (7, 6, 4, -3): (0, 1), (7, 6, 4, -2): (0, 1), (7, 6, 4, -1): (0, 1), (7, 6, 4, 0): (0, 1), (7, 6, 4, 1): (0, 1), (7, 6, 4, 2): (0, 1), (7, 6, 4, 3): (0, 1), (7, 6, 4, 4): (0, 1), (7, 6, 4, 5): (0, 1), (7, 6, 5, -5): (0, 1), (7, 6, 5, -4): (0, 1), (7, 6, 5, -3): (0, 1), (7, 6, 5, -2): (0, 1), (7, 6, 5, -1): (0, 1), (7, 6, 5, 0): (0, 1), (7, 6, 5, 1): (0, 1), (7, 6, 5, 2): (0, 1), (7, 6, 5, 3): (0, 1), (7, 6, 5, 4): (0, 1), (7, 6, 5, 5): (0, 1), (7, 7, -5, -5): (0, 1), (7, 7, -5, -4): (0, 1), (7, 7, -5, -3): (0, 1), (7, 7, -5, -2): (0, 1), (7, 7, -5, -1): (0, 1), (7, 7, -5, 0): (0, 1), (7, 7, -5, 1): (0, 1), (7, 7, -5, 2): (0, 1), (7, 7, -5, 3): (0, 1), (7, 7, -5, 4): (0, 1), (7, 7, -5, 5): (0, 1), (7, 7, -4, -5): (0, 1), (7, 7, -4, -4): (0, 1), (7, 7, -4, -3): (0, 1), (7, 7, -4, -2): (0, 1), (7, 7, -4, -1): (0, 1), (7, 7, -4, 0): (0, 1), (7, 7, -4, 1): (0, 1), (7, 7, -4, 2): (0, 1), (7, 7, -4, 3): (0, 1), (7, 7, -4, 4): (0, 1), (7, 7, -4, 5): (0, 1), (7, 7, -3, -5): (0, 1), (7, 7, -3, -4): (0, 1), (7, 7, -3, -3): (0, 1), (7, 7, -3, -2): (0, 1), (7, 7, -3, -1): (0, 1), (7, 7, -3, 0): (0, 1), (7, 7, -3, 1): (0, 1), (7, 7, -3, 2): (0, 1), (7, 7, -3, 3): (0, 1), (7, 7, -3, 4): (0, 1), (7, 7, -3, 5): (0, 1), (7, 7, -2, -5): (0, 1), (7, 7, -2, -4): (0, 1), (7, 7, -2, -3): (0, 1), (7, 7, -2, -2): (0, 1), (7, 7, -2, -1): (0, 1), (7, 7, -2, 0): (1, 1), (7, 7, -2, 1): (1, 1), (7, 7, -2, 2): (1, 1), (7, 7, -2, 3): (1, 1), (7, 7, -2, 4): (1, 1), (7, 7, -2, 5): (1, 0), (7, 7, -1, -5): (-1, 1), (7, 7, -1, -4): (-1, 1), (7, 7, -1, -3): (-1, 1), (7, 7, -1, -2): (-1, 1), (7, 7, -1, -1): (1, 1), (7, 7, -1, 0): (1, 1), (7, 7, -1, 1): (1, 1), (7, 7, -1, 2): (1, 1), (7, 7, -1, 3): (1, 1), (7, 7, -1, 4): (1, 1), (7, 7, -1, 5): (1, 0), (7, 7, 0, -5): (-1, 1), (7, 7, 0, -4): (-1, 1), (7, 7, 0, -3): (-1, 1), (7, 7, 0, -2): (-1, 1), (7, 7, 0, -1): (1, 1), (7, 7, 0, 0): (1, 1), (7, 7, 0, 1): (0, 1), (7, 7, 0, 2): (1, 1), (7, 7, 0, 3): (0, 1), (7, 7, 0, 4): (1, 1), (7, 7, 0, 5): (1, 0), (7, 7, 1, -5): (0, 1), (7, 7, 1, -4): (1, 1), (7, 7, 1, -3): (1, 1), (7, 7, 1, -2): (1, 1), (7, 7, 1, -1): (0, 1), (7, 7, 1, 0): (0, 1), (7, 7, 1, 1): (-1, 1), (7, 7, 1, 2): (0, 1), (7, 7, 1, 3): (-1, 1), (7, 7, 1, 4): (0, 1), (7, 7, 1, 5): (0, 1), (7, 7, 2, -5): (1, 1), (7, 7, 2, -4): (1, 1), (7, 7, 2, -3): (1, 1), (7, 7, 2, -2): (1, 1), (7, 7, 2, -1): (1, 1), (7, 7, 2, 0): (-1, 1), (7, 7, 2, 1): (-1, 1), (7, 7, 2, 2): (-1, 1), (7, 7, 2, 3): (-1, 1), (7, 7, 2, 4): (-1, 1), (7, 7, 2, 5): (-1, 1), (7, 7, 3, -5): (0, 1), (7, 7, 3, -4): (0, 1), (7, 7, 3, -3): (0, 1), (7, 7, 3, -2): (0, 1), (7, 7, 3, -1): (0, 1), (7, 7, 3, 0): (0, 1), (7, 7, 3, 1): (0, 1), (7, 7, 3, 2): (0, 1), (7, 7, 3, 3): (0, 1), (7, 7, 3, 4): (-1, 1), (7, 7, 3, 5): (-1, 1), (7, 7, 4, -5): (0, 1), (7, 7, 4, -4): (0, 1), (7, 7, 4, -3): (0, 1), (7, 7, 4, -2): (0, 1), (7, 7, 4, -1): (0, 1), (7, 7, 4, 0): (0, 1), (7, 7, 4, 1): (0, 1), (7, 7, 4, 2): (0, 1), (7, 7, 4, 3): (0, 1), (7, 7, 4, 4): (0, 1), (7, 7, 4, 5): (0, 1), (7, 7, 5, -5): (0, 1), (7, 7, 5, -4): (0, 1), (7, 7, 5, -3): (0, 1), (7, 7, 5, -2): (0, 1), (7, 7, 5, -1): (0, 1), (7, 7, 5, 0): (0, 1), (7, 7, 5, 1): (0, 1), (7, 7, 5, 2): (0, 1), (7, 7, 5, 3): (0, 1), (7, 7, 5, 4): (0, 1), (7, 7, 5, 5): (0, 1), (7, 8, -5, -5): (0, 1), (7, 8, -5, -4): (0, 1), (7, 8, -5, -3): (0, 1), (7, 8, -5, -2): (0, 1), (7, 8, -5, -1): (0, 1), (7, 8, -5, 0): (0, 1), (7, 8, -5, 1): (0, 1), (7, 8, -5, 2): (0, 1), (7, 8, -5, 3): (0, 1), (7, 8, -5, 4): (0, 1), (7, 8, -5, 5): (0, 1), (7, 8, -4, -5): (0, 1), (7, 8, -4, -4): (0, 1), (7, 8, -4, -3): (0, 1), (7, 8, -4, -2): (0, 1), (7, 8, -4, -1): (0, 1), (7, 8, -4, 0): (0, 1), (7, 8, -4, 1): (0, 1), (7, 8, -4, 2): (0, 1), (7, 8, -4, 3): (0, 1), (7, 8, -4, 4): (0, 1), (7, 8, -4, 5): (0, 1), (7, 8, -3, -5): (0, 1), (7, 8, -3, -4): (0, 1), (7, 8, -3, -3): (0, 1), (7, 8, -3, -2): (0, 1), (7, 8, -3, -1): (0, 1), (7, 8, -3, 0): (0, 1), (7, 8, -3, 1): (0, 1), (7, 8, -3, 2): (0, 1), (7, 8, -3, 3): (0, 1), (7, 8, -3, 4): (0, 1), (7, 8, -3, 5): (0, 1), (7, 8, -2, -5): (0, 1), (7, 8, -2, -4): (0, 1), (7, 8, -2, -3): (0, 1), (7, 8, -2, -2): (0, 1), (7, 8, -2, -1): (0, 1), (7, 8, -2, 0): (1, 1), (7, 8, -2, 1): (1, 1), (7, 8, -2, 2): (1, 1), (7, 8, -2, 3): (1, 1), (7, 8, -2, 4): (1, 1), (7, 8, -2, 5): (1, 0), (7, 8, -1, -5): (-1, 1), (7, 8, -1, -4): (-1, 1), (7, 8, -1, -3): (-1, 1), (7, 8, -1, -2): (-1, 1), (7, 8, -1, -1): (1, 1), (7, 8, -1, 0): (1, 1), (7, 8, -1, 1): (1, 1), (7, 8, -1, 2): (1, 1), (7, 8, -1, 3): (1, 1), (7, 8, -1, 4): (1, 1), (7, 8, -1, 5): (1, 0), (7, 8, 0, -5): (-1, 1), (7, 8, 0, -4): (-1, 1), (7, 8, 0, -3): (-1, 1), (7, 8, 0, -2): (-1, 1), (7, 8, 0, -1): (1, 1), (7, 8, 0, 0): (1, 1), (7, 8, 0, 1): (1, 1), (7, 8, 0, 2): (0, 1), (7, 8, 0, 3): (1, 1), (7, 8, 0, 4): (0, 1), (7, 8, 0, 5): (0, 1), (7, 8, 1, -5): (0, 1), (7, 8, 1, -4): (1, 1), (7, 8, 1, -3): (1, 1), (7, 8, 1, -2): (1, 1), (7, 8, 1, -1): (0, 1), (7, 8, 1, 0): (0, 1), (7, 8, 1, 1): (0, 1), (7, 8, 1, 2): (-1, 1), (7, 8, 1, 3): (0, 1), (7, 8, 1, 4): (-1, 1), (7, 8, 1, 5): (-1, 1), (7, 8, 2, -5): (1, 1), (7, 8, 2, -4): (1, 1), (7, 8, 2, -3): (1, 1), (7, 8, 2, -2): (1, 1), (7, 8, 2, -1): (1, 1), (7, 8, 2, 0): (-1, 1), (7, 8, 2, 1): (-1, 1), (7, 8, 2, 2): (-1, 1), (7, 8, 2, 3): (-1, 1), (7, 8, 2, 4): (-1, 1), (7, 8, 2, 5): (-1, 1), (7, 8, 3, -5): (0, 1), (7, 8, 3, -4): (0, 1), (7, 8, 3, -3): (0, 1), (7, 8, 3, -2): (0, 1), (7, 8, 3, -1): (0, 1), (7, 8, 3, 0): (0, 1), (7, 8, 3, 1): (0, 1), (7, 8, 3, 2): (0, 1), (7, 8, 3, 3): (-1, 1), (7, 8, 3, 4): (-1, 1), (7, 8, 3, 5): (-1, 1), (7, 8, 4, -5): (0, 1), (7, 8, 4, -4): (0, 1), (7, 8, 4, -3): (0, 1), (7, 8, 4, -2): (0, 1), (7, 8, 4, -1): (0, 1), (7, 8, 4, 0): (0, 1), (7, 8, 4, 1): (0, 1), (7, 8, 4, 2): (0, 1), (7, 8, 4, 3): (0, 1), (7, 8, 4, 4): (0, 1), (7, 8, 4, 5): (0, 1), (7, 8, 5, -5): (0, 1), (7, 8, 5, -4): (0, 1), (7, 8, 5, -3): (0, 1), (7, 8, 5, -2): (0, 1), (7, 8, 5, -1): (0, 1), (7, 8, 5, 0): (0, 1), (7, 8, 5, 1): (0, 1), (7, 8, 5, 2): (0, 1), (7, 8, 5, 3): (0, 1), (7, 8, 5, 4): (0, 1), (7, 8, 5, 5): (0, 1), (7, 9, -5, -5): (0, 1), (7, 9, -5, -4): (0, 1), (7, 9, -5, -3): (0, 1), (7, 9, -5, -2): (0, 1), (7, 9, -5, -1): (0, 1), (7, 9, -5, 0): (0, 1), (7, 9, -5, 1): (0, 1), (7, 9, -5, 2): (0, 1), (7, 9, -5, 3): (0, 1), (7, 9, -5, 4): (0, 1), (7, 9, -5, 5): (0, 1), (7, 9, -4, -5): (0, 1), (7, 9, -4, -4): (0, 1), (7, 9, -4, -3): (0, 1), (7, 9, -4, -2): (0, 1), (7, 9, -4, -1): (0, 1), (7, 9, -4, 0): (0, 1), (7, 9, -4, 1): (0, 1), (7, 9, -4, 2): (0, 1), (7, 9, -4, 3): (0, 1), (7, 9, -4, 4): (0, 1), (7, 9, -4, 5): (0, 1), (7, 9, -3, -5): (0, 1), (7, 9, -3, -4): (0, 1), (7, 9, -3, -3): (0, 1), (7, 9, -3, -2): (0, 1), (7, 9, -3, -1): (0, 1), (7, 9, -3, 0): (0, 1), (7, 9, -3, 1): (0, 1), (7, 9, -3, 2): (0, 1), (7, 9, -3, 3): (0, 1), (7, 9, -3, 4): (0, 1), (7, 9, -3, 5): (0, 1), (7, 9, -2, -5): (0, 1), (7, 9, -2, -4): (0, 1), (7, 9, -2, -3): (0, 1), (7, 9, -2, -2): (0, 1), (7, 9, -2, -1): (0, 1), (7, 9, -2, 0): (1, 1), (7, 9, -2, 1): (1, 1), (7, 9, -2, 2): (1, 1), (7, 9, -2, 3): (1, 1), (7, 9, -2, 4): (1, 1), (7, 9, -2, 5): (1, 0), (7, 9, -1, -5): (-1, 1), (7, 9, -1, -4): (-1, 1), (7, 9, -1, -3): (-1, 1), (7, 9, -1, -2): (-1, 1), (7, 9, -1, -1): (-1, 1), (7, 9, -1, 0): (1, 1), (7, 9, -1, 1): (1, 1), (7, 9, -1, 2): (1, 1), (7, 9, -1, 3): (1, 1), (7, 9, -1, 4): (1, 1), (7, 9, -1, 5): (1, 0), (7, 9, 0, -5): (-1, 1), (7, 9, 0, -4): (-1, 1), (7, 9, 0, -3): (-1, 1), (7, 9, 0, -2): (-1, 1), (7, 9, 0, -1): (1, 1), (7, 9, 0, 0): (0, 1), (7, 9, 0, 1): (1, 1), (7, 9, 0, 2): (1, 1), (7, 9, 0, 3): (1, 1), (7, 9, 0, 4): (0, 1), (7, 9, 0, 5): (0, 1), (7, 9, 1, -5): (1, 1), (7, 9, 1, -4): (1, 1), (7, 9, 1, -3): (1, 1), (7, 9, 1, -2): (1, 1), (7, 9, 1, -1): (0, 1), (7, 9, 1, 0): (-1, 1), (7, 9, 1, 1): (0, 1), (7, 9, 1, 2): (0, 1), (7, 9, 1, 3): (0, 1), (7, 9, 1, 4): (-1, 1), (7, 9, 1, 5): (-1, 1), (7, 9, 2, -5): (1, 1), (7, 9, 2, -4): (1, 1), (7, 9, 2, -3): (1, 1), (7, 9, 2, -2): (1, 1), (7, 9, 2, -1): (1, 1), (7, 9, 2, 0): (-1, 1), (7, 9, 2, 1): (-1, 1), (7, 9, 2, 2): (-1, 1), (7, 9, 2, 3): (-1, 1), (7, 9, 2, 4): (-1, 1), (7, 9, 2, 5): (-1, 1), (7, 9, 3, -5): (0, 1), (7, 9, 3, -4): (0, 1), (7, 9, 3, -3): (0, 1), (7, 9, 3, -2): (0, 1), (7, 9, 3, -1): (0, 1), (7, 9, 3, 0): (0, 1), (7, 9, 3, 1): (0, 1), (7, 9, 3, 2): (0, 1), (7, 9, 3, 3): (-1, 1), (7, 9, 3, 4): (-1, 1), (7, 9, 3, 5): (-1, 1), (7, 9, 4, -5): (0, 1), (7, 9, 4, -4): (0, 1), (7, 9, 4, -3): (0, 1), (7, 9, 4, -2): (0, 1), (7, 9, 4, -1): (0, 1), (7, 9, 4, 0): (0, 1), (7, 9, 4, 1): (0, 1), (7, 9, 4, 2): (0, 1), (7, 9, 4, 3): (0, 1), (7, 9, 4, 4): (0, 1), (7, 9, 4, 5): (0, 1), (7, 9, 5, -5): (0, 1), (7, 9, 5, -4): (0, 1), (7, 9, 5, -3): (0, 1), (7, 9, 5, -2): (0, 1), (7, 9, 5, -1): (0, 1), (7, 9, 5, 0): (0, 1), (7, 9, 5, 1): (0, 1), (7, 9, 5, 2): (0, 1), (7, 9, 5, 3): (0, 1), (7, 9, 5, 4): (0, 1), (7, 9, 5, 5): (0, 1), (7, 10, -5, -5): (0, 1), (7, 10, -5, -4): (0, 1), (7, 10, -5, -3): (0, 1), (7, 10, -5, -2): (0, 1), (7, 10, -5, -1): (0, 1), (7, 10, -5, 0): (0, 1), (7, 10, -5, 1): (0, 1), (7, 10, -5, 2): (0, 1), (7, 10, -5, 3): (0, 1), (7, 10, -5, 4): (0, 1), (7, 10, -5, 5): (0, 1), (7, 10, -4, -5): (0, 1), (7, 10, -4, -4): (0, 1), (7, 10, -4, -3): (0, 1), (7, 10, -4, -2): (0, 1), (7, 10, -4, -1): (0, 1), (7, 10, -4, 0): (0, 1), (7, 10, -4, 1): (0, 1), (7, 10, -4, 2): (0, 1), (7, 10, -4, 3): (0, 1), (7, 10, -4, 4): (0, 1), (7, 10, -4, 5): (0, 1), (7, 10, -3, -5): (0, 1), (7, 10, -3, -4): (0, 1), (7, 10, -3, -3): (0, 1), (7, 10, -3, -2): (0, 1), (7, 10, -3, -1): (0, 1), (7, 10, -3, 0): (0, 1), (7, 10, -3, 1): (0, 1), (7, 10, -3, 2): (0, 1), (7, 10, -3, 3): (0, 1), (7, 10, -3, 4): (0, 1), (7, 10, -3, 5): (0, 1), (7, 10, -2, -5): (0, 1), (7, 10, -2, -4): (0, 1), (7, 10, -2, -3): (0, 1), (7, 10, -2, -2): (0, 1), (7, 10, -2, -1): (0, 1), (7, 10, -2, 0): (1, 1), (7, 10, -2, 1): (1, 1), (7, 10, -2, 2): (1, 1), (7, 10, -2, 3): (1, 1), (7, 10, -2, 4): (1, 1), (7, 10, -2, 5): (1, 0), (7, 10, -1, -5): (-1, 1), (7, 10, -1, -4): (-1, 1), (7, 10, -1, -3): (-1, 1), (7, 10, -1, -2): (-1, 1), (7, 10, -1, -1): (1, 1), (7, 10, -1, 0): (1, 1), (7, 10, -1, 1): (1, 1), (7, 10, -1, 2): (1, 1), (7, 10, -1, 3): (1, 1), (7, 10, -1, 4): (1, 1), (7, 10, -1, 5): (1, 0), (7, 10, 0, -5): (-1, 1), (7, 10, 0, -4): (-1, 1), (7, 10, 0, -3): (-1, 1), (7, 10, 0, -2): (-1, 1), (7, 10, 0, -1): (1, 1), (7, 10, 0, 0): (1, 1), (7, 10, 0, 1): (0, 1), (7, 10, 0, 2): (1, 1), (7, 10, 0, 3): (0, 1), (7, 10, 0, 4): (0, 1), (7, 10, 0, 5): (0, 1), (7, 10, 1, -5): (1, 1), (7, 10, 1, -4): (1, 1), (7, 10, 1, -3): (1, 1), (7, 10, 1, -2): (1, 1), (7, 10, 1, -1): (0, 1), (7, 10, 1, 0): (0, 1), (7, 10, 1, 1): (-1, 1), (7, 10, 1, 2): (0, 1), (7, 10, 1, 3): (-1, 1), (7, 10, 1, 4): (-1, 1), (7, 10, 1, 5): (-1, 1), (7, 10, 2, -5): (1, 1), (7, 10, 2, -4): (1, 1), (7, 10, 2, -3): (1, 1), (7, 10, 2, -2): (1, 1), (7, 10, 2, -1): (1, 1), (7, 10, 2, 0): (-1, 1), (7, 10, 2, 1): (-1, 1), (7, 10, 2, 2): (-1, 1), (7, 10, 2, 3): (-1, 1), (7, 10, 2, 4): (-1, 0), (7, 10, 2, 5): (-1, -1), (7, 10, 3, -5): (0, 1), (7, 10, 3, -4): (0, 1), (7, 10, 3, -3): (0, 1), (7, 10, 3, -2): (0, 1), (7, 10, 3, -1): (0, 1), (7, 10, 3, 0): (0, 1), (7, 10, 3, 1): (0, 1), (7, 10, 3, 2): (0, 1), (7, 10, 3, 3): (-1, 1), (7, 10, 3, 4): (-1, 1), (7, 10, 3, 5): (-1, 1), (7, 10, 4, -5): (0, 1), (7, 10, 4, -4): (0, 1), (7, 10, 4, -3): (0, 1), (7, 10, 4, -2): (0, 1), (7, 10, 4, -1): (0, 1), (7, 10, 4, 0): (0, 1), (7, 10, 4, 1): (0, 1), (7, 10, 4, 2): (0, 1), (7, 10, 4, 3): (0, 1), (7, 10, 4, 4): (0, 1), (7, 10, 4, 5): (0, 1), (7, 10, 5, -5): (0, 1), (7, 10, 5, -4): (0, 1), (7, 10, 5, -3): (0, 1), (7, 10, 5, -2): (0, 1), (7, 10, 5, -1): (0, 1), (7, 10, 5, 0): (0, 1), (7, 10, 5, 1): (0, 1), (7, 10, 5, 2): (0, 1), (7, 10, 5, 3): (0, 1), (7, 10, 5, 4): (0, 1), (7, 10, 5, 5): (0, 1), (7, 11, -5, -5): (0, 1), (7, 11, -5, -4): (0, 1), (7, 11, -5, -3): (0, 1), (7, 11, -5, -2): (0, 1), (7, 11, -5, -1): (0, 1), (7, 11, -5, 0): (0, 1), (7, 11, -5, 1): (0, 1), (7, 11, -5, 2): (0, 1), (7, 11, -5, 3): (0, 1), (7, 11, -5, 4): (0, 1), (7, 11, -5, 5): (0, 1), (7, 11, -4, -5): (0, 1), (7, 11, -4, -4): (0, 1), (7, 11, -4, -3): (0, 1), (7, 11, -4, -2): (0, 1), (7, 11, -4, -1): (0, 1), (7, 11, -4, 0): (0, 1), (7, 11, -4, 1): (0, 1), (7, 11, -4, 2): (0, 1), (7, 11, -4, 3): (0, 1), (7, 11, -4, 4): (0, 1), (7, 11, -4, 5): (0, 1), (7, 11, -3, -5): (0, 1), (7, 11, -3, -4): (0, 1), (7, 11, -3, -3): (0, 1), (7, 11, -3, -2): (0, 1), (7, 11, -3, -1): (0, 1), (7, 11, -3, 0): (0, 1), (7, 11, -3, 1): (0, 1), (7, 11, -3, 2): (0, 1), (7, 11, -3, 3): (0, 1), (7, 11, -3, 4): (0, 1), (7, 11, -3, 5): (0, 1), (7, 11, -2, -5): (0, 1), (7, 11, -2, -4): (0, 1), (7, 11, -2, -3): (0, 1), (7, 11, -2, -2): (0, 1), (7, 11, -2, -1): (0, 1), (7, 11, -2, 0): (1, 1), (7, 11, -2, 1): (1, 1), (7, 11, -2, 2): (1, 1), (7, 11, -2, 3): (1, 1), (7, 11, -2, 4): (1, 1), (7, 11, -2, 5): (1, 0), (7, 11, -1, -5): (-1, 1), (7, 11, -1, -4): (-1, 1), (7, 11, -1, -3): (-1, 1), (7, 11, -1, -2): (-1, 1), (7, 11, -1, -1): (0, 1), (7, 11, -1, 0): (1, 1), (7, 11, -1, 1): (1, 1), (7, 11, -1, 2): (1, 1), (7, 11, -1, 3): (1, 1), (7, 11, -1, 4): (1, 1), (7, 11, -1, 5): (1, 0), (7, 11, 0, -5): (-1, 1), (7, 11, 0, -4): (-1, 1), (7, 11, 0, -3): (-1, 1), (7, 11, 0, -2): (1, 1), (7, 11, 0, -1): (1, 1), (7, 11, 0, 0): (0, 1), (7, 11, 0, 1): (1, 1), (7, 11, 0, 2): (1, 1), (7, 11, 0, 3): (0, 1), (7, 11, 0, 4): (0, 1), (7, 11, 0, 5): (0, 1), (7, 11, 1, -5): (1, 1), (7, 11, 1, -4): (1, 1), (7, 11, 1, -3): (1, 1), (7, 11, 1, -2): (1, 1), (7, 11, 1, -1): (0, 1), (7, 11, 1, 0): (-1, 1), (7, 11, 1, 1): (0, 1), (7, 11, 1, 2): (0, 1), (7, 11, 1, 3): (-1, 1), (7, 11, 1, 4): (-1, 1), (7, 11, 1, 5): (-1, 1), (7, 11, 2, -5): (1, 1), (7, 11, 2, -4): (1, 1), (7, 11, 2, -3): (1, 1), (7, 11, 2, -2): (1, 1), (7, 11, 2, -1): (1, 1), (7, 11, 2, 0): (-1, 1), (7, 11, 2, 1): (-1, 1), (7, 11, 2, 2): (-1, 1), (7, 11, 2, 3): (-1, 1), (7, 11, 2, 4): (-1, 1), (7, 11, 2, 5): (-1, 1), (7, 11, 3, -5): (0, 1), (7, 11, 3, -4): (0, 1), (7, 11, 3, -3): (0, 1), (7, 11, 3, -2): (0, 1), (7, 11, 3, -1): (0, 1), (7, 11, 3, 0): (0, 1), (7, 11, 3, 1): (0, 1), (7, 11, 3, 2): (-1, 1), (7, 11, 3, 3): (-1, 1), (7, 11, 3, 4): (-1, 1), (7, 11, 3, 5): (-1, 1), (7, 11, 4, -5): (0, 1), (7, 11, 4, -4): (0, 1), (7, 11, 4, -3): (0, 1), (7, 11, 4, -2): (0, 1), (7, 11, 4, -1): (0, 1), (7, 11, 4, 0): (0, 1), (7, 11, 4, 1): (0, 1), (7, 11, 4, 2): (0, 1), (7, 11, 4, 3): (0, 1), (7, 11, 4, 4): (0, 1), (7, 11, 4, 5): (0, 1), (7, 11, 5, -5): (0, 1), (7, 11, 5, -4): (0, 1), (7, 11, 5, -3): (0, 1), (7, 11, 5, -2): (0, 1), (7, 11, 5, -1): (0, 1), (7, 11, 5, 0): (0, 1), (7, 11, 5, 1): (0, 1), (7, 11, 5, 2): (0, 1), (7, 11, 5, 3): (0, 1), (7, 11, 5, 4): (0, 1), (7, 11, 5, 5): (0, 1), (7, 12, -5, -5): (0, 1), (7, 12, -5, -4): (0, 1), (7, 12, -5, -3): (0, 1), (7, 12, -5, -2): (0, 1), (7, 12, -5, -1): (0, 1), (7, 12, -5, 0): (0, 1), (7, 12, -5, 1): (0, 1), (7, 12, -5, 2): (0, 1), (7, 12, -5, 3): (0, 1), (7, 12, -5, 4): (0, 1), (7, 12, -5, 5): (0, 1), (7, 12, -4, -5): (0, 1), (7, 12, -4, -4): (0, 1), (7, 12, -4, -3): (0, 1), (7, 12, -4, -2): (0, 1), (7, 12, -4, -1): (0, 1), (7, 12, -4, 0): (0, 1), (7, 12, -4, 1): (0, 1), (7, 12, -4, 2): (0, 1), (7, 12, -4, 3): (0, 1), (7, 12, -4, 4): (0, 1), (7, 12, -4, 5): (0, 1), (7, 12, -3, -5): (0, 1), (7, 12, -3, -4): (0, 1), (7, 12, -3, -3): (0, 1), (7, 12, -3, -2): (0, 1), (7, 12, -3, -1): (0, 1), (7, 12, -3, 0): (0, 1), (7, 12, -3, 1): (0, 1), (7, 12, -3, 2): (0, 1), (7, 12, -3, 3): (0, 1), (7, 12, -3, 4): (0, 1), (7, 12, -3, 5): (0, 1), (7, 12, -2, -5): (0, 1), (7, 12, -2, -4): (0, 1), (7, 12, -2, -3): (0, 1), (7, 12, -2, -2): (0, 1), (7, 12, -2, -1): (0, 1), (7, 12, -2, 0): (1, 1), (7, 12, -2, 1): (1, 1), (7, 12, -2, 2): (1, 1), (7, 12, -2, 3): (1, 1), (7, 12, -2, 4): (1, 1), (7, 12, -2, 5): (1, 0), (7, 12, -1, -5): (-1, 1), (7, 12, -1, -4): (-1, 1), (7, 12, -1, -3): (-1, 1), (7, 12, -1, -2): (-1, 1), (7, 12, -1, -1): (1, 1), (7, 12, -1, 0): (1, 1), (7, 12, -1, 1): (1, 1), (7, 12, -1, 2): (1, 1), (7, 12, -1, 3): (1, 1), (7, 12, -1, 4): (1, 1), (7, 12, -1, 5): (1, 0), (7, 12, 0, -5): (-1, 1), (7, 12, 0, -4): (-1, 1), (7, 12, 0, -3): (-1, 1), (7, 12, 0, -2): (1, 1), (7, 12, 0, -1): (1, 1), (7, 12, 0, 0): (1, 1), (7, 12, 0, 1): (0, 1), (7, 12, 0, 2): (0, 1), (7, 12, 0, 3): (0, 1), (7, 12, 0, 4): (0, 1), (7, 12, 0, 5): (0, 1), (7, 12, 1, -5): (1, 1), (7, 12, 1, -4): (1, 1), (7, 12, 1, -3): (1, 1), (7, 12, 1, -2): (1, 1), (7, 12, 1, -1): (0, 1), (7, 12, 1, 0): (0, 1), (7, 12, 1, 1): (-1, 1), (7, 12, 1, 2): (-1, 1), (7, 12, 1, 3): (-1, 1), (7, 12, 1, 4): (-1, 1), (7, 12, 1, 5): (-1, 1), (7, 12, 2, -5): (1, 1), (7, 12, 2, -4): (1, 1), (7, 12, 2, -3): (1, 1), (7, 12, 2, -2): (1, 1), (7, 12, 2, -1): (1, 1), (7, 12, 2, 0): (-1, 1), (7, 12, 2, 1): (-1, 1), (7, 12, 2, 2): (-1, 1), (7, 12, 2, 3): (-1, 1), (7, 12, 2, 4): (-1, 1), (7, 12, 2, 5): (-1, 1), (7, 12, 3, -5): (0, 1), (7, 12, 3, -4): (0, 1), (7, 12, 3, -3): (0, 1), (7, 12, 3, -2): (0, 1), (7, 12, 3, -1): (0, 1), (7, 12, 3, 0): (0, 1), (7, 12, 3, 1): (0, 1), (7, 12, 3, 2): (-1, 1), (7, 12, 3, 3): (-1, 1), (7, 12, 3, 4): (-1, 1), (7, 12, 3, 5): (-1, 1), (7, 12, 4, -5): (0, 1), (7, 12, 4, -4): (0, 1), (7, 12, 4, -3): (0, 1), (7, 12, 4, -2): (0, 1), (7, 12, 4, -1): (0, 1), (7, 12, 4, 0): (0, 1), (7, 12, 4, 1): (0, 1), (7, 12, 4, 2): (0, 1), (7, 12, 4, 3): (0, 1), (7, 12, 4, 4): (0, 1), (7, 12, 4, 5): (0, 1), (7, 12, 5, -5): (0, 1), (7, 12, 5, -4): (0, 1), (7, 12, 5, -3): (0, 1), (7, 12, 5, -2): (0, 1), (7, 12, 5, -1): (0, 1), (7, 12, 5, 0): (0, 1), (7, 12, 5, 1): (0, 1), (7, 12, 5, 2): (0, 1), (7, 12, 5, 3): (0, 1), (7, 12, 5, 4): (0, 1), (7, 12, 5, 5): (0, 1), (7, 13, -5, -5): (0, 1), (7, 13, -5, -4): (0, 1), (7, 13, -5, -3): (0, 1), (7, 13, -5, -2): (0, 1), (7, 13, -5, -1): (0, 1), (7, 13, -5, 0): (0, 1), (7, 13, -5, 1): (0, 1), (7, 13, -5, 2): (0, 1), (7, 13, -5, 3): (0, 1), (7, 13, -5, 4): (0, 1), (7, 13, -5, 5): (0, 1), (7, 13, -4, -5): (0, 1), (7, 13, -4, -4): (0, 1), (7, 13, -4, -3): (0, 1), (7, 13, -4, -2): (0, 1), (7, 13, -4, -1): (0, 1), (7, 13, -4, 0): (0, 1), (7, 13, -4, 1): (0, 1), (7, 13, -4, 2): (0, 1), (7, 13, -4, 3): (0, 1), (7, 13, -4, 4): (0, 1), (7, 13, -4, 5): (0, 1), (7, 13, -3, -5): (0, 1), (7, 13, -3, -4): (0, 1), (7, 13, -3, -3): (0, 1), (7, 13, -3, -2): (0, 1), (7, 13, -3, -1): (0, 1), (7, 13, -3, 0): (0, 1), (7, 13, -3, 1): (0, 1), (7, 13, -3, 2): (0, 1), (7, 13, -3, 3): (0, 1), (7, 13, -3, 4): (0, 1), (7, 13, -3, 5): (0, 1), (7, 13, -2, -5): (0, 1), (7, 13, -2, -4): (0, 1), (7, 13, -2, -3): (0, 1), (7, 13, -2, -2): (0, 1), (7, 13, -2, -1): (0, 1), (7, 13, -2, 0): (1, 1), (7, 13, -2, 1): (1, 1), (7, 13, -2, 2): (1, 1), (7, 13, -2, 3): (1, 1), (7, 13, -2, 4): (1, 1), (7, 13, -2, 5): (1, 0), (7, 13, -1, -5): (-1, 1), (7, 13, -1, -4): (-1, 1), (7, 13, -1, -3): (-1, 1), (7, 13, -1, -2): (-1, 1), (7, 13, -1, -1): (1, 1), (7, 13, -1, 0): (1, 1), (7, 13, -1, 1): (1, 1), (7, 13, -1, 2): (1, 1), (7, 13, -1, 3): (1, 1), (7, 13, -1, 4): (1, 1), (7, 13, -1, 5): (1, 0), (7, 13, 0, -5): (-1, 1), (7, 13, 0, -4): (-1, 1), (7, 13, 0, -3): (1, 1), (7, 13, 0, -2): (1, 1), (7, 13, 0, -1): (1, 1), (7, 13, 0, 0): (1, 1), (7, 13, 0, 1): (0, 1), (7, 13, 0, 2): (0, 1), (7, 13, 0, 3): (0, 1), (7, 13, 0, 4): (0, 1), (7, 13, 0, 5): (0, 1), (7, 13, 1, -5): (1, 1), (7, 13, 1, -4): (1, 1), (7, 13, 1, -3): (1, 1), (7, 13, 1, -2): (1, 1), (7, 13, 1, -1): (0, 1), (7, 13, 1, 0): (0, 1), (7, 13, 1, 1): (-1, 1), (7, 13, 1, 2): (-1, 1), (7, 13, 1, 3): (-1, 1), (7, 13, 1, 4): (-1, 1), (7, 13, 1, 5): (-1, 1), (7, 13, 2, -5): (1, 1), (7, 13, 2, -4): (1, 1), (7, 13, 2, -3): (1, 1), (7, 13, 2, -2): (1, 1), (7, 13, 2, -1): (1, 1), (7, 13, 2, 0): (-1, 1), (7, 13, 2, 1): (-1, 1), (7, 13, 2, 2): (-1, 1), (7, 13, 2, 3): (-1, 1), (7, 13, 2, 4): (-1, 1), (7, 13, 2, 5): (-1, 1), (7, 13, 3, -5): (0, 1), (7, 13, 3, -4): (0, 1), (7, 13, 3, -3): (0, 1), (7, 13, 3, -2): (0, 1), (7, 13, 3, -1): (0, 1), (7, 13, 3, 0): (0, 1), (7, 13, 3, 1): (0, 1), (7, 13, 3, 2): (0, 1), (7, 13, 3, 3): (-1, 1), (7, 13, 3, 4): (-1, 1), (7, 13, 3, 5): (-1, 1), (7, 13, 4, -5): (0, 1), (7, 13, 4, -4): (0, 1), (7, 13, 4, -3): (0, 1), (7, 13, 4, -2): (0, 1), (7, 13, 4, -1): (0, 1), (7, 13, 4, 0): (0, 1), (7, 13, 4, 1): (0, 1), (7, 13, 4, 2): (0, 1), (7, 13, 4, 3): (0, 1), (7, 13, 4, 4): (0, 1), (7, 13, 4, 5): (0, 1), (7, 13, 5, -5): (0, 1), (7, 13, 5, -4): (0, 1), (7, 13, 5, -3): (0, 1), (7, 13, 5, -2): (0, 1), (7, 13, 5, -1): (0, 1), (7, 13, 5, 0): (0, 1), (7, 13, 5, 1): (0, 1), (7, 13, 5, 2): (0, 1), (7, 13, 5, 3): (0, 1), (7, 13, 5, 4): (0, 1), (7, 13, 5, 5): (0, 1), (7, 14, -5, -5): (0, 1), (7, 14, -5, -4): (0, 1), (7, 14, -5, -3): (0, 1), (7, 14, -5, -2): (0, 1), (7, 14, -5, -1): (0, 1), (7, 14, -5, 0): (0, 1), (7, 14, -5, 1): (0, 1), (7, 14, -5, 2): (0, 1), (7, 14, -5, 3): (0, 1), (7, 14, -5, 4): (0, 0), (7, 14, -5, 5): (-1, -1), (7, 14, -4, -5): (0, 1), (7, 14, -4, -4): (0, 1), (7, 14, -4, -3): (0, 1), (7, 14, -4, -2): (0, 1), (7, 14, -4, -1): (0, 1), (7, 14, -4, 0): (0, 1), (7, 14, -4, 1): (0, 1), (7, 14, -4, 2): (0, 1), (7, 14, -4, 3): (0, 1), (7, 14, -4, 4): (0, 0), (7, 14, -4, 5): (-1, -1), (7, 14, -3, -5): (0, 1), (7, 14, -3, -4): (0, 1), (7, 14, -3, -3): (0, 1), (7, 14, -3, -2): (0, 1), (7, 14, -3, -1): (0, 1), (7, 14, -3, 0): (0, 1), (7, 14, -3, 1): (0, 1), (7, 14, -3, 2): (0, 1), (7, 14, -3, 3): (0, 1), (7, 14, -3, 4): (0, 0), (7, 14, -3, 5): (-1, -1), (7, 14, -2, -5): (0, 1), (7, 14, -2, -4): (0, 1), (7, 14, -2, -3): (0, 1), (7, 14, -2, -2): (0, 1), (7, 14, -2, -1): (0, 1), (7, 14, -2, 0): (1, 1), (7, 14, -2, 1): (1, 1), (7, 14, -2, 2): (1, 1), (7, 14, -2, 3): (1, 1), (7, 14, -2, 4): (1, 0), (7, 14, -2, 5): (1, -1), (7, 14, -1, -5): (-1, 1), (7, 14, -1, -4): (-1, 1), (7, 14, -1, -3): (-1, 1), (7, 14, -1, -2): (-1, 1), (7, 14, -1, -1): (1, 1), (7, 14, -1, 0): (1, 1), (7, 14, -1, 1): (1, 1), (7, 14, -1, 2): (1, 1), (7, 14, -1, 3): (1, 1), (7, 14, -1, 4): (1, 1), (7, 14, -1, 5): (1, 0), (7, 14, 0, -5): (-1, 1), (7, 14, 0, -4): (-1, 1), (7, 14, 0, -3): (1, 1), (7, 14, 0, -2): (-1, 1), (7, 14, 0, -1): (1, 1), (7, 14, 0, 0): (1, 1), (7, 14, 0, 1): (1, 1), (7, 14, 0, 2): (0, 1), (7, 14, 0, 3): (0, 1), (7, 14, 0, 4): (0, 1), (7, 14, 0, 5): (0, 1), (7, 14, 1, -5): (1, 1), (7, 14, 1, -4): (1, 1), (7, 14, 1, -3): (1, 1), (7, 14, 1, -2): (1, 1), (7, 14, 1, -1): (0, 1), (7, 14, 1, 0): (0, 1), (7, 14, 1, 1): (0, 1), (7, 14, 1, 2): (-1, 1), (7, 14, 1, 3): (-1, 1), (7, 14, 1, 4): (-1, 1), (7, 14, 1, 5): (-1, 1), (7, 14, 2, -5): (1, 1), (7, 14, 2, -4): (1, 1), (7, 14, 2, -3): (1, 1), (7, 14, 2, -2): (1, 1), (7, 14, 2, -1): (1, 1), (7, 14, 2, 0): (-1, 1), (7, 14, 2, 1): (-1, 1), (7, 14, 2, 2): (-1, 1), (7, 14, 2, 3): (-1, 1), (7, 14, 2, 4): (-1, 1), (7, 14, 2, 5): (-1, 1), (7, 14, 3, -5): (0, 1), (7, 14, 3, -4): (0, 1), (7, 14, 3, -3): (0, 1), (7, 14, 3, -2): (0, 1), (7, 14, 3, -1): (0, 1), (7, 14, 3, 0): (0, 1), (7, 14, 3, 1): (0, 1), (7, 14, 3, 2): (0, 1), (7, 14, 3, 3): (-1, 1), (7, 14, 3, 4): (-1, 1), (7, 14, 3, 5): (-1, 1), (7, 14, 4, -5): (0, 1), (7, 14, 4, -4): (0, 1), (7, 14, 4, -3): (0, 1), (7, 14, 4, -2): (0, 1), (7, 14, 4, -1): (0, 1), (7, 14, 4, 0): (0, 1), (7, 14, 4, 1): (0, 1), (7, 14, 4, 2): (0, 1), (7, 14, 4, 3): (0, 1), (7, 14, 4, 4): (0, 0), (7, 14, 4, 5): (-1, -1), (7, 14, 5, -5): (0, 1), (7, 14, 5, -4): (0, 1), (7, 14, 5, -3): (0, 1), (7, 14, 5, -2): (0, 1), (7, 14, 5, -1): (0, 1), (7, 14, 5, 0): (0, 1), (7, 14, 5, 1): (0, 1), (7, 14, 5, 2): (0, 1), (7, 14, 5, 3): (0, 1), (7, 14, 5, 4): (0, 0), (7, 14, 5, 5): (-1, -1), (7, 15, -5, -5): (0, 1), (7, 15, -5, -4): (0, 1), (7, 15, -5, -3): (0, 1), (7, 15, -5, -2): (0, 1), (7, 15, -5, -1): (0, 1), (7, 15, -5, 0): (0, 1), (7, 15, -5, 1): (0, 1), (7, 15, -5, 2): (0, 1), (7, 15, -5, 3): (0, 0), (7, 15, -5, 4): (0, 1), (7, 15, -5, 5): (0, 1), (7, 15, -4, -5): (0, 1), (7, 15, -4, -4): (0, 1), (7, 15, -4, -3): (0, 1), (7, 15, -4, -2): (0, 1), (7, 15, -4, -1): (0, 1), (7, 15, -4, 0): (0, 1), (7, 15, -4, 1): (0, 1), (7, 15, -4, 2): (0, 1), (7, 15, -4, 3): (0, 0), (7, 15, -4, 4): (0, 1), (7, 15, -4, 5): (0, 1), (7, 15, -3, -5): (0, 1), (7, 15, -3, -4): (0, 1), (7, 15, -3, -3): (0, 1), (7, 15, -3, -2): (0, 1), (7, 15, -3, -1): (0, 1), (7, 15, -3, 0): (0, 1), (7, 15, -3, 1): (0, 1), (7, 15, -3, 2): (0, 1), (7, 15, -3, 3): (0, 0), (7, 15, -3, 4): (0, 1), (7, 15, -3, 5): (0, 1), (7, 15, -2, -5): (0, 1), (7, 15, -2, -4): (0, 1), (7, 15, -2, -3): (0, 1), (7, 15, -2, -2): (0, 1), (7, 15, -2, -1): (0, 1), (7, 15, -2, 0): (1, 1), (7, 15, -2, 1): (1, 1), (7, 15, -2, 2): (1, 1), (7, 15, -2, 3): (1, 1), (7, 15, -2, 4): (1, 1), (7, 15, -2, 5): (1, 0), (7, 15, -1, -5): (-1, 1), (7, 15, -1, -4): (-1, 1), (7, 15, -1, -3): (-1, 1), (7, 15, -1, -2): (-1, 1), (7, 15, -1, -1): (-1, 1), (7, 15, -1, 0): (1, 1), (7, 15, -1, 1): (1, 1), (7, 15, -1, 2): (1, 1), (7, 15, -1, 3): (1, 1), (7, 15, -1, 4): (1, 0), (7, 15, -1, 5): (1, -1), (7, 15, 0, -5): (-1, 1), (7, 15, 0, -4): (-1, 1), (7, 15, 0, -3): (-1, 1), (7, 15, 0, -2): (-1, 1), (7, 15, 0, -1): (1, 1), (7, 15, 0, 0): (0, 1), (7, 15, 0, 1): (1, 1), (7, 15, 0, 2): (0, 1), (7, 15, 0, 3): (0, 1), (7, 15, 0, 4): (0, 0), (7, 15, 0, 5): (0, -1), (7, 15, 1, -5): (1, 1), (7, 15, 1, -4): (1, 1), (7, 15, 1, -3): (1, 1), (7, 15, 1, -2): (1, 1), (7, 15, 1, -1): (0, 1), (7, 15, 1, 0): (-1, 1), (7, 15, 1, 1): (0, 1), (7, 15, 1, 2): (-1, 1), (7, 15, 1, 3): (-1, 1), (7, 15, 1, 4): (-1, 0), (7, 15, 1, 5): (-1, -1), (7, 15, 2, -5): (1, 1), (7, 15, 2, -4): (1, 1), (7, 15, 2, -3): (1, 1), (7, 15, 2, -2): (1, 1), (7, 15, 2, -1): (1, 1), (7, 15, 2, 0): (-1, 1), (7, 15, 2, 1): (-1, 1), (7, 15, 2, 2): (-1, 1), (7, 15, 2, 3): (-1, 1), (7, 15, 2, 4): (-1, 0), (7, 15, 2, 5): (-1, -1), (7, 15, 3, -5): (0, 1), (7, 15, 3, -4): (0, 1), (7, 15, 3, -3): (0, 1), (7, 15, 3, -2): (0, 1), (7, 15, 3, -1): (0, 1), (7, 15, 3, 0): (0, 1), (7, 15, 3, 1): (0, 1), (7, 15, 3, 2): (0, 1), (7, 15, 3, 3): (-1, 1), (7, 15, 3, 4): (-1, 1), (7, 15, 3, 5): (-1, 1), (7, 15, 4, -5): (0, 1), (7, 15, 4, -4): (0, 1), (7, 15, 4, -3): (0, 1), (7, 15, 4, -2): (0, 1), (7, 15, 4, -1): (0, 1), (7, 15, 4, 0): (0, 1), (7, 15, 4, 1): (0, 1), (7, 15, 4, 2): (0, 1), (7, 15, 4, 3): (0, 0), (7, 15, 4, 4): (0, 1), (7, 15, 4, 5): (0, 1), (7, 15, 5, -5): (0, 1), (7, 15, 5, -4): (0, 1), (7, 15, 5, -3): (0, 1), (7, 15, 5, -2): (0, 1), (7, 15, 5, -1): (0, 1), (7, 15, 5, 0): (0, 1), (7, 15, 5, 1): (0, 1), (7, 15, 5, 2): (0, 1), (7, 15, 5, 3): (0, 0), (7, 15, 5, 4): (0, 1), (7, 15, 5, 5): (0, 1), (7, 16, -5, -5): (0, 1), (7, 16, -5, -4): (0, 1), (7, 16, -5, -3): (0, 1), (7, 16, -5, -2): (0, 1), (7, 16, -5, -1): (0, 1), (7, 16, -5, 0): (0, 1), (7, 16, -5, 1): (0, 1), (7, 16, -5, 2): (0, 0), (7, 16, -5, 3): (0, 1), (7, 16, -5, 4): (0, 1), (7, 16, -5, 5): (0, 1), (7, 16, -4, -5): (0, 1), (7, 16, -4, -4): (0, 1), (7, 16, -4, -3): (0, 1), (7, 16, -4, -2): (0, 1), (7, 16, -4, -1): (0, 1), (7, 16, -4, 0): (0, 1), (7, 16, -4, 1): (0, 1), (7, 16, -4, 2): (0, 0), (7, 16, -4, 3): (0, 1), (7, 16, -4, 4): (0, 1), (7, 16, -4, 5): (0, 1), (7, 16, -3, -5): (0, 1), (7, 16, -3, -4): (0, 1), (7, 16, -3, -3): (0, 1), (7, 16, -3, -2): (0, 1), (7, 16, -3, -1): (0, 1), (7, 16, -3, 0): (0, 1), (7, 16, -3, 1): (0, 1), (7, 16, -3, 2): (0, 0), (7, 16, -3, 3): (0, 1), (7, 16, -3, 4): (0, 1), (7, 16, -3, 5): (0, 1), (7, 16, -2, -5): (0, 1), (7, 16, -2, -4): (0, 1), (7, 16, -2, -3): (0, 1), (7, 16, -2, -2): (0, 1), (7, 16, -2, -1): (0, 1), (7, 16, -2, 0): (1, 1), (7, 16, -2, 1): (1, 1), (7, 16, -2, 2): (1, 1), (7, 16, -2, 3): (1, 1), (7, 16, -2, 4): (1, 1), (7, 16, -2, 5): (1, 0), (7, 16, -1, -5): (-1, 1), (7, 16, -1, -4): (-1, 1), (7, 16, -1, -3): (-1, 1), (7, 16, -1, -2): (-1, 1), (7, 16, -1, -1): (1, 1), (7, 16, -1, 0): (1, 1), (7, 16, -1, 1): (1, 1), (7, 16, -1, 2): (1, 1), (7, 16, -1, 3): (1, 1), (7, 16, -1, 4): (1, 1), (7, 16, -1, 5): (1, 0), (7, 16, 0, -5): (-1, 1), (7, 16, 0, -4): (-1, 1), (7, 16, 0, -3): (-1, 1), (7, 16, 0, -2): (-1, 1), (7, 16, 0, -1): (1, 1), (7, 16, 0, 0): (1, 1), (7, 16, 0, 1): (0, 1), (7, 16, 0, 2): (0, 1), (7, 16, 0, 3): (0, 1), (7, 16, 0, 4): (0, 1), (7, 16, 0, 5): (0, 1), (7, 16, 1, -5): (1, 1), (7, 16, 1, -4): (1, 1), (7, 16, 1, -3): (1, 1), (7, 16, 1, -2): (1, 1), (7, 16, 1, -1): (0, 1), (7, 16, 1, 0): (0, 1), (7, 16, 1, 1): (-1, 1), (7, 16, 1, 2): (-1, 1), (7, 16, 1, 3): (-1, 1), (7, 16, 1, 4): (-1, 1), (7, 16, 1, 5): (-1, 1), (7, 16, 2, -5): (1, 1), (7, 16, 2, -4): (1, 1), (7, 16, 2, -3): (1, 1), (7, 16, 2, -2): (1, 1), (7, 16, 2, -1): (1, 1), (7, 16, 2, 0): (-1, 1), (7, 16, 2, 1): (-1, 1), (7, 16, 2, 2): (-1, 1), (7, 16, 2, 3): (-1, 1), (7, 16, 2, 4): (0, 1), (7, 16, 2, 5): (0, 1), (7, 16, 3, -5): (0, 1), (7, 16, 3, -4): (0, 1), (7, 16, 3, -3): (0, 1), (7, 16, 3, -2): (0, 1), (7, 16, 3, -1): (0, 1), (7, 16, 3, 0): (0, 1), (7, 16, 3, 1): (0, 1), (7, 16, 3, 2): (-1, 1), (7, 16, 3, 3): (-1, 1), (7, 16, 3, 4): (-1, 1), (7, 16, 3, 5): (-1, 1), (7, 16, 4, -5): (0, 1), (7, 16, 4, -4): (0, 1), (7, 16, 4, -3): (0, 1), (7, 16, 4, -2): (0, 1), (7, 16, 4, -1): (0, 1), (7, 16, 4, 0): (0, 1), (7, 16, 4, 1): (0, 1), (7, 16, 4, 2): (0, 0), (7, 16, 4, 3): (0, 1), (7, 16, 4, 4): (0, 1), (7, 16, 4, 5): (0, 1), (7, 16, 5, -5): (0, 1), (7, 16, 5, -4): (0, 1), (7, 16, 5, -3): (0, 1), (7, 16, 5, -2): (0, 1), (7, 16, 5, -1): (0, 1), (7, 16, 5, 0): (0, 1), (7, 16, 5, 1): (0, 1), (7, 16, 5, 2): (0, 0), (7, 16, 5, 3): (0, 1), (7, 16, 5, 4): (0, 1), (7, 16, 5, 5): (0, 1), (7, 17, -5, -5): (0, 1), (7, 17, -5, -4): (0, 1), (7, 17, -5, -3): (0, 1), (7, 17, -5, -2): (0, 1), (7, 17, -5, -1): (0, 1), (7, 17, -5, 0): (0, 1), (7, 17, -5, 1): (0, 0), (7, 17, -5, 2): (0, 1), (7, 17, -5, 3): (0, 1), (7, 17, -5, 4): (0, 1), (7, 17, -5, 5): (0, 1), (7, 17, -4, -5): (0, 1), (7, 17, -4, -4): (0, 1), (7, 17, -4, -3): (0, 1), (7, 17, -4, -2): (0, 1), (7, 17, -4, -1): (0, 1), (7, 17, -4, 0): (0, 1), (7, 17, -4, 1): (0, 0), (7, 17, -4, 2): (0, 1), (7, 17, -4, 3): (0, 1), (7, 17, -4, 4): (0, 1), (7, 17, -4, 5): (0, 1), (7, 17, -3, -5): (0, 1), (7, 17, -3, -4): (0, 1), (7, 17, -3, -3): (0, 1), (7, 17, -3, -2): (0, 1), (7, 17, -3, -1): (0, 1), (7, 17, -3, 0): (0, 1), (7, 17, -3, 1): (0, 0), (7, 17, -3, 2): (0, 1), (7, 17, -3, 3): (0, 1), (7, 17, -3, 4): (0, 1), (7, 17, -3, 5): (0, 1), (7, 17, -2, -5): (0, 1), (7, 17, -2, -4): (0, 1), (7, 17, -2, -3): (0, 1), (7, 17, -2, -2): (0, 1), (7, 17, -2, -1): (0, 1), (7, 17, -2, 0): (0, 1), (7, 17, -2, 1): (1, 1), (7, 17, -2, 2): (1, 1), (7, 17, -2, 3): (1, 1), (7, 17, -2, 4): (1, 1), (7, 17, -2, 5): (1, 0), (7, 17, -1, -5): (-1, 1), (7, 17, -1, -4): (-1, 1), (7, 17, -1, -3): (-1, 1), (7, 17, -1, -2): (-1, 1), (7, 17, -1, -1): (1, 1), (7, 17, -1, 0): (1, 1), (7, 17, -1, 1): (1, 1), (7, 17, -1, 2): (1, 1), (7, 17, -1, 3): (1, 1), (7, 17, -1, 4): (1, 1), (7, 17, -1, 5): (1, 0), (7, 17, 0, -5): (-1, 1), (7, 17, 0, -4): (-1, 1), (7, 17, 0, -3): (-1, 1), (7, 17, 0, -2): (1, 1), (7, 17, 0, -1): (1, 1), (7, 17, 0, 0): (0, 1), (7, 17, 0, 1): (0, 1), (7, 17, 0, 2): (0, 1), (7, 17, 0, 3): (0, 1), (7, 17, 0, 4): (0, 1), (7, 17, 0, 5): (0, 1), (7, 17, 1, -5): (1, 1), (7, 17, 1, -4): (1, 1), (7, 17, 1, -3): (1, 1), (7, 17, 1, -2): (1, 1), (7, 17, 1, -1): (0, 1), (7, 17, 1, 0): (-1, 1), (7, 17, 1, 1): (-1, 1), (7, 17, 1, 2): (-1, 1), (7, 17, 1, 3): (-1, 1), (7, 17, 1, 4): (-1, 1), (7, 17, 1, 5): (-1, 1), (7, 17, 2, -5): (1, 1), (7, 17, 2, -4): (1, 1), (7, 17, 2, -3): (1, 1), (7, 17, 2, -2): (1, 1), (7, 17, 2, -1): (1, 1), (7, 17, 2, 0): (-1, 1), (7, 17, 2, 1): (-1, 1), (7, 17, 2, 2): (-1, 1), (7, 17, 2, 3): (-1, 1), (7, 17, 2, 4): (0, 1), (7, 17, 2, 5): (0, 1), (7, 17, 3, -5): (0, 1), (7, 17, 3, -4): (0, 1), (7, 17, 3, -3): (0, 1), (7, 17, 3, -2): (0, 1), (7, 17, 3, -1): (0, 1), (7, 17, 3, 0): (0, 1), (7, 17, 3, 1): (0, 0), (7, 17, 3, 2): (-1, 1), (7, 17, 3, 3): (-1, 1), (7, 17, 3, 4): (-1, 1), (7, 17, 3, 5): (-1, 1), (7, 17, 4, -5): (0, 1), (7, 17, 4, -4): (0, 1), (7, 17, 4, -3): (0, 1), (7, 17, 4, -2): (0, 1), (7, 17, 4, -1): (0, 1), (7, 17, 4, 0): (0, 1), (7, 17, 4, 1): (0, 0), (7, 17, 4, 2): (0, 1), (7, 17, 4, 3): (0, 1), (7, 17, 4, 4): (0, 1), (7, 17, 4, 5): (0, 1), (7, 17, 5, -5): (0, 1), (7, 17, 5, -4): (0, 1), (7, 17, 5, -3): (0, 1), (7, 17, 5, -2): (0, 1), (7, 17, 5, -1): (0, 1), (7, 17, 5, 0): (0, 1), (7, 17, 5, 1): (0, 0), (7, 17, 5, 2): (0, 1), (7, 17, 5, 3): (0, 1), (7, 17, 5, 4): (0, 1), (7, 17, 5, 5): (0, 1), (7, 18, -5, -5): (0, 1), (7, 18, -5, -4): (0, 1), (7, 18, -5, -3): (0, 1), (7, 18, -5, -2): (0, 1), (7, 18, -5, -1): (0, 1), (7, 18, -5, 0): (0, 0), (7, 18, -5, 1): (0, 1), (7, 18, -5, 2): (0, 1), (7, 18, -5, 3): (0, 1), (7, 18, -5, 4): (0, 1), (7, 18, -5, 5): (0, 1), (7, 18, -4, -5): (0, 1), (7, 18, -4, -4): (0, 1), (7, 18, -4, -3): (0, 1), (7, 18, -4, -2): (0, 1), (7, 18, -4, -1): (0, 1), (7, 18, -4, 0): (0, 0), (7, 18, -4, 1): (0, 1), (7, 18, -4, 2): (0, 1), (7, 18, -4, 3): (0, 1), (7, 18, -4, 4): (0, 1), (7, 18, -4, 5): (0, 1), (7, 18, -3, -5): (0, 1), (7, 18, -3, -4): (0, 1), (7, 18, -3, -3): (0, 1), (7, 18, -3, -2): (0, 1), (7, 18, -3, -1): (0, 1), (7, 18, -3, 0): (0, 0), (7, 18, -3, 1): (0, 1), (7, 18, -3, 2): (0, 1), (7, 18, -3, 3): (0, 1), (7, 18, -3, 4): (0, 1), (7, 18, -3, 5): (0, 1), (7, 18, -2, -5): (0, 1), (7, 18, -2, -4): (0, 1), (7, 18, -2, -3): (0, 1), (7, 18, -2, -2): (0, 1), (7, 18, -2, -1): (0, 1), (7, 18, -2, 0): (0, 0), (7, 18, -2, 1): (1, 1), (7, 18, -2, 2): (1, 1), (7, 18, -2, 3): (1, 1), (7, 18, -2, 4): (1, 1), (7, 18, -2, 5): (1, 0), (7, 18, -1, -5): (-1, 1), (7, 18, -1, -4): (-1, 1), (7, 18, -1, -3): (-1, 1), (7, 18, -1, -2): (-1, 1), (7, 18, -1, -1): (-1, 1), (7, 18, -1, 0): (1, 1), (7, 18, -1, 1): (1, 1), (7, 18, -1, 2): (1, 1), (7, 18, -1, 3): (1, 1), (7, 18, -1, 4): (1, 1), (7, 18, -1, 5): (1, 0), (7, 18, 0, -5): (-1, 1), (7, 18, 0, -4): (-1, 1), (7, 18, 0, -3): (-1, 1), (7, 18, 0, -2): (1, 1), (7, 18, 0, -1): (1, 1), (7, 18, 0, 0): (0, 1), (7, 18, 0, 1): (0, 1), (7, 18, 0, 2): (0, 1), (7, 18, 0, 3): (0, 1), (7, 18, 0, 4): (0, 1), (7, 18, 0, 5): (0, 1), (7, 18, 1, -5): (1, 1), (7, 18, 1, -4): (1, 1), (7, 18, 1, -3): (1, 1), (7, 18, 1, -2): (1, 1), (7, 18, 1, -1): (0, 1), (7, 18, 1, 0): (-1, 1), (7, 18, 1, 1): (-1, 1), (7, 18, 1, 2): (-1, 1), (7, 18, 1, 3): (-1, 1), (7, 18, 1, 4): (-1, 1), (7, 18, 1, 5): (-1, 1), (7, 18, 2, -5): (1, 1), (7, 18, 2, -4): (1, 1), (7, 18, 2, -3): (1, 1), (7, 18, 2, -2): (1, 1), (7, 18, 2, -1): (1, 1), (7, 18, 2, 0): (-1, 1), (7, 18, 2, 1): (-1, 1), (7, 18, 2, 2): (-1, 1), (7, 18, 2, 3): (0, 1), (7, 18, 2, 4): (0, 1), (7, 18, 2, 5): (0, 1), (7, 18, 3, -5): (0, 1), (7, 18, 3, -4): (0, 1), (7, 18, 3, -3): (0, 1), (7, 18, 3, -2): (0, 1), (7, 18, 3, -1): (0, 1), (7, 18, 3, 0): (0, 0), (7, 18, 3, 1): (-1, 1), (7, 18, 3, 2): (-1, 1), (7, 18, 3, 3): (-1, 1), (7, 18, 3, 4): (-1, 1), (7, 18, 3, 5): (-1, 1), (7, 18, 4, -5): (0, 1), (7, 18, 4, -4): (0, 1), (7, 18, 4, -3): (0, 1), (7, 18, 4, -2): (0, 1), (7, 18, 4, -1): (0, 1), (7, 18, 4, 0): (0, 0), (7, 18, 4, 1): (0, 1), (7, 18, 4, 2): (0, 1), (7, 18, 4, 3): (0, 1), (7, 18, 4, 4): (0, 1), (7, 18, 4, 5): (0, 1), (7, 18, 5, -5): (0, 1), (7, 18, 5, -4): (0, 1), (7, 18, 5, -3): (0, 1), (7, 18, 5, -2): (0, 1), (7, 18, 5, -1): (0, 1), (7, 18, 5, 0): (0, 0), (7, 18, 5, 1): (0, 1), (7, 18, 5, 2): (0, 1), (7, 18, 5, 3): (0, 1), (7, 18, 5, 4): (0, 1), (7, 18, 5, 5): (0, 1), (7, 19, -5, -5): (0, 1), (7, 19, -5, -4): (0, 1), (7, 19, -5, -3): (0, 1), (7, 19, -5, -2): (0, 1), (7, 19, -5, -1): (0, 0), (7, 19, -5, 0): (0, 1), (7, 19, -5, 1): (0, 1), (7, 19, -5, 2): (0, 1), (7, 19, -5, 3): (0, 1), (7, 19, -5, 4): (0, 1), (7, 19, -5, 5): (0, 1), (7, 19, -4, -5): (0, 1), (7, 19, -4, -4): (0, 1), (7, 19, -4, -3): (0, 1), (7, 19, -4, -2): (0, 1), (7, 19, -4, -1): (0, 0), (7, 19, -4, 0): (0, 1), (7, 19, -4, 1): (0, 1), (7, 19, -4, 2): (0, 1), (7, 19, -4, 3): (0, 1), (7, 19, -4, 4): (0, 1), (7, 19, -4, 5): (0, 1), (7, 19, -3, -5): (0, 1), (7, 19, -3, -4): (0, 1), (7, 19, -3, -3): (0, 1), (7, 19, -3, -2): (0, 1), (7, 19, -3, -1): (0, 0), (7, 19, -3, 0): (0, 1), (7, 19, -3, 1): (0, 1), (7, 19, -3, 2): (0, 1), (7, 19, -3, 3): (0, 1), (7, 19, -3, 4): (0, 1), (7, 19, -3, 5): (0, 1), (7, 19, -2, -5): (0, 1), (7, 19, -2, -4): (0, 1), (7, 19, -2, -3): (0, 1), (7, 19, -2, -2): (0, 1), (7, 19, -2, -1): (0, 0), (7, 19, -2, 0): (0, 1), (7, 19, -2, 1): (1, 1), (7, 19, -2, 2): (1, 1), (7, 19, -2, 3): (1, 1), (7, 19, -2, 4): (1, 1), (7, 19, -2, 5): (1, 0), (7, 19, -1, -5): (-1, 1), (7, 19, -1, -4): (-1, 1), (7, 19, -1, -3): (-1, 1), (7, 19, -1, -2): (-1, 1), (7, 19, -1, -1): (1, 1), (7, 19, -1, 0): (1, 1), (7, 19, -1, 1): (1, 1), (7, 19, -1, 2): (1, 1), (7, 19, -1, 3): (1, 1), (7, 19, -1, 4): (1, 0), (7, 19, -1, 5): (1, -1), (7, 19, 0, -5): (-1, 1), (7, 19, 0, -4): (-1, 1), (7, 19, 0, -3): (1, 1), (7, 19, 0, -2): (1, 1), (7, 19, 0, -1): (1, 1), (7, 19, 0, 0): (1, 1), (7, 19, 0, 1): (0, 1), (7, 19, 0, 2): (0, 1), (7, 19, 0, 3): (0, 1), (7, 19, 0, 4): (0, 0), (7, 19, 0, 5): (0, -1), (7, 19, 1, -5): (1, 1), (7, 19, 1, -4): (1, 1), (7, 19, 1, -3): (1, 1), (7, 19, 1, -2): (1, 1), (7, 19, 1, -1): (0, 1), (7, 19, 1, 0): (0, 1), (7, 19, 1, 1): (-1, 1), (7, 19, 1, 2): (-1, 1), (7, 19, 1, 3): (-1, 1), (7, 19, 1, 4): (-1, 0), (7, 19, 1, 5): (-1, -1), (7, 19, 2, -5): (1, 1), (7, 19, 2, -4): (1, 1), (7, 19, 2, -3): (1, 1), (7, 19, 2, -2): (1, 1), (7, 19, 2, -1): (1, 0), (7, 19, 2, 0): (-1, 1), (7, 19, 2, 1): (-1, 1), (7, 19, 2, 2): (-1, 1), (7, 19, 2, 3): (0, 1), (7, 19, 2, 4): (0, 1), (7, 19, 2, 5): (0, 1), (7, 19, 3, -5): (0, 1), (7, 19, 3, -4): (0, 1), (7, 19, 3, -3): (0, 1), (7, 19, 3, -2): (0, 1), (7, 19, 3, -1): (0, 0), (7, 19, 3, 0): (0, 1), (7, 19, 3, 1): (-1, 1), (7, 19, 3, 2): (-1, 1), (7, 19, 3, 3): (-1, 1), (7, 19, 3, 4): (-1, 1), (7, 19, 3, 5): (-1, 1), (7, 19, 4, -5): (0, 1), (7, 19, 4, -4): (0, 1), (7, 19, 4, -3): (0, 1), (7, 19, 4, -2): (0, 1), (7, 19, 4, -1): (0, 0), (7, 19, 4, 0): (0, 1), (7, 19, 4, 1): (0, 1), (7, 19, 4, 2): (0, 1), (7, 19, 4, 3): (0, 1), (7, 19, 4, 4): (0, 1), (7, 19, 4, 5): (0, 1), (7, 19, 5, -5): (0, 1), (7, 19, 5, -4): (0, 1), (7, 19, 5, -3): (0, 1), (7, 19, 5, -2): (0, 1), (7, 19, 5, -1): (0, 0), (7, 19, 5, 0): (0, 1), (7, 19, 5, 1): (0, 1), (7, 19, 5, 2): (0, 1), (7, 19, 5, 3): (0, 1), (7, 19, 5, 4): (0, 1), (7, 19, 5, 5): (0, 1), (7, 20, -5, -5): (0, 1), (7, 20, -5, -4): (0, 1), (7, 20, -5, -3): (0, 1), (7, 20, -5, -2): (0, 0), (7, 20, -5, -1): (0, 1), (7, 20, -5, 0): (0, 1), (7, 20, -5, 1): (0, 1), (7, 20, -5, 2): (0, 1), (7, 20, -5, 3): (0, 1), (7, 20, -5, 4): (0, 1), (7, 20, -5, 5): (0, 1), (7, 20, -4, -5): (0, 1), (7, 20, -4, -4): (0, 1), (7, 20, -4, -3): (0, 1), (7, 20, -4, -2): (0, 0), (7, 20, -4, -1): (0, 1), (7, 20, -4, 0): (0, 1), (7, 20, -4, 1): (0, 1), (7, 20, -4, 2): (0, 1), (7, 20, -4, 3): (0, 1), (7, 20, -4, 4): (0, 1), (7, 20, -4, 5): (0, 1), (7, 20, -3, -5): (0, 1), (7, 20, -3, -4): (0, 1), (7, 20, -3, -3): (0, 1), (7, 20, -3, -2): (0, 0), (7, 20, -3, -1): (0, 1), (7, 20, -3, 0): (0, 1), (7, 20, -3, 1): (0, 1), (7, 20, -3, 2): (0, 1), (7, 20, -3, 3): (0, 1), (7, 20, -3, 4): (0, 1), (7, 20, -3, 5): (0, 1), (7, 20, -2, -5): (0, 1), (7, 20, -2, -4): (0, 1), (7, 20, -2, -3): (0, 1), (7, 20, -2, -2): (0, 0), (7, 20, -2, -1): (0, 1), (7, 20, -2, 0): (1, 1), (7, 20, -2, 1): (1, 1), (7, 20, -2, 2): (1, 1), (7, 20, -2, 3): (1, 1), (7, 20, -2, 4): (1, 1), (7, 20, -2, 5): (1, 0), (7, 20, -1, -5): (-1, 1), (7, 20, -1, -4): (-1, 1), (7, 20, -1, -3): (-1, 1), (7, 20, -1, -2): (-1, 0), (7, 20, -1, -1): (1, 1), (7, 20, -1, 0): (1, 1), (7, 20, -1, 1): (1, 1), (7, 20, -1, 2): (1, 1), (7, 20, -1, 3): (1, 1), (7, 20, -1, 4): (1, 0), (7, 20, -1, 5): (1, -1), (7, 20, 0, -5): (-1, 1), (7, 20, 0, -4): (-1, 1), (7, 20, 0, -3): (1, 1), (7, 20, 0, -2): (1, 1), (7, 20, 0, -1): (1, 1), (7, 20, 0, 0): (1, 1), (7, 20, 0, 1): (0, 1), (7, 20, 0, 2): (0, 1), (7, 20, 0, 3): (0, 1), (7, 20, 0, 4): (0, 0), (7, 20, 0, 5): (0, -1), (7, 20, 1, -5): (1, 1), (7, 20, 1, -4): (1, 1), (7, 20, 1, -3): (1, 1), (7, 20, 1, -2): (1, 1), (7, 20, 1, -1): (0, 1), (7, 20, 1, 0): (0, 1), (7, 20, 1, 1): (-1, 1), (7, 20, 1, 2): (-1, 1), (7, 20, 1, 3): (-1, 1), (7, 20, 1, 4): (-1, 0), (7, 20, 1, 5): (-1, -1), (7, 20, 2, -5): (1, 1), (7, 20, 2, -4): (1, 1), (7, 20, 2, -3): (1, 1), (7, 20, 2, -2): (1, 0), (7, 20, 2, -1): (1, 1), (7, 20, 2, 0): (-1, 1), (7, 20, 2, 1): (-1, 1), (7, 20, 2, 2): (0, 1), (7, 20, 2, 3): (0, 1), (7, 20, 2, 4): (0, 1), (7, 20, 2, 5): (0, 1), (7, 20, 3, -5): (0, 1), (7, 20, 3, -4): (0, 1), (7, 20, 3, -3): (0, 1), (7, 20, 3, -2): (0, 0), (7, 20, 3, -1): (0, 1), (7, 20, 3, 0): (0, 1), (7, 20, 3, 1): (0, 1), (7, 20, 3, 2): (-1, 1), (7, 20, 3, 3): (-1, 1), (7, 20, 3, 4): (-1, 1), (7, 20, 3, 5): (-1, 1), (7, 20, 4, -5): (0, 1), (7, 20, 4, -4): (0, 1), (7, 20, 4, -3): (0, 1), (7, 20, 4, -2): (0, 0), (7, 20, 4, -1): (0, 1), (7, 20, 4, 0): (0, 1), (7, 20, 4, 1): (0, 1), (7, 20, 4, 2): (0, 1), (7, 20, 4, 3): (0, 1), (7, 20, 4, 4): (0, 1), (7, 20, 4, 5): (0, 1), (7, 20, 5, -5): (0, 1), (7, 20, 5, -4): (0, 1), (7, 20, 5, -3): (0, 1), (7, 20, 5, -2): (0, 0), (7, 20, 5, -1): (0, 1), (7, 20, 5, 0): (0, 1), (7, 20, 5, 1): (0, 1), (7, 20, 5, 2): (0, 1), (7, 20, 5, 3): (0, 1), (7, 20, 5, 4): (0, 1), (7, 20, 5, 5): (0, 1), (7, 21, -5, -5): (0, 1), (7, 21, -5, -4): (0, 1), (7, 21, -5, -3): (0, 0), (7, 21, -5, -2): (0, 1), (7, 21, -5, -1): (0, 1), (7, 21, -5, 0): (0, 1), (7, 21, -5, 1): (0, 1), (7, 21, -5, 2): (0, 1), (7, 21, -5, 3): (0, 1), (7, 21, -5, 4): (0, 1), (7, 21, -5, 5): (0, 1), (7, 21, -4, -5): (0, 1), (7, 21, -4, -4): (0, 1), (7, 21, -4, -3): (0, 0), (7, 21, -4, -2): (0, 1), (7, 21, -4, -1): (0, 1), (7, 21, -4, 0): (0, 1), (7, 21, -4, 1): (0, 1), (7, 21, -4, 2): (0, 1), (7, 21, -4, 3): (0, 1), (7, 21, -4, 4): (0, 1), (7, 21, -4, 5): (0, 1), (7, 21, -3, -5): (0, 1), (7, 21, -3, -4): (0, 1), (7, 21, -3, -3): (0, 0), (7, 21, -3, -2): (0, 1), (7, 21, -3, -1): (0, 1), (7, 21, -3, 0): (0, 1), (7, 21, -3, 1): (0, 1), (7, 21, -3, 2): (0, 1), (7, 21, -3, 3): (0, 1), (7, 21, -3, 4): (0, 1), (7, 21, -3, 5): (0, 1), (7, 21, -2, -5): (0, 1), (7, 21, -2, -4): (0, 1), (7, 21, -2, -3): (0, 0), (7, 21, -2, -2): (0, 1), (7, 21, -2, -1): (0, 1), (7, 21, -2, 0): (0, 1), (7, 21, -2, 1): (1, 1), (7, 21, -2, 2): (1, 1), (7, 21, -2, 3): (1, 1), (7, 21, -2, 4): (1, 1), (7, 21, -2, 5): (1, 0), (7, 21, -1, -5): (-1, 1), (7, 21, -1, -4): (-1, 1), (7, 21, -1, -3): (-1, 0), (7, 21, -1, -2): (-1, 1), (7, 21, -1, -1): (1, 1), (7, 21, -1, 0): (1, 1), (7, 21, -1, 1): (1, 1), (7, 21, -1, 2): (1, 1), (7, 21, -1, 3): (1, 0), (7, 21, -1, 4): (0, 1), (7, 21, -1, 5): (0, 1), (7, 21, 0, -5): (-1, 1), (7, 21, 0, -4): (1, 1), (7, 21, 0, -3): (1, 1), (7, 21, 0, -2): (1, 1), (7, 21, 0, -1): (1, 1), (7, 21, 0, 0): (0, 1), (7, 21, 0, 1): (0, 1), (7, 21, 0, 2): (0, 1), (7, 21, 0, 3): (0, 0), (7, 21, 0, 4): (-1, 1), (7, 21, 0, 5): (-1, 1), (7, 21, 1, -5): (1, 1), (7, 21, 1, -4): (1, 1), (7, 21, 1, -3): (1, 1), (7, 21, 1, -2): (1, 1), (7, 21, 1, -1): (0, 1), (7, 21, 1, 0): (-1, 1), (7, 21, 1, 1): (-1, 1), (7, 21, 1, 2): (-1, 1), (7, 21, 1, 3): (-1, 0), (7, 21, 1, 4): (-1, -1), (7, 21, 1, 5): (-1, -1), (7, 21, 2, -5): (1, 1), (7, 21, 2, -4): (1, 1), (7, 21, 2, -3): (1, 0), (7, 21, 2, -2): (1, 1), (7, 21, 2, -1): (1, 1), (7, 21, 2, 0): (-1, 1), (7, 21, 2, 1): (-1, 1), (7, 21, 2, 2): (0, 1), (7, 21, 2, 3): (0, 1), (7, 21, 2, 4): (1, 1), (7, 21, 2, 5): (1, 0), (7, 21, 3, -5): (0, 1), (7, 21, 3, -4): (0, 1), (7, 21, 3, -3): (0, 0), (7, 21, 3, -2): (0, 1), (7, 21, 3, -1): (0, 1), (7, 21, 3, 0): (0, 1), (7, 21, 3, 1): (0, 1), (7, 21, 3, 2): (-1, 1), (7, 21, 3, 3): (-1, 1), (7, 21, 3, 4): (0, 1), (7, 21, 3, 5): (0, 1), (7, 21, 4, -5): (0, 1), (7, 21, 4, -4): (0, 1), (7, 21, 4, -3): (0, 0), (7, 21, 4, -2): (0, 1), (7, 21, 4, -1): (0, 1), (7, 21, 4, 0): (0, 1), (7, 21, 4, 1): (0, 1), (7, 21, 4, 2): (0, 1), (7, 21, 4, 3): (0, 1), (7, 21, 4, 4): (0, 1), (7, 21, 4, 5): (0, 1), (7, 21, 5, -5): (0, 1), (7, 21, 5, -4): (0, 1), (7, 21, 5, -3): (0, 0), (7, 21, 5, -2): (0, 1), (7, 21, 5, -1): (0, 1), (7, 21, 5, 0): (0, 1), (7, 21, 5, 1): (0, 1), (7, 21, 5, 2): (0, 1), (7, 21, 5, 3): (0, 1), (7, 21, 5, 4): (0, 1), (7, 21, 5, 5): (0, 1), (7, 22, -5, -5): (0, 1), (7, 22, -5, -4): (0, 0), (7, 22, -5, -3): (0, 1), (7, 22, -5, -2): (0, 1), (7, 22, -5, -1): (0, 1), (7, 22, -5, 0): (0, 1), (7, 22, -5, 1): (0, 1), (7, 22, -5, 2): (0, 1), (7, 22, -5, 3): (0, 1), (7, 22, -5, 4): (0, 1), (7, 22, -5, 5): (0, 1), (7, 22, -4, -5): (0, 1), (7, 22, -4, -4): (0, 0), (7, 22, -4, -3): (0, 1), (7, 22, -4, -2): (0, 1), (7, 22, -4, -1): (0, 1), (7, 22, -4, 0): (0, 1), (7, 22, -4, 1): (0, 1), (7, 22, -4, 2): (0, 1), (7, 22, -4, 3): (0, 1), (7, 22, -4, 4): (0, 1), (7, 22, -4, 5): (0, 1), (7, 22, -3, -5): (0, 1), (7, 22, -3, -4): (0, 0), (7, 22, -3, -3): (0, 1), (7, 22, -3, -2): (0, 1), (7, 22, -3, -1): (0, 1), (7, 22, -3, 0): (0, 1), (7, 22, -3, 1): (0, 1), (7, 22, -3, 2): (0, 1), (7, 22, -3, 3): (0, 1), (7, 22, -3, 4): (0, 1), (7, 22, -3, 5): (0, 1), (7, 22, -2, -5): (0, 1), (7, 22, -2, -4): (0, 0), (7, 22, -2, -3): (0, 1), (7, 22, -2, -2): (0, 1), (7, 22, -2, -1): (0, 1), (7, 22, -2, 0): (0, 1), (7, 22, -2, 1): (1, 1), (7, 22, -2, 2): (1, 1), (7, 22, -2, 3): (1, 1), (7, 22, -2, 4): (1, 1), (7, 22, -2, 5): (1, 0), (7, 22, -1, -5): (-1, 1), (7, 22, -1, -4): (-1, 0), (7, 22, -1, -3): (-1, 1), (7, 22, -1, -2): (-1, 1), (7, 22, -1, -1): (1, 1), (7, 22, -1, 0): (1, 1), (7, 22, -1, 1): (1, 1), (7, 22, -1, 2): (1, 1), (7, 22, -1, 3): (1, 0), (7, 22, -1, 4): (0, 1), (7, 22, -1, 5): (0, 1), (7, 22, 0, -5): (-1, 1), (7, 22, 0, -4): (-1, 1), (7, 22, 0, -3): (-1, 1), (7, 22, 0, -2): (1, 1), (7, 22, 0, -1): (0, 1), (7, 22, 0, 0): (0, 1), (7, 22, 0, 1): (0, 1), (7, 22, 0, 2): (0, 1), (7, 22, 0, 3): (0, 0), (7, 22, 0, 4): (-1, 1), (7, 22, 0, 5): (-1, 1), (7, 22, 1, -5): (1, 1), (7, 22, 1, -4): (1, 1), (7, 22, 1, -3): (1, 1), (7, 22, 1, -2): (1, 1), (7, 22, 1, -1): (-1, 1), (7, 22, 1, 0): (-1, 1), (7, 22, 1, 1): (-1, 1), (7, 22, 1, 2): (-1, 1), (7, 22, 1, 3): (-1, 0), (7, 22, 1, 4): (-1, -1), (7, 22, 1, 5): (-1, -1), (7, 22, 2, -5): (1, 1), (7, 22, 2, -4): (1, 0), (7, 22, 2, -3): (1, 1), (7, 22, 2, -2): (1, 1), (7, 22, 2, -1): (1, 1), (7, 22, 2, 0): (1, 1), (7, 22, 2, 1): (0, 1), (7, 22, 2, 2): (0, 1), (7, 22, 2, 3): (1, 1), (7, 22, 2, 4): (1, 1), (7, 22, 2, 5): (1, 0), (7, 22, 3, -5): (0, 1), (7, 22, 3, -4): (0, 0), (7, 22, 3, -3): (0, 1), (7, 22, 3, -2): (0, 1), (7, 22, 3, -1): (0, 1), (7, 22, 3, 0): (0, 1), (7, 22, 3, 1): (-1, 1), (7, 22, 3, 2): (-1, 1), (7, 22, 3, 3): (0, 1), (7, 22, 3, 4): (0, 1), (7, 22, 3, 5): (0, 1), (7, 22, 4, -5): (0, 1), (7, 22, 4, -4): (0, 0), (7, 22, 4, -3): (0, 1), (7, 22, 4, -2): (0, 1), (7, 22, 4, -1): (0, 1), (7, 22, 4, 0): (0, 1), (7, 22, 4, 1): (0, 1), (7, 22, 4, 2): (0, 1), (7, 22, 4, 3): (0, 1), (7, 22, 4, 4): (0, 1), (7, 22, 4, 5): (0, 1), (7, 22, 5, -5): (0, 1), (7, 22, 5, -4): (0, 0), (7, 22, 5, -3): (0, 1), (7, 22, 5, -2): (0, 1), (7, 22, 5, -1): (0, 1), (7, 22, 5, 0): (0, 1), (7, 22, 5, 1): (0, 1), (7, 22, 5, 2): (0, 1), (7, 22, 5, 3): (0, 1), (7, 22, 5, 4): (0, 1), (7, 22, 5, 5): (0, 1), (7, 23, -5, -5): (0, 0), (7, 23, -5, -4): (0, 1), (7, 23, -5, -3): (0, 1), (7, 23, -5, -2): (0, 1), (7, 23, -5, -1): (0, 1), (7, 23, -5, 0): (0, 1), (7, 23, -5, 1): (0, 1), (7, 23, -5, 2): (0, 1), (7, 23, -5, 3): (0, 1), (7, 23, -5, 4): (0, 1), (7, 23, -5, 5): (0, 1), (7, 23, -4, -5): (0, 0), (7, 23, -4, -4): (0, 1), (7, 23, -4, -3): (0, 1), (7, 23, -4, -2): (0, 1), (7, 23, -4, -1): (0, 1), (7, 23, -4, 0): (0, 1), (7, 23, -4, 1): (0, 1), (7, 23, -4, 2): (0, 1), (7, 23, -4, 3): (0, 1), (7, 23, -4, 4): (0, 1), (7, 23, -4, 5): (0, 1), (7, 23, -3, -5): (0, 0), (7, 23, -3, -4): (0, 1), (7, 23, -3, -3): (0, 1), (7, 23, -3, -2): (0, 1), (7, 23, -3, -1): (0, 1), (7, 23, -3, 0): (0, 1), (7, 23, -3, 1): (0, 1), (7, 23, -3, 2): (0, 1), (7, 23, -3, 3): (0, 1), (7, 23, -3, 4): (0, 1), (7, 23, -3, 5): (0, 1), (7, 23, -2, -5): (0, 0), (7, 23, -2, -4): (0, 1), (7, 23, -2, -3): (0, 1), (7, 23, -2, -2): (0, 1), (7, 23, -2, -1): (0, 1), (7, 23, -2, 0): (1, 1), (7, 23, -2, 1): (1, 1), (7, 23, -2, 2): (1, 1), (7, 23, -2, 3): (1, 1), (7, 23, -2, 4): (1, 1), (7, 23, -2, 5): (1, 0), (7, 23, -1, -5): (-1, 0), (7, 23, -1, -4): (-1, 1), (7, 23, -1, -3): (-1, 1), (7, 23, -1, -2): (-1, 1), (7, 23, -1, -1): (1, 1), (7, 23, -1, 0): (1, 1), (7, 23, -1, 1): (1, 1), (7, 23, -1, 2): (1, 1), (7, 23, -1, 3): (0, 1), (7, 23, -1, 4): (0, 1), (7, 23, -1, 5): (0, 1), (7, 23, 0, -5): (-1, 1), (7, 23, 0, -4): (-1, 1), (7, 23, 0, -3): (-1, 1), (7, 23, 0, -2): (1, 1), (7, 23, 0, -1): (1, 1), (7, 23, 0, 0): (0, 1), (7, 23, 0, 1): (0, 1), (7, 23, 0, 2): (0, 1), (7, 23, 0, 3): (-1, 1), (7, 23, 0, 4): (-1, 1), (7, 23, 0, 5): (-1, 1), (7, 23, 1, -5): (1, 1), (7, 23, 1, -4): (1, 1), (7, 23, 1, -3): (1, 1), (7, 23, 1, -2): (1, 1), (7, 23, 1, -1): (0, 1), (7, 23, 1, 0): (-1, 1), (7, 23, 1, 1): (-1, 1), (7, 23, 1, 2): (-1, 1), (7, 23, 1, 3): (-1, 0), (7, 23, 1, 4): (-1, -1), (7, 23, 1, 5): (-1, -1), (7, 23, 2, -5): (1, 0), (7, 23, 2, -4): (1, 1), (7, 23, 2, -3): (1, 1), (7, 23, 2, -2): (1, 1), (7, 23, 2, -1): (1, 1), (7, 23, 2, 0): (-1, 1), (7, 23, 2, 1): (0, 1), (7, 23, 2, 2): (1, 1), (7, 23, 2, 3): (1, 1), (7, 23, 2, 4): (1, 1), (7, 23, 2, 5): (1, 0), (7, 23, 3, -5): (0, 0), (7, 23, 3, -4): (0, 1), (7, 23, 3, -3): (0, 1), (7, 23, 3, -2): (0, 1), (7, 23, 3, -1): (0, 1), (7, 23, 3, 0): (0, 1), (7, 23, 3, 1): (-1, 1), (7, 23, 3, 2): (0, 1), (7, 23, 3, 3): (0, 1), (7, 23, 3, 4): (0, 1), (7, 23, 3, 5): (0, 1), (7, 23, 4, -5): (0, 0), (7, 23, 4, -4): (0, 1), (7, 23, 4, -3): (0, 1), (7, 23, 4, -2): (0, 1), (7, 23, 4, -1): (0, 1), (7, 23, 4, 0): (0, 1), (7, 23, 4, 1): (0, 1), (7, 23, 4, 2): (0, 1), (7, 23, 4, 3): (0, 1), (7, 23, 4, 4): (0, 1), (7, 23, 4, 5): (0, 1), (7, 23, 5, -5): (0, 0), (7, 23, 5, -4): (0, 1), (7, 23, 5, -3): (0, 1), (7, 23, 5, -2): (0, 1), (7, 23, 5, -1): (0, 1), (7, 23, 5, 0): (0, 1), (7, 23, 5, 1): (0, 1), (7, 23, 5, 2): (0, 1), (7, 23, 5, 3): (0, 1), (7, 23, 5, 4): (0, 1), (7, 23, 5, 5): (0, 1), (7, 24, -5, -5): (0, 1), (7, 24, -5, -4): (0, 1), (7, 24, -5, -3): (0, 1), (7, 24, -5, -2): (0, 1), (7, 24, -5, -1): (0, 1), (7, 24, -5, 0): (0, 1), (7, 24, -5, 1): (0, 1), (7, 24, -5, 2): (0, 1), (7, 24, -5, 3): (0, 1), (7, 24, -5, 4): (0, 1), (7, 24, -5, 5): (0, 1), (7, 24, -4, -5): (0, 1), (7, 24, -4, -4): (0, 1), (7, 24, -4, -3): (0, 1), (7, 24, -4, -2): (0, 1), (7, 24, -4, -1): (0, 1), (7, 24, -4, 0): (0, 1), (7, 24, -4, 1): (0, 1), (7, 24, -4, 2): (0, 1), (7, 24, -4, 3): (0, 1), (7, 24, -4, 4): (-1, 1), (7, 24, -4, 5): (-1, 1), (7, 24, -3, -5): (0, 1), (7, 24, -3, -4): (0, 1), (7, 24, -3, -3): (0, 1), (7, 24, -3, -2): (0, 1), (7, 24, -3, -1): (0, 1), (7, 24, -3, 0): (0, 1), (7, 24, -3, 1): (0, 1), (7, 24, -3, 2): (0, 1), (7, 24, -3, 3): (0, 1), (7, 24, -3, 4): (0, 1), (7, 24, -3, 5): (0, 1), (7, 24, -2, -5): (0, 1), (7, 24, -2, -4): (0, 1), (7, 24, -2, -3): (0, 1), (7, 24, -2, -2): (0, 1), (7, 24, -2, -1): (0, 1), (7, 24, -2, 0): (1, 1), (7, 24, -2, 1): (1, 1), (7, 24, -2, 2): (1, 1), (7, 24, -2, 3): (1, 1), (7, 24, -2, 4): (1, 0), (7, 24, -2, 5): (1, -1), (7, 24, -1, -5): (-1, 1), (7, 24, -1, -4): (-1, 1), (7, 24, -1, -3): (-1, 1), (7, 24, -1, -2): (-1, 1), (7, 24, -1, -1): (1, 1), (7, 24, -1, 0): (1, 1), (7, 24, -1, 1): (1, 1), (7, 24, -1, 2): (1, 0), (7, 24, -1, 3): (0, 1), (7, 24, -1, 4): (0, 0), (7, 24, -1, 5): (0, -1), (7, 24, 0, -5): (-1, 1), (7, 24, 0, -4): (-1, 1), (7, 24, 0, -3): (1, 1), (7, 24, 0, -2): (1, 1), (7, 24, 0, -1): (1, 1), (7, 24, 0, 0): (0, 1), (7, 24, 0, 1): (0, 1), (7, 24, 0, 2): (0, 0), (7, 24, 0, 3): (-1, 1), (7, 24, 0, 4): (-1, 0), (7, 24, 0, 5): (-1, -1), (7, 24, 1, -5): (1, 1), (7, 24, 1, -4): (1, 1), (7, 24, 1, -3): (1, 1), (7, 24, 1, -2): (1, 1), (7, 24, 1, -1): (0, 1), (7, 24, 1, 0): (-1, 1), (7, 24, 1, 1): (-1, 1), (7, 24, 1, 2): (-1, 0), (7, 24, 1, 3): (-1, -1), (7, 24, 1, 4): (-1, -1), (7, 24, 1, 5): (-1, -1), (7, 24, 2, -5): (1, 1), (7, 24, 2, -4): (1, 1), (7, 24, 2, -3): (1, 1), (7, 24, 2, -2): (1, 1), (7, 24, 2, -1): (1, 1), (7, 24, 2, 0): (0, 1), (7, 24, 2, 1): (1, 1), (7, 24, 2, 2): (1, 1), (7, 24, 2, 3): (1, 1), (7, 24, 2, 4): (1, 1), (7, 24, 2, 5): (1, 0), (7, 24, 3, -5): (0, 1), (7, 24, 3, -4): (0, 1), (7, 24, 3, -3): (0, 1), (7, 24, 3, -2): (0, 1), (7, 24, 3, -1): (0, 1), (7, 24, 3, 0): (-1, 1), (7, 24, 3, 1): (0, 1), (7, 24, 3, 2): (0, 1), (7, 24, 3, 3): (0, 1), (7, 24, 3, 4): (0, 1), (7, 24, 3, 5): (0, 1), (7, 24, 4, -5): (0, 1), (7, 24, 4, -4): (0, 1), (7, 24, 4, -3): (0, 1), (7, 24, 4, -2): (0, 1), (7, 24, 4, -1): (0, 1), (7, 24, 4, 0): (0, 1), (7, 24, 4, 1): (0, 1), (7, 24, 4, 2): (0, 1), (7, 24, 4, 3): (0, 1), (7, 24, 4, 4): (0, 1), (7, 24, 4, 5): (0, 1), (7, 24, 5, -5): (0, 1), (7, 24, 5, -4): (0, 1), (7, 24, 5, -3): (0, 1), (7, 24, 5, -2): (0, 1), (7, 24, 5, -1): (0, 1), (7, 24, 5, 0): (0, 1), (7, 24, 5, 1): (0, 1), (7, 24, 5, 2): (0, 1), (7, 24, 5, 3): (0, 1), (7, 24, 5, 4): (0, 1), (7, 24, 5, 5): (0, 1), (7, 25, -5, -5): (0, 1), (7, 25, -5, -4): (0, 1), (7, 25, -5, -3): (0, 1), (7, 25, -5, -2): (0, 1), (7, 25, -5, -1): (0, 1), (7, 25, -5, 0): (0, 1), (7, 25, -5, 1): (0, 1), (7, 25, -5, 2): (0, 1), (7, 25, -5, 3): (0, 1), (7, 25, -5, 4): (0, 1), (7, 25, -5, 5): (0, 1), (7, 25, -4, -5): (0, 1), (7, 25, -4, -4): (0, 1), (7, 25, -4, -3): (0, 1), (7, 25, -4, -2): (0, 1), (7, 25, -4, -1): (0, 1), (7, 25, -4, 0): (0, 1), (7, 25, -4, 1): (0, 1), (7, 25, -4, 2): (0, 1), (7, 25, -4, 3): (-1, 1), (7, 25, -4, 4): (-1, 1), (7, 25, -4, 5): (-1, 1), (7, 25, -3, -5): (0, 1), (7, 25, -3, -4): (0, 1), (7, 25, -3, -3): (0, 1), (7, 25, -3, -2): (0, 1), (7, 25, -3, -1): (0, 1), (7, 25, -3, 0): (0, 1), (7, 25, -3, 1): (0, 1), (7, 25, -3, 2): (0, 1), (7, 25, -3, 3): (0, 1), (7, 25, -3, 4): (-1, 1), (7, 25, -3, 5): (-1, 1), (7, 25, -2, -5): (0, 1), (7, 25, -2, -4): (0, 1), (7, 25, -2, -3): (0, 1), (7, 25, -2, -2): (0, 1), (7, 25, -2, -1): (0, 1), (7, 25, -2, 0): (1, 1), (7, 25, -2, 1): (1, 1), (7, 25, -2, 2): (1, 1), (7, 25, -2, 3): (1, 0), (7, 25, -2, 4): (1, -1), (7, 25, -2, 5): (1, -1), (7, 25, -1, -5): (-1, 1), (7, 25, -1, -4): (-1, 1), (7, 25, -1, -3): (-1, 1), (7, 25, -1, -2): (-1, 1), (7, 25, -1, -1): (1, 1), (7, 25, -1, 0): (1, 1), (7, 25, -1, 1): (1, 1), (7, 25, -1, 2): (0, 1), (7, 25, -1, 3): (0, 0), (7, 25, -1, 4): (0, -1), (7, 25, -1, 5): (0, -1), (7, 25, 0, -5): (-1, 1), (7, 25, 0, -4): (-1, 1), (7, 25, 0, -3): (1, 1), (7, 25, 0, -2): (1, 1), (7, 25, 0, -1): (1, 1), (7, 25, 0, 0): (0, 1), (7, 25, 0, 1): (0, 1), (7, 25, 0, 2): (-1, 1), (7, 25, 0, 3): (-1, 0), (7, 25, 0, 4): (-1, -1), (7, 25, 0, 5): (-1, -1), (7, 25, 1, -5): (1, 1), (7, 25, 1, -4): (1, 1), (7, 25, 1, -3): (1, 1), (7, 25, 1, -2): (1, 1), (7, 25, 1, -1): (0, 1), (7, 25, 1, 0): (-1, 1), (7, 25, 1, 1): (-1, 1), (7, 25, 1, 2): (-1, 1), (7, 25, 1, 3): (-1, 0), (7, 25, 1, 4): (-1, -1), (7, 25, 1, 5): (-1, -1), (7, 25, 2, -5): (1, 1), (7, 25, 2, -4): (1, 1), (7, 25, 2, -3): (1, 1), (7, 25, 2, -2): (1, 1), (7, 25, 2, -1): (1, 1), (7, 25, 2, 0): (1, 1), (7, 25, 2, 1): (1, 1), (7, 25, 2, 2): (1, 1), (7, 25, 2, 3): (1, 1), (7, 25, 2, 4): (1, 0), (7, 25, 2, 5): (1, -1), (7, 25, 3, -5): (0, 1), (7, 25, 3, -4): (0, 1), (7, 25, 3, -3): (0, 1), (7, 25, 3, -2): (0, 1), (7, 25, 3, -1): (0, 1), (7, 25, 3, 0): (0, 1), (7, 25, 3, 1): (0, 1), (7, 25, 3, 2): (0, 1), (7, 25, 3, 3): (0, 1), (7, 25, 3, 4): (0, 0), (7, 25, 3, 5): (0, -1), (7, 25, 4, -5): (0, 1), (7, 25, 4, -4): (0, 1), (7, 25, 4, -3): (0, 1), (7, 25, 4, -2): (0, 1), (7, 25, 4, -1): (0, 1), (7, 25, 4, 0): (0, 1), (7, 25, 4, 1): (0, 1), (7, 25, 4, 2): (0, 1), (7, 25, 4, 3): (0, 1), (7, 25, 4, 4): (0, 0), (7, 25, 4, 5): (-1, -1), (7, 25, 5, -5): (0, 1), (7, 25, 5, -4): (0, 1), (7, 25, 5, -3): (0, 1), (7, 25, 5, -2): (0, 1), (7, 25, 5, -1): (0, 1), (7, 25, 5, 0): (0, 1), (7, 25, 5, 1): (0, 1), (7, 25, 5, 2): (0, 1), (7, 25, 5, 3): (0, 1), (7, 25, 5, 4): (0, 0), (7, 25, 5, 5): (-1, -1), (7, 26, -5, -5): (0, 1), (7, 26, -5, -4): (0, 1), (7, 26, -5, -3): (0, 1), (7, 26, -5, -2): (0, 1), (7, 26, -5, -1): (0, 1), (7, 26, -5, 0): (0, 1), (7, 26, -5, 1): (0, 1), (7, 26, -5, 2): (0, 1), (7, 26, -5, 3): (0, 1), (7, 26, -5, 4): (0, 1), (7, 26, -5, 5): (0, 1), (7, 26, -4, -5): (0, 1), (7, 26, -4, -4): (0, 1), (7, 26, -4, -3): (0, 1), (7, 26, -4, -2): (0, 1), (7, 26, -4, -1): (0, 1), (7, 26, -4, 0): (0, 1), (7, 26, -4, 1): (0, 1), (7, 26, -4, 2): (-1, 1), (7, 26, -4, 3): (-1, 1), (7, 26, -4, 4): (-1, 1), (7, 26, -4, 5): (-1, 1), (7, 26, -3, -5): (0, 1), (7, 26, -3, -4): (0, 1), (7, 26, -3, -3): (0, 1), (7, 26, -3, -2): (0, 1), (7, 26, -3, -1): (0, 1), (7, 26, -3, 0): (0, 1), (7, 26, -3, 1): (0, 1), (7, 26, -3, 2): (0, 1), (7, 26, -3, 3): (-1, 1), (7, 26, -3, 4): (-1, 1), (7, 26, -3, 5): (-1, 1), (7, 26, -2, -5): (0, 1), (7, 26, -2, -4): (0, 1), (7, 26, -2, -3): (0, 1), (7, 26, -2, -2): (0, 1), (7, 26, -2, -1): (0, 1), (7, 26, -2, 0): (1, 1), (7, 26, -2, 1): (1, 1), (7, 26, -2, 2): (1, 1), (7, 26, -2, 3): (1, 0), (7, 26, -2, 4): (-1, 1), (7, 26, -2, 5): (-1, 1), (7, 26, -1, -5): (-1, 1), (7, 26, -1, -4): (-1, 1), (7, 26, -1, -3): (-1, 1), (7, 26, -1, -2): (-1, 1), (7, 26, -1, -1): (1, 1), (7, 26, -1, 0): (1, 1), (7, 26, -1, 1): (1, 1), (7, 26, -1, 2): (0, 1), (7, 26, -1, 3): (0, 0), (7, 26, -1, 4): (0, -1), (7, 26, -1, 5): (0, -1), (7, 26, 0, -5): (-1, 1), (7, 26, 0, -4): (1, 1), (7, 26, 0, -3): (1, 1), (7, 26, 0, -2): (1, 1), (7, 26, 0, -1): (0, 1), (7, 26, 0, 0): (0, 1), (7, 26, 0, 1): (0, 1), (7, 26, 0, 2): (-1, 1), (7, 26, 0, 3): (-1, 0), (7, 26, 0, 4): (-1, -1), (7, 26, 0, 5): (-1, -1), (7, 26, 1, -5): (1, 1), (7, 26, 1, -4): (1, 1), (7, 26, 1, -3): (1, 1), (7, 26, 1, -2): (1, 1), (7, 26, 1, -1): (-1, 1), (7, 26, 1, 0): (-1, 1), (7, 26, 1, 1): (-1, 1), (7, 26, 1, 2): (-1, 0), (7, 26, 1, 3): (-1, -1), (7, 26, 1, 4): (-1, -1), (7, 26, 1, 5): (-1, 1), (7, 26, 2, -5): (1, 1), (7, 26, 2, -4): (1, 1), (7, 26, 2, -3): (1, 1), (7, 26, 2, -2): (1, 1), (7, 26, 2, -1): (1, 1), (7, 26, 2, 0): (1, 1), (7, 26, 2, 1): (1, 1), (7, 26, 2, 2): (1, 1), (7, 26, 2, 3): (1, 0), (7, 26, 2, 4): (1, -1), (7, 26, 2, 5): (1, -1), (7, 26, 3, -5): (0, 1), (7, 26, 3, -4): (0, 1), (7, 26, 3, -3): (0, 1), (7, 26, 3, -2): (0, 1), (7, 26, 3, -1): (0, 1), (7, 26, 3, 0): (0, 1), (7, 26, 3, 1): (0, 1), (7, 26, 3, 2): (0, 1), (7, 26, 3, 3): (0, 0), (7, 26, 3, 4): (0, -1), (7, 26, 3, 5): (0, -1), (7, 26, 4, -5): (0, 1), (7, 26, 4, -4): (0, 1), (7, 26, 4, -3): (0, 1), (7, 26, 4, -2): (0, 1), (7, 26, 4, -1): (0, 1), (7, 26, 4, 0): (0, 1), (7, 26, 4, 1): (0, 1), (7, 26, 4, 2): (0, 1), (7, 26, 4, 3): (0, 0), (7, 26, 4, 4): (-1, -1), (7, 26, 4, 5): (-1, -1), (7, 26, 5, -5): (0, 1), (7, 26, 5, -4): (0, 1), (7, 26, 5, -3): (0, 1), (7, 26, 5, -2): (0, 1), (7, 26, 5, -1): (0, 1), (7, 26, 5, 0): (0, 1), (7, 26, 5, 1): (0, 1), (7, 26, 5, 2): (0, 1), (7, 26, 5, 3): (0, 0), (7, 26, 5, 4): (-1, -1), (7, 26, 5, 5): (-1, -1), (7, 27, -5, -5): (0, 1), (7, 27, -5, -4): (0, 1), (7, 27, -5, -3): (0, 1), (7, 27, -5, -2): (0, 1), (7, 27, -5, -1): (0, 1), (7, 27, -5, 0): (0, 1), (7, 27, -5, 1): (0, 1), (7, 27, -5, 2): (0, 1), (7, 27, -5, 3): (0, 1), (7, 27, -5, 4): (0, 0), (7, 27, -5, 5): (-1, -1), (7, 27, -4, -5): (0, 1), (7, 27, -4, -4): (0, 1), (7, 27, -4, -3): (0, 1), (7, 27, -4, -2): (0, 1), (7, 27, -4, -1): (0, 1), (7, 27, -4, 0): (0, 1), (7, 27, -4, 1): (-1, 1), (7, 27, -4, 2): (-1, 1), (7, 27, -4, 3): (-1, 1), (7, 27, -4, 4): (-1, 0), (7, 27, -4, 5): (-1, -1), (7, 27, -3, -5): (0, 1), (7, 27, -3, -4): (0, 1), (7, 27, -3, -3): (0, 1), (7, 27, -3, -2): (0, 1), (7, 27, -3, -1): (0, 1), (7, 27, -3, 0): (0, 1), (7, 27, -3, 1): (0, 1), (7, 27, -3, 2): (-1, 1), (7, 27, -3, 3): (-1, 1), (7, 27, -3, 4): (0, 1), (7, 27, -3, 5): (0, 1), (7, 27, -2, -5): (0, 1), (7, 27, -2, -4): (0, 1), (7, 27, -2, -3): (0, 1), (7, 27, -2, -2): (0, 1), (7, 27, -2, -1): (0, 1), (7, 27, -2, 0): (1, 1), (7, 27, -2, 1): (1, 1), (7, 27, -2, 2): (1, 1), (7, 27, -2, 3): (-1, 1), (7, 27, -2, 4): (-1, 1), (7, 27, -2, 5): (-1, 1), (7, 27, -1, -5): (-1, 1), (7, 27, -1, -4): (-1, 1), (7, 27, -1, -3): (-1, 1), (7, 27, -1, -2): (-1, 1), (7, 27, -1, -1): (1, 1), (7, 27, -1, 0): (1, 1), (7, 27, -1, 1): (0, 1), (7, 27, -1, 2): (0, 1), (7, 27, -1, 3): (0, 0), (7, 27, -1, 4): (-1, 1), (7, 27, -1, 5): (-1, 1), (7, 27, 0, -5): (-1, 1), (7, 27, 0, -4): (1, 1), (7, 27, 0, -3): (1, 1), (7, 27, 0, -2): (1, 1), (7, 27, 0, -1): (0, 1), (7, 27, 0, 0): (0, 1), (7, 27, 0, 1): (-1, 1), (7, 27, 0, 2): (-1, 1), (7, 27, 0, 3): (-1, 0), (7, 27, 0, 4): (-1, -1), (7, 27, 0, 5): (-1, -1), (7, 27, 1, -5): (1, 1), (7, 27, 1, -4): (1, 1), (7, 27, 1, -3): (1, 1), (7, 27, 1, -2): (1, 1), (7, 27, 1, -1): (-1, 1), (7, 27, 1, 0): (-1, 1), (7, 27, 1, 1): (-1, 0), (7, 27, 1, 2): (-1, -1), (7, 27, 1, 3): (-1, -1), (7, 27, 1, 4): (-1, -1), (7, 27, 1, 5): (-1, 1), (7, 27, 2, -5): (1, 1), (7, 27, 2, -4): (1, 1), (7, 27, 2, -3): (1, 1), (7, 27, 2, -2): (1, 1), (7, 27, 2, -1): (1, 1), (7, 27, 2, 0): (1, 1), (7, 27, 2, 1): (1, 1), (7, 27, 2, 2): (1, 0), (7, 27, 2, 3): (1, -1), (7, 27, 2, 4): (1, 1), (7, 27, 2, 5): (1, 0), (7, 27, 3, -5): (0, 1), (7, 27, 3, -4): (0, 1), (7, 27, 3, -3): (0, 1), (7, 27, 3, -2): (0, 1), (7, 27, 3, -1): (0, 1), (7, 27, 3, 0): (0, 1), (7, 27, 3, 1): (0, 1), (7, 27, 3, 2): (0, 0), (7, 27, 3, 3): (0, -1), (7, 27, 3, 4): (0, 1), (7, 27, 3, 5): (0, 1), (7, 27, 4, -5): (0, 1), (7, 27, 4, -4): (0, 1), (7, 27, 4, -3): (0, 1), (7, 27, 4, -2): (0, 1), (7, 27, 4, -1): (0, 1), (7, 27, 4, 0): (0, 1), (7, 27, 4, 1): (0, 1), (7, 27, 4, 2): (0, 0), (7, 27, 4, 3): (-1, -1), (7, 27, 4, 4): (0, 1), (7, 27, 4, 5): (0, 1), (7, 27, 5, -5): (0, 1), (7, 27, 5, -4): (0, 1), (7, 27, 5, -3): (0, 1), (7, 27, 5, -2): (0, 1), (7, 27, 5, -1): (0, 1), (7, 27, 5, 0): (0, 1), (7, 27, 5, 1): (0, 1), (7, 27, 5, 2): (0, 0), (7, 27, 5, 3): (-1, -1), (7, 27, 5, 4): (0, 1), (7, 27, 5, 5): (0, 1), (7, 28, -5, -5): (0, 1), (7, 28, -5, -4): (0, 1), (7, 28, -5, -3): (0, 1), (7, 28, -5, -2): (0, 1), (7, 28, -5, -1): (0, 1), (7, 28, -5, 0): (0, 1), (7, 28, -5, 1): (0, 1), (7, 28, -5, 2): (0, 1), (7, 28, -5, 3): (0, 1), (7, 28, -5, 4): (0, 0), (7, 28, -5, 5): (-1, -1), (7, 28, -4, -5): (0, 1), (7, 28, -4, -4): (0, 1), (7, 28, -4, -3): (0, 1), (7, 28, -4, -2): (0, 1), (7, 28, -4, -1): (0, 1), (7, 28, -4, 0): (-1, 1), (7, 28, -4, 1): (-1, 1), (7, 28, -4, 2): (-1, 1), (7, 28, -4, 3): (0, 1), (7, 28, -4, 4): (0, 0), (7, 28, -4, 5): (-1, -1), (7, 28, -3, -5): (0, 1), (7, 28, -3, -4): (0, 1), (7, 28, -3, -3): (0, 1), (7, 28, -3, -2): (0, 1), (7, 28, -3, -1): (0, 1), (7, 28, -3, 0): (0, 1), (7, 28, -3, 1): (-1, 1), (7, 28, -3, 2): (-1, 1), (7, 28, -3, 3): (0, 1), (7, 28, -3, 4): (0, 0), (7, 28, -3, 5): (-1, -1), (7, 28, -2, -5): (0, 1), (7, 28, -2, -4): (0, 1), (7, 28, -2, -3): (0, 1), (7, 28, -2, -2): (0, 1), (7, 28, -2, -1): (0, 1), (7, 28, -2, 0): (1, 1), (7, 28, -2, 1): (1, 1), (7, 28, -2, 2): (-1, 1), (7, 28, -2, 3): (-1, 1), (7, 28, -2, 4): (-1, 0), (7, 28, -2, 5): (-1, -1), (7, 28, -1, -5): (-1, 1), (7, 28, -1, -4): (-1, 1), (7, 28, -1, -3): (-1, 1), (7, 28, -1, -2): (-1, 1), (7, 28, -1, -1): (1, 1), (7, 28, -1, 0): (1, 1), (7, 28, -1, 1): (0, 1), (7, 28, -1, 2): (0, 0), (7, 28, -1, 3): (-1, 1), (7, 28, -1, 4): (-1, 1), (7, 28, -1, 5): (-1, 1), (7, 28, 0, -5): (-1, 1), (7, 28, 0, -4): (1, 1), (7, 28, 0, -3): (1, 1), (7, 28, 0, -2): (1, 1), (7, 28, 0, -1): (0, 1), (7, 28, 0, 0): (0, 1), (7, 28, 0, 1): (-1, 1), (7, 28, 0, 2): (-1, 0), (7, 28, 0, 3): (-1, -1), (7, 28, 0, 4): (-1, -1), (7, 28, 0, 5): (-1, -1), (7, 28, 1, -5): (1, 1), (7, 28, 1, -4): (1, 1), (7, 28, 1, -3): (1, 1), (7, 28, 1, -2): (1, 1), (7, 28, 1, -1): (-1, 1), (7, 28, 1, 0): (-1, 1), (7, 28, 1, 1): (-1, 0), (7, 28, 1, 2): (-1, -1), (7, 28, 1, 3): (-1, -1), (7, 28, 1, 4): (-1, -1), (7, 28, 1, 5): (-1, 1), (7, 28, 2, -5): (1, 1), (7, 28, 2, -4): (1, 1), (7, 28, 2, -3): (1, 1), (7, 28, 2, -2): (1, 1), (7, 28, 2, -1): (1, 1), (7, 28, 2, 0): (1, 1), (7, 28, 2, 1): (1, 0), (7, 28, 2, 2): (1, -1), (7, 28, 2, 3): (1, 1), (7, 28, 2, 4): (1, 0), (7, 28, 2, 5): (1, 0), (7, 28, 3, -5): (0, 1), (7, 28, 3, -4): (0, 1), (7, 28, 3, -3): (0, 1), (7, 28, 3, -2): (0, 1), (7, 28, 3, -1): (0, 1), (7, 28, 3, 0): (0, 1), (7, 28, 3, 1): (0, 0), (7, 28, 3, 2): (0, -1), (7, 28, 3, 3): (0, 1), (7, 28, 3, 4): (0, 1), (7, 28, 3, 5): (0, 1), (7, 28, 4, -5): (0, 1), (7, 28, 4, -4): (0, 1), (7, 28, 4, -3): (0, 1), (7, 28, 4, -2): (0, 1), (7, 28, 4, -1): (0, 1), (7, 28, 4, 0): (0, 1), (7, 28, 4, 1): (0, 0), (7, 28, 4, 2): (-1, -1), (7, 28, 4, 3): (0, 1), (7, 28, 4, 4): (0, 1), (7, 28, 4, 5): (0, 1), (7, 28, 5, -5): (0, 1), (7, 28, 5, -4): (0, 1), (7, 28, 5, -3): (0, 1), (7, 28, 5, -2): (0, 1), (7, 28, 5, -1): (0, 1), (7, 28, 5, 0): (0, 1), (7, 28, 5, 1): (0, 0), (7, 28, 5, 2): (-1, -1), (7, 28, 5, 3): (0, 1), (7, 28, 5, 4): (0, 1), (7, 28, 5, 5): (0, 1), (7, 29, -5, -5): (0, 1), (7, 29, -5, -4): (0, 1), (7, 29, -5, -3): (0, 1), (7, 29, -5, -2): (0, 1), (7, 29, -5, -1): (0, 1), (7, 29, -5, 0): (0, 1), (7, 29, -5, 1): (0, 1), (7, 29, -5, 2): (0, 1), (7, 29, -5, 3): (0, 0), (7, 29, -5, 4): (-1, -1), (7, 29, -5, 5): (0, 1), (7, 29, -4, -5): (0, 1), (7, 29, -4, -4): (0, 1), (7, 29, -4, -3): (0, 1), (7, 29, -4, -2): (0, 1), (7, 29, -4, -1): (-1, 1), (7, 29, -4, 0): (-1, 1), (7, 29, -4, 1): (-1, 1), (7, 29, -4, 2): (0, 1), (7, 29, -4, 3): (0, 0), (7, 29, -4, 4): (-1, -1), (7, 29, -4, 5): (0, 1), (7, 29, -3, -5): (0, 1), (7, 29, -3, -4): (0, 1), (7, 29, -3, -3): (0, 1), (7, 29, -3, -2): (0, 1), (7, 29, -3, -1): (0, 1), (7, 29, -3, 0): (-1, 1), (7, 29, -3, 1): (-1, 1), (7, 29, -3, 2): (0, 1), (7, 29, -3, 3): (0, 0), (7, 29, -3, 4): (-1, -1), (7, 29, -3, 5): (0, 1), (7, 29, -2, -5): (0, 1), (7, 29, -2, -4): (0, 1), (7, 29, -2, -3): (0, 1), (7, 29, -2, -2): (0, 1), (7, 29, -2, -1): (0, 1), (7, 29, -2, 0): (1, 1), (7, 29, -2, 1): (1, 1), (7, 29, -2, 2): (-1, 1), (7, 29, -2, 3): (-1, 0), (7, 29, -2, 4): (-1, -1), (7, 29, -2, 5): (-1, 1), (7, 29, -1, -5): (-1, 1), (7, 29, -1, -4): (-1, 1), (7, 29, -1, -3): (-1, 1), (7, 29, -1, -2): (-1, 1), (7, 29, -1, -1): (1, 1), (7, 29, -1, 0): (0, 1), (7, 29, -1, 1): (0, 1), (7, 29, -1, 2): (-1, 1), (7, 29, -1, 3): (-1, 0), (7, 29, -1, 4): (-1, -1), (7, 29, -1, 5): (-1, 1), (7, 29, 0, -5): (1, 1), (7, 29, 0, -4): (1, 1), (7, 29, 0, -3): (1, 1), (7, 29, 0, -2): (1, 1), (7, 29, 0, -1): (0, 1), (7, 29, 0, 0): (-1, 1), (7, 29, 0, 1): (-1, 1), (7, 29, 0, 2): (-1, 0), (7, 29, 0, 3): (-1, -1), (7, 29, 0, 4): (-1, -1), (7, 29, 0, 5): (-1, 1), (7, 29, 1, -5): (1, 1), (7, 29, 1, -4): (1, 1), (7, 29, 1, -3): (1, 1), (7, 29, 1, -2): (1, 1), (7, 29, 1, -1): (-1, 1), (7, 29, 1, 0): (-1, 1), (7, 29, 1, 1): (-1, 0), (7, 29, 1, 2): (-1, -1), (7, 29, 1, 3): (-1, -1), (7, 29, 1, 4): (-1, -1), (7, 29, 1, 5): (-1, 1), (7, 29, 2, -5): (1, 1), (7, 29, 2, -4): (1, 1), (7, 29, 2, -3): (1, 1), (7, 29, 2, -2): (1, 1), (7, 29, 2, -1): (1, 1), (7, 29, 2, 0): (1, 0), (7, 29, 2, 1): (1, -1), (7, 29, 2, 2): (1, 1), (7, 29, 2, 3): (1, 0), (7, 29, 2, 4): (1, 0), (7, 29, 2, 5): (1, 0), (7, 29, 3, -5): (0, 1), (7, 29, 3, -4): (0, 1), (7, 29, 3, -3): (0, 1), (7, 29, 3, -2): (0, 1), (7, 29, 3, -1): (0, 1), (7, 29, 3, 0): (0, 0), (7, 29, 3, 1): (0, -1), (7, 29, 3, 2): (0, 1), (7, 29, 3, 3): (0, 1), (7, 29, 3, 4): (0, 1), (7, 29, 3, 5): (0, 1), (7, 29, 4, -5): (0, 1), (7, 29, 4, -4): (0, 1), (7, 29, 4, -3): (0, 1), (7, 29, 4, -2): (0, 1), (7, 29, 4, -1): (0, 1), (7, 29, 4, 0): (0, 0), (7, 29, 4, 1): (-1, -1), (7, 29, 4, 2): (0, 1), (7, 29, 4, 3): (0, 1), (7, 29, 4, 4): (0, 1), (7, 29, 4, 5): (0, 1), (7, 29, 5, -5): (0, 1), (7, 29, 5, -4): (0, 1), (7, 29, 5, -3): (0, 1), (7, 29, 5, -2): (0, 1), (7, 29, 5, -1): (0, 1), (7, 29, 5, 0): (0, 0), (7, 29, 5, 1): (-1, -1), (7, 29, 5, 2): (0, 1), (7, 29, 5, 3): (0, 1), (7, 29, 5, 4): (0, 1), (7, 29, 5, 5): (0, 1), (7, 30, -5, -5): (0, 1), (7, 30, -5, -4): (0, 1), (7, 30, -5, -3): (0, 1), (7, 30, -5, -2): (0, 1), (7, 30, -5, -1): (0, 1), (7, 30, -5, 0): (0, 1), (7, 30, -5, 1): (0, 1), (7, 30, -5, 2): (0, 0), (7, 30, -5, 3): (-1, -1), (7, 30, -5, 4): (-1, -1), (7, 30, -5, 5): (0, 1), (7, 30, -4, -5): (0, 1), (7, 30, -4, -4): (0, 1), (7, 30, -4, -3): (0, 1), (7, 30, -4, -2): (-1, 1), (7, 30, -4, -1): (-1, 1), (7, 30, -4, 0): (-1, 1), (7, 30, -4, 1): (0, 1), (7, 30, -4, 2): (0, 0), (7, 30, -4, 3): (-1, -1), (7, 30, -4, 4): (-1, -1), (7, 30, -4, 5): (0, 1), (7, 30, -3, -5): (0, 1), (7, 30, -3, -4): (0, 1), (7, 30, -3, -3): (0, 1), (7, 30, -3, -2): (0, 1), (7, 30, -3, -1): (-1, 1), (7, 30, -3, 0): (-1, 1), (7, 30, -3, 1): (0, 1), (7, 30, -3, 2): (0, 0), (7, 30, -3, 3): (-1, -1), (7, 30, -3, 4): (-1, -1), (7, 30, -3, 5): (0, 1), (7, 30, -2, -5): (0, 1), (7, 30, -2, -4): (0, 1), (7, 30, -2, -3): (0, 1), (7, 30, -2, -2): (0, 1), (7, 30, -2, -1): (1, 1), (7, 30, -2, 0): (1, 1), (7, 30, -2, 1): (-1, 1), (7, 30, -2, 2): (-1, 0), (7, 30, -2, 3): (-1, -1), (7, 30, -2, 4): (-1, -1), (7, 30, -2, 5): (-1, 1), (7, 30, -1, -5): (-1, 1), (7, 30, -1, -4): (-1, 1), (7, 30, -1, -3): (-1, 1), (7, 30, -1, -2): (-1, 1), (7, 30, -1, -1): (1, 1), (7, 30, -1, 0): (0, 1), (7, 30, -1, 1): (-1, 1), (7, 30, -1, 2): (-1, 0), (7, 30, -1, 3): (-1, -1), (7, 30, -1, 4): (-1, 1), (7, 30, -1, 5): (-1, 1), (7, 30, 0, -5): (1, 1), (7, 30, 0, -4): (1, 1), (7, 30, 0, -3): (1, 1), (7, 30, 0, -2): (0, 1), (7, 30, 0, -1): (0, 1), (7, 30, 0, 0): (-1, 1), (7, 30, 0, 1): (-1, 0), (7, 30, 0, 2): (-1, -1), (7, 30, 0, 3): (-1, -1), (7, 30, 0, 4): (-1, -1), (7, 30, 0, 5): (-1, 1), (7, 30, 1, -5): (1, 1), (7, 30, 1, -4): (1, 1), (7, 30, 1, -3): (1, 1), (7, 30, 1, -2): (-1, 1), (7, 30, 1, -1): (-1, 1), (7, 30, 1, 0): (-1, 1), (7, 30, 1, 1): (-1, 0), (7, 30, 1, 2): (-1, -1), (7, 30, 1, 3): (-1, -1), (7, 30, 1, 4): (-1, 1), (7, 30, 1, 5): (-1, 1), (7, 30, 2, -5): (1, 1), (7, 30, 2, -4): (1, 1), (7, 30, 2, -3): (1, 1), (7, 30, 2, -2): (1, 1), (7, 30, 2, -1): (1, 0), (7, 30, 2, 0): (1, -1), (7, 30, 2, 1): (1, 1), (7, 30, 2, 2): (1, 0), (7, 30, 2, 3): (1, 0), (7, 30, 2, 4): (1, 0), (7, 30, 2, 5): (1, 0), (7, 30, 3, -5): (0, 1), (7, 30, 3, -4): (0, 1), (7, 30, 3, -3): (0, 1), (7, 30, 3, -2): (0, 1), (7, 30, 3, -1): (0, 0), (7, 30, 3, 0): (0, -1), (7, 30, 3, 1): (0, 1), (7, 30, 3, 2): (0, 1), (7, 30, 3, 3): (0, 1), (7, 30, 3, 4): (0, 1), (7, 30, 3, 5): (0, 1), (7, 30, 4, -5): (0, 1), (7, 30, 4, -4): (0, 1), (7, 30, 4, -3): (0, 1), (7, 30, 4, -2): (0, 1), (7, 30, 4, -1): (0, 0), (7, 30, 4, 0): (-1, -1), (7, 30, 4, 1): (0, 1), (7, 30, 4, 2): (0, 1), (7, 30, 4, 3): (0, 1), (7, 30, 4, 4): (0, 1), (7, 30, 4, 5): (0, 1), (7, 30, 5, -5): (0, 1), (7, 30, 5, -4): (0, 1), (7, 30, 5, -3): (0, 1), (7, 30, 5, -2): (0, 1), (7, 30, 5, -1): (0, 0), (7, 30, 5, 0): (-1, -1), (7, 30, 5, 1): (0, 1), (7, 30, 5, 2): (0, 1), (7, 30, 5, 3): (0, 1), (7, 30, 5, 4): (0, 1), (7, 30, 5, 5): (0, 1), (7, 31, -5, -5): (0, 1), (7, 31, -5, -4): (0, 1), (7, 31, -5, -3): (0, 1), (7, 31, -5, -2): (0, 1), (7, 31, -5, -1): (0, 1), (7, 31, -5, 0): (0, 1), (7, 31, -5, 1): (0, 1), (7, 31, -5, 2): (0, 0), (7, 31, -5, 3): (-1, -1), (7, 31, -5, 4): (0, 1), (7, 31, -5, 5): (0, 1), (7, 31, -4, -5): (0, 1), (7, 31, -4, -4): (0, 1), (7, 31, -4, -3): (-1, 1), (7, 31, -4, -2): (-1, 1), (7, 31, -4, -1): (-1, 1), (7, 31, -4, 0): (0, 1), (7, 31, -4, 1): (0, 1), (7, 31, -4, 2): (0, 0), (7, 31, -4, 3): (-1, -1), (7, 31, -4, 4): (-1, 1), (7, 31, -4, 5): (-1, 1), (7, 31, -3, -5): (0, 1), (7, 31, -3, -4): (0, 1), (7, 31, -3, -3): (0, 1), (7, 31, -3, -2): (-1, 1), (7, 31, -3, -1): (-1, 1), (7, 31, -3, 0): (0, 1), (7, 31, -3, 1): (0, 1), (7, 31, -3, 2): (0, 0), (7, 31, -3, 3): (-1, -1), (7, 31, -3, 4): (0, 0), (7, 31, -3, 5): (-1, -1), (7, 31, -2, -5): (0, 1), (7, 31, -2, -4): (0, 1), (7, 31, -2, -3): (0, 1), (7, 31, -2, -2): (0, 1), (7, 31, -2, -1): (-1, 1), (7, 31, -2, 0): (-1, 1), (7, 31, -2, 1): (-1, 1), (7, 31, -2, 2): (-1, 0), (7, 31, -2, 3): (-1, -1), (7, 31, -2, 4): (-1, 0), (7, 31, -2, 5): (-1, -1), (7, 31, -1, -5): (-1, 1), (7, 31, -1, -4): (-1, 1), (7, 31, -1, -3): (-1, 1), (7, 31, -1, -2): (-1, 1), (7, 31, -1, -1): (0, 1), (7, 31, -1, 0): (-1, 1), (7, 31, -1, 1): (-1, 0), (7, 31, -1, 2): (-1, -1), (7, 31, -1, 3): (-1, -1), (7, 31, -1, 4): (-1, 0), (7, 31, -1, 5): (-1, -1), (7, 31, 0, -5): (1, 1), (7, 31, 0, -4): (1, 1), (7, 31, 0, -3): (1, 1), (7, 31, 0, -2): (0, 1), (7, 31, 0, -1): (-1, 1), (7, 31, 0, 0): (-1, 1), (7, 31, 0, 1): (-1, 0), (7, 31, 0, 2): (-1, -1), (7, 31, 0, 3): (-1, -1), (7, 31, 0, 4): (-1, 1), (7, 31, 0, 5): (-1, 1), (7, 31, 1, -5): (1, 1), (7, 31, 1, -4): (1, 1), (7, 31, 1, -3): (1, 1), (7, 31, 1, -2): (-1, 1), (7, 31, 1, -1): (-1, 1), (7, 31, 1, 0): (-1, 1), (7, 31, 1, 1): (-1, 0), (7, 31, 1, 2): (-1, -1), (7, 31, 1, 3): (-1, -1), (7, 31, 1, 4): (-1, 1), (7, 31, 1, 5): (-1, 1), (7, 31, 2, -5): (1, 1), (7, 31, 2, -4): (1, 1), (7, 31, 2, -3): (1, 1), (7, 31, 2, -2): (1, 0), (7, 31, 2, -1): (1, -1), (7, 31, 2, 0): (1, 1), (7, 31, 2, 1): (1, 0), (7, 31, 2, 2): (1, 0), (7, 31, 2, 3): (1, 0), (7, 31, 2, 4): (-1, 1), (7, 31, 2, 5): (-1, 1), (7, 31, 3, -5): (0, 1), (7, 31, 3, -4): (0, 1), (7, 31, 3, -3): (0, 1), (7, 31, 3, -2): (0, 0), (7, 31, 3, -1): (0, -1), (7, 31, 3, 0): (0, 1), (7, 31, 3, 1): (0, 1), (7, 31, 3, 2): (0, 1), (7, 31, 3, 3): (0, 1), (7, 31, 3, 4): (0, 1), (7, 31, 3, 5): (0, 1), (7, 31, 4, -5): (0, 1), (7, 31, 4, -4): (0, 1), (7, 31, 4, -3): (0, 1), (7, 31, 4, -2): (0, 0), (7, 31, 4, -1): (-1, -1), (7, 31, 4, 0): (0, 1), (7, 31, 4, 1): (0, 1), (7, 31, 4, 2): (0, 1), (7, 31, 4, 3): (0, 1), (7, 31, 4, 4): (0, 1), (7, 31, 4, 5): (0, 1), (7, 31, 5, -5): (0, 1), (7, 31, 5, -4): (0, 1), (7, 31, 5, -3): (0, 1), (7, 31, 5, -2): (0, 0), (7, 31, 5, -1): (-1, -1), (7, 31, 5, 0): (0, 1), (7, 31, 5, 1): (0, 1), (7, 31, 5, 2): (0, 1), (7, 31, 5, 3): (0, 1), (7, 31, 5, 4): (0, 1), (7, 31, 5, 5): (0, 1), (7, 32, -5, -5): (0, 1), (7, 32, -5, -4): (0, 1), (7, 32, -5, -3): (0, 1), (7, 32, -5, -2): (0, 1), (7, 32, -5, -1): (0, 1), (7, 32, -5, 0): (0, 1), (7, 32, -5, 1): (0, 0), (7, 32, -5, 2): (-1, -1), (7, 32, -5, 3): (0, 1), (7, 32, -5, 4): (0, 1), (7, 32, -5, 5): (0, 1), (7, 32, -4, -5): (0, 1), (7, 32, -4, -4): (-1, 1), (7, 32, -4, -3): (-1, 1), (7, 32, -4, -2): (-1, 1), (7, 32, -4, -1): (0, 1), (7, 32, -4, 0): (0, 1), (7, 32, -4, 1): (0, 0), (7, 32, -4, 2): (-1, -1), (7, 32, -4, 3): (-1, 1), (7, 32, -4, 4): (-1, 1), (7, 32, -4, 5): (-1, 1), (7, 32, -3, -5): (0, 1), (7, 32, -3, -4): (0, 1), (7, 32, -3, -3): (-1, 1), (7, 32, -3, -2): (-1, 1), (7, 32, -3, -1): (0, 1), (7, 32, -3, 0): (0, 1), (7, 32, -3, 1): (0, 0), (7, 32, -3, 2): (-1, -1), (7, 32, -3, 3): (-1, -1), (7, 32, -3, 4): (-1, -1), (7, 32, -3, 5): (-1, 1), (7, 32, -2, -5): (0, 1), (7, 32, -2, -4): (0, 1), (7, 32, -2, -3): (0, 1), (7, 32, -2, -2): (-1, 1), (7, 32, -2, -1): (-1, 1), (7, 32, -2, 0): (-1, 1), (7, 32, -2, 1): (-1, 0), (7, 32, -2, 2): (-1, -1), (7, 32, -2, 3): (-1, -1), (7, 32, -2, 4): (-1, -1), (7, 32, -2, 5): (-1, 1), (7, 32, -1, -5): (-1, 1), (7, 32, -1, -4): (-1, 1), (7, 32, -1, -3): (-1, 1), (7, 32, -1, -2): (-1, 1), (7, 32, -1, -1): (-1, 1), (7, 32, -1, 0): (-1, 1), (7, 32, -1, 1): (-1, 0), (7, 32, -1, 2): (-1, -1), (7, 32, -1, 3): (-1, 0), (7, 32, -1, 4): (-1, -1), (7, 32, -1, 5): (-1, 1), (7, 32, 0, -5): (1, 1), (7, 32, 0, -4): (1, 1), (7, 32, 0, -3): (1, 1), (7, 32, 0, -2): (-1, 1), (7, 32, 0, -1): (-1, 1), (7, 32, 0, 0): (-1, 0), (7, 32, 0, 1): (-1, -1), (7, 32, 0, 2): (-1, -1), (7, 32, 0, 3): (-1, -1), (7, 32, 0, 4): (-1, 1), (7, 32, 0, 5): (-1, 1), (7, 32, 1, -5): (1, 1), (7, 32, 1, -4): (1, 1), (7, 32, 1, -3): (1, 1), (7, 32, 1, -2): (-1, 1), (7, 32, 1, -1): (-1, 1), (7, 32, 1, 0): (-1, 1), (7, 32, 1, 1): (-1, 0), (7, 32, 1, 2): (-1, -1), (7, 32, 1, 3): (-1, 1), (7, 32, 1, 4): (-1, 1), (7, 32, 1, 5): (-1, 1), (7, 32, 2, -5): (1, 1), (7, 32, 2, -4): (1, 1), (7, 32, 2, -3): (1, 0), (7, 32, 2, -2): (1, -1), (7, 32, 2, -1): (1, 1), (7, 32, 2, 0): (1, 0), (7, 32, 2, 1): (1, 0), (7, 32, 2, 2): (1, 0), (7, 32, 2, 3): (-1, 1), (7, 32, 2, 4): (-1, 1), (7, 32, 2, 5): (-1, 1), (7, 32, 3, -5): (0, 1), (7, 32, 3, -4): (0, 1), (7, 32, 3, -3): (0, 0), (7, 32, 3, -2): (0, -1), (7, 32, 3, -1): (0, 1), (7, 32, 3, 0): (0, 1), (7, 32, 3, 1): (0, 1), (7, 32, 3, 2): (0, 1), (7, 32, 3, 3): (0, 1), (7, 32, 3, 4): (0, 1), (7, 32, 3, 5): (0, 1), (7, 32, 4, -5): (0, 1), (7, 32, 4, -4): (0, 1), (7, 32, 4, -3): (0, 0), (7, 32, 4, -2): (-1, -1), (7, 32, 4, -1): (0, 1), (7, 32, 4, 0): (0, 1), (7, 32, 4, 1): (0, 1), (7, 32, 4, 2): (0, 1), (7, 32, 4, 3): (0, 1), (7, 32, 4, 4): (0, 1), (7, 32, 4, 5): (0, 1), (7, 32, 5, -5): (0, 1), (7, 32, 5, -4): (0, 1), (7, 32, 5, -3): (0, 0), (7, 32, 5, -2): (-1, -1), (7, 32, 5, -1): (0, 1), (7, 32, 5, 0): (0, 1), (7, 32, 5, 1): (0, 1), (7, 32, 5, 2): (0, 1), (7, 32, 5, 3): (0, 1), (7, 32, 5, 4): (0, 1), (7, 32, 5, 5): (0, 1), (7, 33, -5, -5): (0, 1), (7, 33, -5, -4): (0, 1), (7, 33, -5, -3): (0, 1), (7, 33, -5, -2): (0, 1), (7, 33, -5, -1): (0, 1), (7, 33, -5, 0): (0, 1), (7, 33, -5, 1): (0, 0), (7, 33, -5, 2): (-1, -1), (7, 33, -5, 3): (0, 1), (7, 33, -5, 4): (0, 1), (7, 33, -5, 5): (0, 1), (7, 33, -4, -5): (-1, 1), (7, 33, -4, -4): (-1, 1), (7, 33, -4, -3): (-1, 1), (7, 33, -4, -2): (0, 1), (7, 33, -4, -1): (0, 1), (7, 33, -4, 0): (0, 1), (7, 33, -4, 1): (0, 0), (7, 33, -4, 2): (-1, -1), (7, 33, -4, 3): (-1, 1), (7, 33, -4, 4): (-1, 1), (7, 33, -4, 5): (-1, 1), (7, 33, -3, -5): (0, 1), (7, 33, -3, -4): (-1, 1), (7, 33, -3, -3): (-1, 1), (7, 33, -3, -2): (0, 1), (7, 33, -3, -1): (0, 1), (7, 33, -3, 0): (0, 1), (7, 33, -3, 1): (0, 0), (7, 33, -3, 2): (-1, -1), (7, 33, -3, 3): (-1, -1), (7, 33, -3, 4): (-1, 1), (7, 33, -3, 5): (-1, 1), (7, 33, -2, -5): (0, 1), (7, 33, -2, -4): (0, 1), (7, 33, -2, -3): (-1, 1), (7, 33, -2, -2): (-1, 1), (7, 33, -2, -1): (-1, 1), (7, 33, -2, 0): (-1, 1), (7, 33, -2, 1): (-1, 0), (7, 33, -2, 2): (-1, -1), (7, 33, -2, 3): (-1, -1), (7, 33, -2, 4): (-1, 1), (7, 33, -2, 5): (-1, 1), (7, 33, -1, -5): (-1, 1), (7, 33, -1, -4): (-1, 1), (7, 33, -1, -3): (-1, 1), (7, 33, -1, -2): (-1, 1), (7, 33, -1, -1): (-1, 1), (7, 33, -1, 0): (-1, 0), (7, 33, -1, 1): (-1, -1), (7, 33, -1, 2): (-1, -1), (7, 33, -1, 3): (-1, -1), (7, 33, -1, 4): (-1, 1), (7, 33, -1, 5): (-1, 1), (7, 33, 0, -5): (1, 1), (7, 33, 0, -4): (1, 1), (7, 33, 0, -3): (1, 1), (7, 33, 0, -2): (-1, 1), (7, 33, 0, -1): (-1, 1), (7, 33, 0, 0): (-1, 0), (7, 33, 0, 1): (-1, -1), (7, 33, 0, 2): (-1, -1), (7, 33, 0, 3): (-1, 1), (7, 33, 0, 4): (-1, 1), (7, 33, 0, 5): (-1, 1), (7, 33, 1, -5): (1, 1), (7, 33, 1, -4): (1, 1), (7, 33, 1, -3): (1, 1), (7, 33, 1, -2): (-1, 1), (7, 33, 1, -1): (-1, 1), (7, 33, 1, 0): (-1, 1), (7, 33, 1, 1): (-1, 0), (7, 33, 1, 2): (-1, 1), (7, 33, 1, 3): (-1, 1), (7, 33, 1, 4): (-1, 1), (7, 33, 1, 5): (-1, 1), (7, 33, 2, -5): (1, 1), (7, 33, 2, -4): (1, 0), (7, 33, 2, -3): (1, -1), (7, 33, 2, -2): (1, 1), (7, 33, 2, -1): (1, 0), (7, 33, 2, 0): (1, 0), (7, 33, 2, 1): (1, 0), (7, 33, 2, 2): (-1, 1), (7, 33, 2, 3): (-1, 1), (7, 33, 2, 4): (-1, 1), (7, 33, 2, 5): (-1, 1), (7, 33, 3, -5): (0, 1), (7, 33, 3, -4): (0, 0), (7, 33, 3, -3): (0, -1), (7, 33, 3, -2): (0, 1), (7, 33, 3, -1): (0, 1), (7, 33, 3, 0): (0, 1), (7, 33, 3, 1): (0, 1), (7, 33, 3, 2): (0, 1), (7, 33, 3, 3): (0, 1), (7, 33, 3, 4): (0, 1), (7, 33, 3, 5): (0, 1), (7, 33, 4, -5): (0, 1), (7, 33, 4, -4): (0, 0), (7, 33, 4, -3): (-1, -1), (7, 33, 4, -2): (0, 1), (7, 33, 4, -1): (0, 1), (7, 33, 4, 0): (0, 1), (7, 33, 4, 1): (0, 1), (7, 33, 4, 2): (0, 1), (7, 33, 4, 3): (0, 1), (7, 33, 4, 4): (0, 1), (7, 33, 4, 5): (0, 1), (7, 33, 5, -5): (0, 1), (7, 33, 5, -4): (0, 0), (7, 33, 5, -3): (-1, -1), (7, 33, 5, -2): (0, 1), (7, 33, 5, -1): (0, 1), (7, 33, 5, 0): (0, 1), (7, 33, 5, 1): (0, 1), (7, 33, 5, 2): (0, 1), (7, 33, 5, 3): (0, 1), (7, 33, 5, 4): (0, 1), (7, 33, 5, 5): (0, 1), (7, 34, -5, -5): (0, 1), (7, 34, -5, -4): (0, 1), (7, 34, -5, -3): (0, 0), (7, 34, -5, -2): (0, 1), (7, 34, -5, -1): (0, 1), (7, 34, -5, 0): (0, 0), (7, 34, -5, 1): (-1, -1), (7, 34, -5, 2): (0, 1), (7, 34, -5, 3): (0, 1), (7, 34, -5, 4): (0, 1), (7, 34, -5, 5): (0, 1), (7, 34, -4, -5): (-1, 1), (7, 34, -4, -4): (-1, 1), (7, 34, -4, -3): (-1, 0), (7, 34, -4, -2): (0, 1), (7, 34, -4, -1): (0, 1), (7, 34, -4, 0): (0, 0), (7, 34, -4, 1): (-1, -1), (7, 34, -4, 2): (-1, 1), (7, 34, -4, 3): (-1, 1), (7, 34, -4, 4): (-1, 1), (7, 34, -4, 5): (-1, 1), (7, 34, -3, -5): (-1, 1), (7, 34, -3, -4): (-1, 1), (7, 34, -3, -3): (-1, 1), (7, 34, -3, -2): (0, 1), (7, 34, -3, -1): (0, 1), (7, 34, -3, 0): (0, 0), (7, 34, -3, 1): (-1, -1), (7, 34, -3, 2): (-1, -1), (7, 34, -3, 3): (-1, 1), (7, 34, -3, 4): (-1, 1), (7, 34, -3, 5): (-1, 1), (7, 34, -2, -5): (0, 1), (7, 34, -2, -4): (-1, 1), (7, 34, -2, -3): (0, 1), (7, 34, -2, -2): (-1, 1), (7, 34, -2, -1): (-1, 1), (7, 34, -2, 0): (-1, 0), (7, 34, -2, 1): (-1, -1), (7, 34, -2, 2): (-1, -1), (7, 34, -2, 3): (-1, 1), (7, 34, -2, 4): (-1, 1), (7, 34, -2, 5): (-1, 1), (7, 34, -1, -5): (-1, 1), (7, 34, -1, -4): (-1, 1), (7, 34, -1, -3): (-1, 1), (7, 34, -1, -2): (-1, 1), (7, 34, -1, -1): (-1, 1), (7, 34, -1, 0): (-1, 0), (7, 34, -1, 1): (-1, -1), (7, 34, -1, 2): (-1, -1), (7, 34, -1, 3): (-1, 1), (7, 34, -1, 4): (-1, 1), (7, 34, -1, 5): (-1, 1), (7, 34, 0, -5): (1, 1), (7, 34, 0, -4): (1, 1), (7, 34, 0, -3): (-1, 1), (7, 34, 0, -2): (-1, 1), (7, 34, 0, -1): (-1, 1), (7, 34, 0, 0): (-1, 0), (7, 34, 0, 1): (-1, -1), (7, 34, 0, 2): (-1, -1), (7, 34, 0, 3): (-1, 1), (7, 34, 0, 4): (-1, 1), (7, 34, 0, 5): (-1, 1), (7, 34, 1, -5): (1, 1), (7, 34, 1, -4): (1, 1), (7, 34, 1, -3): (-1, 1), (7, 34, 1, -2): (-1, 1), (7, 34, 1, -1): (-1, 1), (7, 34, 1, 0): (-1, 1), (7, 34, 1, 1): (-1, 1), (7, 34, 1, 2): (-1, 1), (7, 34, 1, 3): (-1, 1), (7, 34, 1, 4): (-1, 1), (7, 34, 1, 5): (-1, 1), (7, 34, 2, -5): (1, 0), (7, 34, 2, -4): (1, -1), (7, 34, 2, -3): (1, 1), (7, 34, 2, -2): (1, 0), (7, 34, 2, -1): (1, 0), (7, 34, 2, 0): (1, 0), (7, 34, 2, 1): (-1, 1), (7, 34, 2, 2): (-1, 1), (7, 34, 2, 3): (-1, 1), (7, 34, 2, 4): (-1, 1), (7, 34, 2, 5): (-1, 1), (7, 34, 3, -5): (0, 0), (7, 34, 3, -4): (0, -1), (7, 34, 3, -3): (0, 1), (7, 34, 3, -2): (0, 1), (7, 34, 3, -1): (0, 1), (7, 34, 3, 0): (0, 1), (7, 34, 3, 1): (0, 1), (7, 34, 3, 2): (0, 1), (7, 34, 3, 3): (0, 1), (7, 34, 3, 4): (0, 1), (7, 34, 3, 5): (0, 1), (7, 34, 4, -5): (0, 0), (7, 34, 4, -4): (-1, -1), (7, 34, 4, -3): (0, 1), (7, 34, 4, -2): (0, 1), (7, 34, 4, -1): (0, 1), (7, 34, 4, 0): (0, 1), (7, 34, 4, 1): (0, 1), (7, 34, 4, 2): (0, 1), (7, 34, 4, 3): (0, 1), (7, 34, 4, 4): (0, 1), (7, 34, 4, 5): (0, 1), (7, 34, 5, -5): (0, 0), (7, 34, 5, -4): (-1, -1), (7, 34, 5, -3): (0, 1), (7, 34, 5, -2): (0, 1), (7, 34, 5, -1): (0, 1), (7, 34, 5, 0): (0, 1), (7, 34, 5, 1): (0, 1), (7, 34, 5, 2): (0, 1), (7, 34, 5, 3): (0, 1), (7, 34, 5, 4): (0, 1), (7, 34, 5, 5): (0, 1), (7, 35, -5, -5): (0, 1), (7, 35, -5, -4): (0, 0), (7, 35, -5, -3): (0, 1), (7, 35, -5, -2): (0, 1), (7, 35, -5, -1): (0, 1), (7, 35, -5, 0): (0, 0), (7, 35, -5, 1): (-1, -1), (7, 35, -5, 2): (0, 1), (7, 35, -5, 3): (0, 1), (7, 35, -5, 4): (0, 1), (7, 35, -5, 5): (0, 1), (7, 35, -4, -5): (-1, 1), (7, 35, -4, -4): (-1, 0), (7, 35, -4, -3): (0, 1), (7, 35, -4, -2): (0, 1), (7, 35, -4, -1): (0, 1), (7, 35, -4, 0): (0, 0), (7, 35, -4, 1): (-1, -1), (7, 35, -4, 2): (-1, 1), (7, 35, -4, 3): (-1, 1), (7, 35, -4, 4): (-1, 1), (7, 35, -4, 5): (-1, 1), (7, 35, -3, -5): (-1, 1), (7, 35, -3, -4): (-1, 0), (7, 35, -3, -3): (0, 1), (7, 35, -3, -2): (0, 1), (7, 35, -3, -1): (0, 1), (7, 35, -3, 0): (0, 0), (7, 35, -3, 1): (-1, -1), (7, 35, -3, 2): (-1, 1), (7, 35, -3, 3): (-1, 1), (7, 35, -3, 4): (-1, 1), (7, 35, -3, 5): (-1, 1), (7, 35, -2, -5): (-1, 1), (7, 35, -2, -4): (-1, 0), (7, 35, -2, -3): (-1, 1), (7, 35, -2, -2): (-1, 1), (7, 35, -2, -1): (-1, 1), (7, 35, -2, 0): (-1, 0), (7, 35, -2, 1): (-1, -1), (7, 35, -2, 2): (-1, 1), (7, 35, -2, 3): (-1, 1), (7, 35, -2, 4): (-1, 1), (7, 35, -2, 5): (-1, 1), (7, 35, -1, -5): (-1, 1), (7, 35, -1, -4): (-1, 1), (7, 35, -1, -3): (-1, 1), (7, 35, -1, -2): (-1, 1), (7, 35, -1, -1): (-1, 1), (7, 35, -1, 0): (-1, 0), (7, 35, -1, 1): (-1, -1), (7, 35, -1, 2): (-1, 1), (7, 35, -1, 3): (-1, 1), (7, 35, -1, 4): (-1, 1), (7, 35, -1, 5): (-1, 1), (7, 35, 0, -5): (1, 1), (7, 35, 0, -4): (1, 1), (7, 35, 0, -3): (-1, 1), (7, 35, 0, -2): (-1, 1), (7, 35, 0, -1): (-1, 1), (7, 35, 0, 0): (-1, 0), (7, 35, 0, 1): (-1, -1), (7, 35, 0, 2): (-1, 1), (7, 35, 0, 3): (-1, 1), (7, 35, 0, 4): (-1, 1), (7, 35, 0, 5): (-1, 1), (7, 35, 1, -5): (1, 1), (7, 35, 1, -4): (1, 1), (7, 35, 1, -3): (-1, 1), (7, 35, 1, -2): (-1, 1), (7, 35, 1, -1): (-1, 1), (7, 35, 1, 0): (-1, 1), (7, 35, 1, 1): (-1, 1), (7, 35, 1, 2): (-1, 1), (7, 35, 1, 3): (-1, 1), (7, 35, 1, 4): (-1, 1), (7, 35, 1, 5): (-1, 1), (7, 35, 2, -5): (1, 0), (7, 35, 2, -4): (1, 1), (7, 35, 2, -3): (1, 0), (7, 35, 2, -2): (1, 0), (7, 35, 2, -1): (1, 0), (7, 35, 2, 0): (-1, 1), (7, 35, 2, 1): (-1, 1), (7, 35, 2, 2): (-1, 1), (7, 35, 2, 3): (-1, 1), (7, 35, 2, 4): (-1, 1), (7, 35, 2, 5): (-1, 1), (7, 35, 3, -5): (0, 0), (7, 35, 3, -4): (0, 1), (7, 35, 3, -3): (0, 1), (7, 35, 3, -2): (0, 1), (7, 35, 3, -1): (0, 1), (7, 35, 3, 0): (0, 1), (7, 35, 3, 1): (0, 1), (7, 35, 3, 2): (0, 1), (7, 35, 3, 3): (0, 1), (7, 35, 3, 4): (0, 1), (7, 35, 3, 5): (0, 1), (7, 35, 4, -5): (0, 0), (7, 35, 4, -4): (0, 1), (7, 35, 4, -3): (0, 1), (7, 35, 4, -2): (0, 1), (7, 35, 4, -1): (0, 1), (7, 35, 4, 0): (0, 1), (7, 35, 4, 1): (0, 1), (7, 35, 4, 2): (0, 1), (7, 35, 4, 3): (0, 1), (7, 35, 4, 4): (0, 1), (7, 35, 4, 5): (0, 1), (7, 35, 5, -5): (0, 0), (7, 35, 5, -4): (0, 1), (7, 35, 5, -3): (0, 1), (7, 35, 5, -2): (0, 1), (7, 35, 5, -1): (0, 1), (7, 35, 5, 0): (0, 1), (7, 35, 5, 1): (0, 1), (7, 35, 5, 2): (0, 1), (7, 35, 5, 3): (0, 1), (7, 35, 5, 4): (0, 1), (7, 35, 5, 5): (0, 1), (8, 1, -5, -5): (0, 1), (8, 1, -5, -4): (0, 1), (8, 1, -5, -3): (0, 1), (8, 1, -5, -2): (0, 1), (8, 1, -5, -1): (0, 0), (8, 1, -5, 0): (-1, -1), (8, 1, -5, 1): (0, 1), (8, 1, -5, 2): (0, 1), (8, 1, -5, 3): (0, 1), (8, 1, -5, 4): (0, 1), (8, 1, -5, 5): (0, 1), (8, 1, -4, -5): (-1, 1), (8, 1, -4, -4): (-1, 1), (8, 1, -4, -3): (-1, 1), (8, 1, -4, -2): (-1, 1), (8, 1, -4, -1): (-1, 0), (8, 1, -4, 0): (-1, -1), (8, 1, -4, 1): (0, 1), (8, 1, -4, 2): (0, 1), (8, 1, -4, 3): (0, 1), (8, 1, -4, 4): (0, 1), (8, 1, -4, 5): (0, 1), (8, 1, -3, -5): (-1, 1), (8, 1, -3, -4): (-1, 1), (8, 1, -3, -3): (-1, 1), (8, 1, -3, -2): (-1, 1), (8, 1, -3, -1): (-1, 0), (8, 1, -3, 0): (0, 1), (8, 1, -3, 1): (0, 1), (8, 1, -3, 2): (0, 1), (8, 1, -3, 3): (1, 1), (8, 1, -3, 4): (1, 1), (8, 1, -3, 5): (1, 0), (8, 1, -2, -5): (0, 1), (8, 1, -2, -4): (0, 1), (8, 1, -2, -3): (0, 1), (8, 1, -2, -2): (0, 1), (8, 1, -2, -1): (-1, 1), (8, 1, -2, 0): (1, 1), (8, 1, -2, 1): (1, 1), (8, 1, -2, 2): (1, 1), (8, 1, -2, 3): (1, 1), (8, 1, -2, 4): (1, 1), (8, 1, -2, 5): (1, 0), (8, 1, -1, -5): (1, 0), (8, 1, -1, -4): (1, 0), (8, 1, -1, -3): (1, 0), (8, 1, -1, -2): (1, 0), (8, 1, -1, -1): (1, 0), (8, 1, -1, 0): (1, 1), (8, 1, -1, 1): (1, 1), (8, 1, -1, 2): (1, 1), (8, 1, -1, 3): (1, 1), (8, 1, -1, 4): (1, 1), (8, 1, -1, 5): (1, 0), (8, 1, 0, -5): (1, 0), (8, 1, 0, -4): (1, 0), (8, 1, 0, -3): (1, 0), (8, 1, 0, -2): (1, 0), (8, 1, 0, -1): (1, 0), (8, 1, 0, 0): (0, 1), (8, 1, 0, 1): (0, 1), (8, 1, 0, 2): (0, 1), (8, 1, 0, 3): (0, 1), (8, 1, 0, 4): (0, 1), (8, 1, 0, 5): (0, 1), (8, 1, 1, -5): (0, 1), (8, 1, 1, -4): (0, 1), (8, 1, 1, -3): (0, 1), (8, 1, 1, -2): (0, 1), (8, 1, 1, -1): (0, 1), (8, 1, 1, 0): (-1, 1), (8, 1, 1, 1): (-1, 1), (8, 1, 1, 2): (-1, 1), (8, 1, 1, 3): (-1, 1), (8, 1, 1, 4): (-1, 1), (8, 1, 1, 5): (-1, 1), (8, 1, 2, -5): (0, 1), (8, 1, 2, -4): (0, 1), (8, 1, 2, -3): (0, 1), (8, 1, 2, -2): (0, 1), (8, 1, 2, -1): (0, 1), (8, 1, 2, 0): (-1, 1), (8, 1, 2, 1): (-1, 1), (8, 1, 2, 2): (-1, 1), (8, 1, 2, 3): (-1, 1), (8, 1, 2, 4): (-1, 1), (8, 1, 2, 5): (-1, 1), (8, 1, 3, -5): (0, 1), (8, 1, 3, -4): (0, 1), (8, 1, 3, -3): (0, 1), (8, 1, 3, -2): (0, 1), (8, 1, 3, -1): (0, 1), (8, 1, 3, 0): (0, 1), (8, 1, 3, 1): (0, 1), (8, 1, 3, 2): (0, 1), (8, 1, 3, 3): (0, 1), (8, 1, 3, 4): (0, 1), (8, 1, 3, 5): (0, 1), (8, 1, 4, -5): (0, 1), (8, 1, 4, -4): (0, 1), (8, 1, 4, -3): (0, 1), (8, 1, 4, -2): (0, 1), (8, 1, 4, -1): (0, 1), (8, 1, 4, 0): (0, 1), (8, 1, 4, 1): (0, 1), (8, 1, 4, 2): (0, 1), (8, 1, 4, 3): (0, 1), (8, 1, 4, 4): (0, 1), (8, 1, 4, 5): (0, 1), (8, 1, 5, -5): (0, 1), (8, 1, 5, -4): (0, 1), (8, 1, 5, -3): (0, 1), (8, 1, 5, -2): (0, 1), (8, 1, 5, -1): (0, 1), (8, 1, 5, 0): (0, 1), (8, 1, 5, 1): (0, 1), (8, 1, 5, 2): (0, 1), (8, 1, 5, 3): (0, 1), (8, 1, 5, 4): (0, 1), (8, 1, 5, 5): (0, 1), (8, 2, -5, -5): (0, 1), (8, 2, -5, -4): (0, 1), (8, 2, -5, -3): (0, 1), (8, 2, -5, -2): (0, 0), (8, 2, -5, -1): (-1, -1), (8, 2, -5, 0): (0, 1), (8, 2, -5, 1): (0, 1), (8, 2, -5, 2): (0, 1), (8, 2, -5, 3): (0, 1), (8, 2, -5, 4): (0, 1), (8, 2, -5, 5): (0, 1), (8, 2, -4, -5): (-1, 1), (8, 2, -4, -4): (-1, 1), (8, 2, -4, -3): (-1, 1), (8, 2, -4, -2): (-1, 0), (8, 2, -4, -1): (-1, -1), (8, 2, -4, 0): (0, 1), (8, 2, -4, 1): (0, 1), (8, 2, -4, 2): (0, 1), (8, 2, -4, 3): (0, 1), (8, 2, -4, 4): (0, 1), (8, 2, -4, 5): (0, 1), (8, 2, -3, -5): (-1, 1), (8, 2, -3, -4): (-1, 1), (8, 2, -3, -3): (-1, 1), (8, 2, -3, -2): (-1, 0), (8, 2, -3, -1): (0, 1), (8, 2, -3, 0): (0, 1), (8, 2, -3, 1): (0, 1), (8, 2, -3, 2): (0, 1), (8, 2, -3, 3): (0, 1), (8, 2, -3, 4): (1, 1), (8, 2, -3, 5): (1, 0), (8, 2, -2, -5): (0, 1), (8, 2, -2, -4): (0, 1), (8, 2, -2, -3): (0, 1), (8, 2, -2, -2): (-1, 1), (8, 2, -2, -1): (-1, 1), (8, 2, -2, 0): (1, 1), (8, 2, -2, 1): (1, 1), (8, 2, -2, 2): (1, 1), (8, 2, -2, 3): (1, 1), (8, 2, -2, 4): (1, 1), (8, 2, -2, 5): (1, 0), (8, 2, -1, -5): (1, 0), (8, 2, -1, -4): (1, 0), (8, 2, -1, -3): (1, 0), (8, 2, -1, -2): (1, 0), (8, 2, -1, -1): (1, 1), (8, 2, -1, 0): (1, 1), (8, 2, -1, 1): (1, 1), (8, 2, -1, 2): (1, 1), (8, 2, -1, 3): (1, 1), (8, 2, -1, 4): (1, 1), (8, 2, -1, 5): (1, 0), (8, 2, 0, -5): (1, 0), (8, 2, 0, -4): (1, 0), (8, 2, 0, -3): (1, 0), (8, 2, 0, -2): (1, 0), (8, 2, 0, -1): (1, 1), (8, 2, 0, 0): (0, 1), (8, 2, 0, 1): (0, 1), (8, 2, 0, 2): (0, 1), (8, 2, 0, 3): (0, 1), (8, 2, 0, 4): (0, 1), (8, 2, 0, 5): (0, 1), (8, 2, 1, -5): (0, 1), (8, 2, 1, -4): (0, 1), (8, 2, 1, -3): (0, 1), (8, 2, 1, -2): (0, 0), (8, 2, 1, -1): (0, 1), (8, 2, 1, 0): (-1, 1), (8, 2, 1, 1): (-1, 1), (8, 2, 1, 2): (-1, 1), (8, 2, 1, 3): (-1, 1), (8, 2, 1, 4): (-1, 1), (8, 2, 1, 5): (-1, 1), (8, 2, 2, -5): (0, 1), (8, 2, 2, -4): (0, 1), (8, 2, 2, -3): (0, 1), (8, 2, 2, -2): (0, 1), (8, 2, 2, -1): (0, 1), (8, 2, 2, 0): (-1, 1), (8, 2, 2, 1): (-1, 1), (8, 2, 2, 2): (-1, 1), (8, 2, 2, 3): (-1, 1), (8, 2, 2, 4): (-1, 1), (8, 2, 2, 5): (-1, 1), (8, 2, 3, -5): (0, 1), (8, 2, 3, -4): (0, 1), (8, 2, 3, -3): (0, 1), (8, 2, 3, -2): (0, 1), (8, 2, 3, -1): (0, 1), (8, 2, 3, 0): (0, 1), (8, 2, 3, 1): (0, 1), (8, 2, 3, 2): (0, 1), (8, 2, 3, 3): (0, 1), (8, 2, 3, 4): (0, 1), (8, 2, 3, 5): (0, 1), (8, 2, 4, -5): (0, 1), (8, 2, 4, -4): (0, 1), (8, 2, 4, -3): (0, 1), (8, 2, 4, -2): (0, 1), (8, 2, 4, -1): (0, 1), (8, 2, 4, 0): (0, 1), (8, 2, 4, 1): (0, 1), (8, 2, 4, 2): (0, 1), (8, 2, 4, 3): (0, 1), (8, 2, 4, 4): (0, 1), (8, 2, 4, 5): (0, 1), (8, 2, 5, -5): (0, 1), (8, 2, 5, -4): (0, 1), (8, 2, 5, -3): (0, 1), (8, 2, 5, -2): (0, 1), (8, 2, 5, -1): (0, 1), (8, 2, 5, 0): (0, 1), (8, 2, 5, 1): (0, 1), (8, 2, 5, 2): (0, 1), (8, 2, 5, 3): (0, 1), (8, 2, 5, 4): (0, 1), (8, 2, 5, 5): (0, 1), (8, 3, -5, -5): (0, 1), (8, 3, -5, -4): (0, 1), (8, 3, -5, -3): (0, 0), (8, 3, -5, -2): (-1, -1), (8, 3, -5, -1): (0, 1), (8, 3, -5, 0): (0, 1), (8, 3, -5, 1): (0, 1), (8, 3, -5, 2): (0, 1), (8, 3, -5, 3): (0, 1), (8, 3, -5, 4): (0, 1), (8, 3, -5, 5): (0, 1), (8, 3, -4, -5): (-1, 1), (8, 3, -4, -4): (-1, 1), (8, 3, -4, -3): (-1, 0), (8, 3, -4, -2): (-1, -1), (8, 3, -4, -1): (0, 1), (8, 3, -4, 0): (0, 1), (8, 3, -4, 1): (0, 1), (8, 3, -4, 2): (0, 1), (8, 3, -4, 3): (0, 1), (8, 3, -4, 4): (0, 1), (8, 3, -4, 5): (0, 1), (8, 3, -3, -5): (-1, 1), (8, 3, -3, -4): (-1, 1), (8, 3, -3, -3): (-1, 0), (8, 3, -3, -2): (0, 1), (8, 3, -3, -1): (0, 1), (8, 3, -3, 0): (0, 1), (8, 3, -3, 1): (0, 1), (8, 3, -3, 2): (0, 1), (8, 3, -3, 3): (0, 1), (8, 3, -3, 4): (1, 1), (8, 3, -3, 5): (1, 0), (8, 3, -2, -5): (0, 1), (8, 3, -2, -4): (0, 1), (8, 3, -2, -3): (-1, 1), (8, 3, -2, -2): (-1, 1), (8, 3, -2, -1): (-1, 1), (8, 3, -2, 0): (1, 1), (8, 3, -2, 1): (1, 1), (8, 3, -2, 2): (1, 1), (8, 3, -2, 3): (1, 1), (8, 3, -2, 4): (1, 1), (8, 3, -2, 5): (1, 0), (8, 3, -1, -5): (1, 0), (8, 3, -1, -4): (1, 0), (8, 3, -1, -3): (1, 0), (8, 3, -1, -2): (1, -1), (8, 3, -1, -1): (1, 1), (8, 3, -1, 0): (1, 1), (8, 3, -1, 1): (1, 1), (8, 3, -1, 2): (1, 1), (8, 3, -1, 3): (1, 1), (8, 3, -1, 4): (1, 1), (8, 3, -1, 5): (1, 0), (8, 3, 0, -5): (1, 0), (8, 3, 0, -4): (1, 0), (8, 3, 0, -3): (1, 0), (8, 3, 0, -2): (1, -1), (8, 3, 0, -1): (1, 1), (8, 3, 0, 0): (0, 1), (8, 3, 0, 1): (0, 1), (8, 3, 0, 2): (0, 1), (8, 3, 0, 3): (0, 1), (8, 3, 0, 4): (0, 1), (8, 3, 0, 5): (0, 1), (8, 3, 1, -5): (0, 1), (8, 3, 1, -4): (0, 1), (8, 3, 1, -3): (0, 0), (8, 3, 1, -2): (1, 1), (8, 3, 1, -1): (0, 1), (8, 3, 1, 0): (-1, 1), (8, 3, 1, 1): (-1, 1), (8, 3, 1, 2): (-1, 1), (8, 3, 1, 3): (-1, 1), (8, 3, 1, 4): (-1, 1), (8, 3, 1, 5): (-1, 1), (8, 3, 2, -5): (0, 1), (8, 3, 2, -4): (0, 1), (8, 3, 2, -3): (0, 1), (8, 3, 2, -2): (0, 1), (8, 3, 2, -1): (0, 1), (8, 3, 2, 0): (-1, 1), (8, 3, 2, 1): (-1, 1), (8, 3, 2, 2): (-1, 1), (8, 3, 2, 3): (-1, 1), (8, 3, 2, 4): (-1, 1), (8, 3, 2, 5): (-1, 1), (8, 3, 3, -5): (0, 1), (8, 3, 3, -4): (0, 1), (8, 3, 3, -3): (0, 1), (8, 3, 3, -2): (0, 1), (8, 3, 3, -1): (0, 1), (8, 3, 3, 0): (0, 1), (8, 3, 3, 1): (0, 1), (8, 3, 3, 2): (0, 1), (8, 3, 3, 3): (0, 1), (8, 3, 3, 4): (0, 1), (8, 3, 3, 5): (0, 1), (8, 3, 4, -5): (0, 1), (8, 3, 4, -4): (0, 1), (8, 3, 4, -3): (0, 1), (8, 3, 4, -2): (0, 1), (8, 3, 4, -1): (0, 1), (8, 3, 4, 0): (0, 1), (8, 3, 4, 1): (0, 1), (8, 3, 4, 2): (0, 1), (8, 3, 4, 3): (0, 1), (8, 3, 4, 4): (0, 1), (8, 3, 4, 5): (0, 1), (8, 3, 5, -5): (0, 1), (8, 3, 5, -4): (0, 1), (8, 3, 5, -3): (0, 1), (8, 3, 5, -2): (0, 1), (8, 3, 5, -1): (0, 1), (8, 3, 5, 0): (0, 1), (8, 3, 5, 1): (0, 1), (8, 3, 5, 2): (0, 1), (8, 3, 5, 3): (0, 1), (8, 3, 5, 4): (0, 1), (8, 3, 5, 5): (0, 1), (8, 4, -5, -5): (0, 1), (8, 4, -5, -4): (0, 0), (8, 4, -5, -3): (-1, -1), (8, 4, -5, -2): (0, 1), (8, 4, -5, -1): (0, 1), (8, 4, -5, 0): (0, 1), (8, 4, -5, 1): (0, 1), (8, 4, -5, 2): (0, 1), (8, 4, -5, 3): (0, 1), (8, 4, -5, 4): (0, 1), (8, 4, -5, 5): (0, 1), (8, 4, -4, -5): (-1, 1), (8, 4, -4, -4): (-1, 0), (8, 4, -4, -3): (-1, -1), (8, 4, -4, -2): (0, 1), (8, 4, -4, -1): (0, 1), (8, 4, -4, 0): (0, 1), (8, 4, -4, 1): (0, 1), (8, 4, -4, 2): (0, 1), (8, 4, -4, 3): (0, 1), (8, 4, -4, 4): (0, 1), (8, 4, -4, 5): (0, 1), (8, 4, -3, -5): (-1, 1), (8, 4, -3, -4): (-1, 0), (8, 4, -3, -3): (0, 1), (8, 4, -3, -2): (0, 1), (8, 4, -3, -1): (0, 1), (8, 4, -3, 0): (0, 1), (8, 4, -3, 1): (0, 1), (8, 4, -3, 2): (0, 1), (8, 4, -3, 3): (0, 1), (8, 4, -3, 4): (1, 1), (8, 4, -3, 5): (1, 0), (8, 4, -2, -5): (0, 1), (8, 4, -2, -4): (-1, 1), (8, 4, -2, -3): (-1, 1), (8, 4, -2, -2): (-1, 1), (8, 4, -2, -1): (-1, 1), (8, 4, -2, 0): (1, 1), (8, 4, -2, 1): (1, 1), (8, 4, -2, 2): (1, 1), (8, 4, -2, 3): (1, 1), (8, 4, -2, 4): (1, 1), (8, 4, -2, 5): (1, 0), (8, 4, -1, -5): (1, 0), (8, 4, -1, -4): (1, 0), (8, 4, -1, -3): (1, -1), (8, 4, -1, -2): (-1, 1), (8, 4, -1, -1): (1, 1), (8, 4, -1, 0): (1, 1), (8, 4, -1, 1): (1, 1), (8, 4, -1, 2): (1, 1), (8, 4, -1, 3): (1, 1), (8, 4, -1, 4): (1, 1), (8, 4, -1, 5): (1, 0), (8, 4, 0, -5): (1, 0), (8, 4, 0, -4): (1, 0), (8, 4, 0, -3): (1, -1), (8, 4, 0, -2): (1, 1), (8, 4, 0, -1): (1, 1), (8, 4, 0, 0): (0, 1), (8, 4, 0, 1): (0, 1), (8, 4, 0, 2): (0, 1), (8, 4, 0, 3): (0, 1), (8, 4, 0, 4): (0, 1), (8, 4, 0, 5): (0, 1), (8, 4, 1, -5): (0, 1), (8, 4, 1, -4): (0, 0), (8, 4, 1, -3): (1, 1), (8, 4, 1, -2): (1, 1), (8, 4, 1, -1): (0, 1), (8, 4, 1, 0): (-1, 1), (8, 4, 1, 1): (-1, 1), (8, 4, 1, 2): (-1, 1), (8, 4, 1, 3): (-1, 1), (8, 4, 1, 4): (-1, 1), (8, 4, 1, 5): (-1, 1), (8, 4, 2, -5): (0, 1), (8, 4, 2, -4): (0, 1), (8, 4, 2, -3): (0, 1), (8, 4, 2, -2): (0, 1), (8, 4, 2, -1): (0, 1), (8, 4, 2, 0): (-1, 1), (8, 4, 2, 1): (-1, 1), (8, 4, 2, 2): (-1, 1), (8, 4, 2, 3): (-1, 1), (8, 4, 2, 4): (-1, 1), (8, 4, 2, 5): (-1, 1), (8, 4, 3, -5): (0, 1), (8, 4, 3, -4): (0, 1), (8, 4, 3, -3): (0, 1), (8, 4, 3, -2): (0, 1), (8, 4, 3, -1): (0, 1), (8, 4, 3, 0): (0, 1), (8, 4, 3, 1): (0, 1), (8, 4, 3, 2): (0, 1), (8, 4, 3, 3): (0, 1), (8, 4, 3, 4): (0, 1), (8, 4, 3, 5): (0, 1), (8, 4, 4, -5): (0, 1), (8, 4, 4, -4): (0, 1), (8, 4, 4, -3): (0, 1), (8, 4, 4, -2): (0, 1), (8, 4, 4, -1): (0, 1), (8, 4, 4, 0): (0, 1), (8, 4, 4, 1): (0, 1), (8, 4, 4, 2): (0, 1), (8, 4, 4, 3): (0, 1), (8, 4, 4, 4): (0, 1), (8, 4, 4, 5): (0, 1), (8, 4, 5, -5): (0, 1), (8, 4, 5, -4): (0, 1), (8, 4, 5, -3): (0, 1), (8, 4, 5, -2): (0, 1), (8, 4, 5, -1): (0, 1), (8, 4, 5, 0): (0, 1), (8, 4, 5, 1): (0, 1), (8, 4, 5, 2): (0, 1), (8, 4, 5, 3): (0, 1), (8, 4, 5, 4): (0, 1), (8, 4, 5, 5): (0, 1), (8, 5, -5, -5): (0, 0), (8, 5, -5, -4): (-1, -1), (8, 5, -5, -3): (0, 1), (8, 5, -5, -2): (0, 1), (8, 5, -5, -1): (0, 1), (8, 5, -5, 0): (0, 1), (8, 5, -5, 1): (0, 1), (8, 5, -5, 2): (0, 1), (8, 5, -5, 3): (0, 1), (8, 5, -5, 4): (0, 1), (8, 5, -5, 5): (0, 1), (8, 5, -4, -5): (-1, 0), (8, 5, -4, -4): (-1, -1), (8, 5, -4, -3): (0, 1), (8, 5, -4, -2): (0, 1), (8, 5, -4, -1): (0, 1), (8, 5, -4, 0): (0, 1), (8, 5, -4, 1): (0, 1), (8, 5, -4, 2): (0, 1), (8, 5, -4, 3): (0, 1), (8, 5, -4, 4): (0, 1), (8, 5, -4, 5): (0, 1), (8, 5, -3, -5): (-1, 0), (8, 5, -3, -4): (0, 1), (8, 5, -3, -3): (0, 1), (8, 5, -3, -2): (0, 1), (8, 5, -3, -1): (0, 1), (8, 5, -3, 0): (0, 1), (8, 5, -3, 1): (0, 1), (8, 5, -3, 2): (0, 1), (8, 5, -3, 3): (1, 1), (8, 5, -3, 4): (1, 1), (8, 5, -3, 5): (1, 0), (8, 5, -2, -5): (-1, 1), (8, 5, -2, -4): (-1, 1), (8, 5, -2, -3): (-1, 1), (8, 5, -2, -2): (-1, 1), (8, 5, -2, -1): (-1, 1), (8, 5, -2, 0): (1, 1), (8, 5, -2, 1): (1, 1), (8, 5, -2, 2): (1, 1), (8, 5, -2, 3): (1, 1), (8, 5, -2, 4): (1, 1), (8, 5, -2, 5): (1, 0), (8, 5, -1, -5): (1, 0), (8, 5, -1, -4): (1, -1), (8, 5, -1, -3): (-1, 0), (8, 5, -1, -2): (-1, 1), (8, 5, -1, -1): (1, 1), (8, 5, -1, 0): (1, 1), (8, 5, -1, 1): (1, 1), (8, 5, -1, 2): (1, 1), (8, 5, -1, 3): (1, 1), (8, 5, -1, 4): (1, 1), (8, 5, -1, 5): (1, 0), (8, 5, 0, -5): (1, 0), (8, 5, 0, -4): (1, -1), (8, 5, 0, -3): (1, 1), (8, 5, 0, -2): (1, 1), (8, 5, 0, -1): (1, 1), (8, 5, 0, 0): (0, 1), (8, 5, 0, 1): (0, 1), (8, 5, 0, 2): (0, 1), (8, 5, 0, 3): (0, 1), (8, 5, 0, 4): (0, 1), (8, 5, 0, 5): (0, 1), (8, 5, 1, -5): (0, 0), (8, 5, 1, -4): (1, 1), (8, 5, 1, -3): (1, 1), (8, 5, 1, -2): (1, 1), (8, 5, 1, -1): (0, 1), (8, 5, 1, 0): (-1, 1), (8, 5, 1, 1): (-1, 1), (8, 5, 1, 2): (-1, 1), (8, 5, 1, 3): (-1, 1), (8, 5, 1, 4): (-1, 1), (8, 5, 1, 5): (-1, 1), (8, 5, 2, -5): (0, 1), (8, 5, 2, -4): (0, 1), (8, 5, 2, -3): (0, 1), (8, 5, 2, -2): (0, 1), (8, 5, 2, -1): (0, 1), (8, 5, 2, 0): (-1, 1), (8, 5, 2, 1): (-1, 1), (8, 5, 2, 2): (-1, 1), (8, 5, 2, 3): (-1, 1), (8, 5, 2, 4): (-1, 1), (8, 5, 2, 5): (-1, 1), (8, 5, 3, -5): (0, 1), (8, 5, 3, -4): (0, 1), (8, 5, 3, -3): (0, 1), (8, 5, 3, -2): (0, 1), (8, 5, 3, -1): (0, 1), (8, 5, 3, 0): (0, 1), (8, 5, 3, 1): (0, 1), (8, 5, 3, 2): (0, 1), (8, 5, 3, 3): (0, 1), (8, 5, 3, 4): (0, 1), (8, 5, 3, 5): (0, 1), (8, 5, 4, -5): (0, 1), (8, 5, 4, -4): (0, 1), (8, 5, 4, -3): (0, 1), (8, 5, 4, -2): (0, 1), (8, 5, 4, -1): (0, 1), (8, 5, 4, 0): (0, 1), (8, 5, 4, 1): (0, 1), (8, 5, 4, 2): (0, 1), (8, 5, 4, 3): (0, 1), (8, 5, 4, 4): (0, 1), (8, 5, 4, 5): (0, 1), (8, 5, 5, -5): (0, 1), (8, 5, 5, -4): (0, 1), (8, 5, 5, -3): (0, 1), (8, 5, 5, -2): (0, 1), (8, 5, 5, -1): (0, 1), (8, 5, 5, 0): (0, 1), (8, 5, 5, 1): (0, 1), (8, 5, 5, 2): (0, 1), (8, 5, 5, 3): (0, 1), (8, 5, 5, 4): (0, 1), (8, 5, 5, 5): (0, 1), (8, 6, -5, -5): (0, 1), (8, 6, -5, -4): (0, 1), (8, 6, -5, -3): (0, 1), (8, 6, -5, -2): (0, 1), (8, 6, -5, -1): (0, 1), (8, 6, -5, 0): (0, 1), (8, 6, -5, 1): (0, 1), (8, 6, -5, 2): (0, 1), (8, 6, -5, 3): (0, 1), (8, 6, -5, 4): (0, 1), (8, 6, -5, 5): (0, 1), (8, 6, -4, -5): (0, 1), (8, 6, -4, -4): (0, 1), (8, 6, -4, -3): (0, 1), (8, 6, -4, -2): (0, 1), (8, 6, -4, -1): (0, 1), (8, 6, -4, 0): (0, 1), (8, 6, -4, 1): (0, 1), (8, 6, -4, 2): (0, 1), (8, 6, -4, 3): (0, 1), (8, 6, -4, 4): (0, 1), (8, 6, -4, 5): (0, 1), (8, 6, -3, -5): (0, 1), (8, 6, -3, -4): (0, 1), (8, 6, -3, -3): (0, 1), (8, 6, -3, -2): (0, 1), (8, 6, -3, -1): (0, 1), (8, 6, -3, 0): (0, 1), (8, 6, -3, 1): (0, 1), (8, 6, -3, 2): (0, 1), (8, 6, -3, 3): (1, 1), (8, 6, -3, 4): (0, 1), (8, 6, -3, 5): (0, 1), (8, 6, -2, -5): (-1, 1), (8, 6, -2, -4): (-1, 1), (8, 6, -2, -3): (-1, 1), (8, 6, -2, -2): (-1, 1), (8, 6, -2, -1): (-1, 1), (8, 6, -2, 0): (1, 1), (8, 6, -2, 1): (1, 1), (8, 6, -2, 2): (1, 1), (8, 6, -2, 3): (1, 1), (8, 6, -2, 4): (1, 1), (8, 6, -2, 5): (1, 0), (8, 6, -1, -5): (-1, 1), (8, 6, -1, -4): (-1, 1), (8, 6, -1, -3): (-1, 1), (8, 6, -1, -2): (-1, 1), (8, 6, -1, -1): (1, 1), (8, 6, -1, 0): (1, 1), (8, 6, -1, 1): (1, 1), (8, 6, -1, 2): (1, 1), (8, 6, -1, 3): (1, 1), (8, 6, -1, 4): (1, 1), (8, 6, -1, 5): (1, 0), (8, 6, 0, -5): (1, 0), (8, 6, 0, -4): (1, 0), (8, 6, 0, -3): (1, 1), (8, 6, 0, -2): (1, 1), (8, 6, 0, -1): (1, 1), (8, 6, 0, 0): (0, 1), (8, 6, 0, 1): (0, 1), (8, 6, 0, 2): (0, 1), (8, 6, 0, 3): (0, 1), (8, 6, 0, 4): (0, 1), (8, 6, 0, 5): (0, 1), (8, 6, 1, -5): (1, 1), (8, 6, 1, -4): (1, 1), (8, 6, 1, -3): (1, 1), (8, 6, 1, -2): (1, 1), (8, 6, 1, -1): (0, 1), (8, 6, 1, 0): (-1, 1), (8, 6, 1, 1): (-1, 1), (8, 6, 1, 2): (-1, 1), (8, 6, 1, 3): (-1, 1), (8, 6, 1, 4): (-1, 1), (8, 6, 1, 5): (-1, 1), (8, 6, 2, -5): (0, 1), (8, 6, 2, -4): (0, 1), (8, 6, 2, -3): (0, 1), (8, 6, 2, -2): (0, 1), (8, 6, 2, -1): (0, 1), (8, 6, 2, 0): (-1, 1), (8, 6, 2, 1): (-1, 1), (8, 6, 2, 2): (-1, 1), (8, 6, 2, 3): (-1, 1), (8, 6, 2, 4): (-1, 1), (8, 6, 2, 5): (-1, 1), (8, 6, 3, -5): (0, 1), (8, 6, 3, -4): (0, 1), (8, 6, 3, -3): (0, 1), (8, 6, 3, -2): (0, 1), (8, 6, 3, -1): (0, 1), (8, 6, 3, 0): (0, 1), (8, 6, 3, 1): (0, 1), (8, 6, 3, 2): (0, 1), (8, 6, 3, 3): (0, 1), (8, 6, 3, 4): (0, 1), (8, 6, 3, 5): (0, 1), (8, 6, 4, -5): (0, 1), (8, 6, 4, -4): (0, 1), (8, 6, 4, -3): (0, 1), (8, 6, 4, -2): (0, 1), (8, 6, 4, -1): (0, 1), (8, 6, 4, 0): (0, 1), (8, 6, 4, 1): (0, 1), (8, 6, 4, 2): (0, 1), (8, 6, 4, 3): (0, 1), (8, 6, 4, 4): (0, 1), (8, 6, 4, 5): (0, 1), (8, 6, 5, -5): (0, 1), (8, 6, 5, -4): (0, 1), (8, 6, 5, -3): (0, 1), (8, 6, 5, -2): (0, 1), (8, 6, 5, -1): (0, 1), (8, 6, 5, 0): (0, 1), (8, 6, 5, 1): (0, 1), (8, 6, 5, 2): (0, 1), (8, 6, 5, 3): (0, 1), (8, 6, 5, 4): (0, 1), (8, 6, 5, 5): (0, 1), (8, 7, -5, -5): (0, 1), (8, 7, -5, -4): (0, 1), (8, 7, -5, -3): (0, 1), (8, 7, -5, -2): (0, 1), (8, 7, -5, -1): (0, 1), (8, 7, -5, 0): (0, 1), (8, 7, -5, 1): (0, 1), (8, 7, -5, 2): (0, 1), (8, 7, -5, 3): (0, 1), (8, 7, -5, 4): (0, 1), (8, 7, -5, 5): (0, 1), (8, 7, -4, -5): (0, 1), (8, 7, -4, -4): (0, 1), (8, 7, -4, -3): (0, 1), (8, 7, -4, -2): (0, 1), (8, 7, -4, -1): (0, 1), (8, 7, -4, 0): (0, 1), (8, 7, -4, 1): (0, 1), (8, 7, -4, 2): (0, 1), (8, 7, -4, 3): (0, 1), (8, 7, -4, 4): (0, 1), (8, 7, -4, 5): (0, 1), (8, 7, -3, -5): (0, 1), (8, 7, -3, -4): (0, 1), (8, 7, -3, -3): (0, 1), (8, 7, -3, -2): (0, 1), (8, 7, -3, -1): (0, 1), (8, 7, -3, 0): (0, 1), (8, 7, -3, 1): (0, 1), (8, 7, -3, 2): (0, 1), (8, 7, -3, 3): (0, 1), (8, 7, -3, 4): (1, 1), (8, 7, -3, 5): (1, 0), (8, 7, -2, -5): (-1, 1), (8, 7, -2, -4): (-1, 1), (8, 7, -2, -3): (-1, 1), (8, 7, -2, -2): (-1, 1), (8, 7, -2, -1): (-1, 1), (8, 7, -2, 0): (1, 1), (8, 7, -2, 1): (1, 1), (8, 7, -2, 2): (1, 1), (8, 7, -2, 3): (1, 1), (8, 7, -2, 4): (1, 1), (8, 7, -2, 5): (1, 0), (8, 7, -1, -5): (-1, 1), (8, 7, -1, -4): (-1, 0), (8, 7, -1, -3): (-1, 1), (8, 7, -1, -2): (-1, 1), (8, 7, -1, -1): (1, 1), (8, 7, -1, 0): (1, 1), (8, 7, -1, 1): (1, 1), (8, 7, -1, 2): (1, 1), (8, 7, -1, 3): (1, 1), (8, 7, -1, 4): (1, 1), (8, 7, -1, 5): (1, 0), (8, 7, 0, -5): (1, 0), (8, 7, 0, -4): (1, 1), (8, 7, 0, -3): (1, 1), (8, 7, 0, -2): (1, 1), (8, 7, 0, -1): (1, 1), (8, 7, 0, 0): (0, 1), (8, 7, 0, 1): (0, 1), (8, 7, 0, 2): (0, 1), (8, 7, 0, 3): (0, 1), (8, 7, 0, 4): (0, 1), (8, 7, 0, 5): (0, 1), (8, 7, 1, -5): (1, 1), (8, 7, 1, -4): (1, 1), (8, 7, 1, -3): (1, 1), (8, 7, 1, -2): (1, 1), (8, 7, 1, -1): (0, 1), (8, 7, 1, 0): (-1, 1), (8, 7, 1, 1): (-1, 1), (8, 7, 1, 2): (-1, 1), (8, 7, 1, 3): (-1, 1), (8, 7, 1, 4): (-1, 1), (8, 7, 1, 5): (-1, 1), (8, 7, 2, -5): (0, 1), (8, 7, 2, -4): (0, 1), (8, 7, 2, -3): (0, 1), (8, 7, 2, -2): (0, 1), (8, 7, 2, -1): (0, 1), (8, 7, 2, 0): (-1, 1), (8, 7, 2, 1): (-1, 1), (8, 7, 2, 2): (-1, 1), (8, 7, 2, 3): (-1, 1), (8, 7, 2, 4): (-1, 1), (8, 7, 2, 5): (-1, 1), (8, 7, 3, -5): (0, 1), (8, 7, 3, -4): (0, 1), (8, 7, 3, -3): (0, 1), (8, 7, 3, -2): (0, 1), (8, 7, 3, -1): (0, 1), (8, 7, 3, 0): (0, 1), (8, 7, 3, 1): (0, 1), (8, 7, 3, 2): (0, 1), (8, 7, 3, 3): (0, 1), (8, 7, 3, 4): (0, 1), (8, 7, 3, 5): (0, 1), (8, 7, 4, -5): (0, 1), (8, 7, 4, -4): (0, 1), (8, 7, 4, -3): (0, 1), (8, 7, 4, -2): (0, 1), (8, 7, 4, -1): (0, 1), (8, 7, 4, 0): (0, 1), (8, 7, 4, 1): (0, 1), (8, 7, 4, 2): (0, 1), (8, 7, 4, 3): (0, 1), (8, 7, 4, 4): (0, 1), (8, 7, 4, 5): (0, 1), (8, 7, 5, -5): (0, 1), (8, 7, 5, -4): (0, 1), (8, 7, 5, -3): (0, 1), (8, 7, 5, -2): (0, 1), (8, 7, 5, -1): (0, 1), (8, 7, 5, 0): (0, 1), (8, 7, 5, 1): (0, 1), (8, 7, 5, 2): (0, 1), (8, 7, 5, 3): (0, 1), (8, 7, 5, 4): (0, 1), (8, 7, 5, 5): (0, 1), (8, 8, -5, -5): (0, 1), (8, 8, -5, -4): (0, 1), (8, 8, -5, -3): (0, 1), (8, 8, -5, -2): (0, 1), (8, 8, -5, -1): (0, 1), (8, 8, -5, 0): (0, 1), (8, 8, -5, 1): (0, 1), (8, 8, -5, 2): (0, 1), (8, 8, -5, 3): (0, 1), (8, 8, -5, 4): (0, 1), (8, 8, -5, 5): (0, 1), (8, 8, -4, -5): (0, 1), (8, 8, -4, -4): (0, 1), (8, 8, -4, -3): (0, 1), (8, 8, -4, -2): (0, 1), (8, 8, -4, -1): (0, 1), (8, 8, -4, 0): (0, 1), (8, 8, -4, 1): (0, 1), (8, 8, -4, 2): (0, 1), (8, 8, -4, 3): (0, 1), (8, 8, -4, 4): (0, 1), (8, 8, -4, 5): (0, 1), (8, 8, -3, -5): (0, 1), (8, 8, -3, -4): (0, 1), (8, 8, -3, -3): (0, 1), (8, 8, -3, -2): (0, 1), (8, 8, -3, -1): (0, 1), (8, 8, -3, 0): (0, 1), (8, 8, -3, 1): (0, 1), (8, 8, -3, 2): (0, 1), (8, 8, -3, 3): (1, 1), (8, 8, -3, 4): (1, 1), (8, 8, -3, 5): (1, 0), (8, 8, -2, -5): (-1, 1), (8, 8, -2, -4): (-1, 1), (8, 8, -2, -3): (-1, 1), (8, 8, -2, -2): (-1, 1), (8, 8, -2, -1): (-1, 1), (8, 8, -2, 0): (1, 1), (8, 8, -2, 1): (1, 1), (8, 8, -2, 2): (1, 1), (8, 8, -2, 3): (1, 1), (8, 8, -2, 4): (1, 1), (8, 8, -2, 5): (1, 0), (8, 8, -1, -5): (-1, 1), (8, 8, -1, -4): (-1, 1), (8, 8, -1, -3): (-1, 1), (8, 8, -1, -2): (-1, 1), (8, 8, -1, -1): (1, 1), (8, 8, -1, 0): (1, 1), (8, 8, -1, 1): (1, 1), (8, 8, -1, 2): (1, 1), (8, 8, -1, 3): (1, 1), (8, 8, -1, 4): (1, 1), (8, 8, -1, 5): (1, 0), (8, 8, 0, -5): (1, 0), (8, 8, 0, -4): (1, 1), (8, 8, 0, -3): (1, 1), (8, 8, 0, -2): (1, 1), (8, 8, 0, -1): (1, 1), (8, 8, 0, 0): (0, 1), (8, 8, 0, 1): (0, 1), (8, 8, 0, 2): (0, 1), (8, 8, 0, 3): (0, 1), (8, 8, 0, 4): (0, 1), (8, 8, 0, 5): (0, 1), (8, 8, 1, -5): (1, 1), (8, 8, 1, -4): (1, 1), (8, 8, 1, -3): (1, 1), (8, 8, 1, -2): (1, 1), (8, 8, 1, -1): (0, 1), (8, 8, 1, 0): (-1, 1), (8, 8, 1, 1): (-1, 1), (8, 8, 1, 2): (-1, 1), (8, 8, 1, 3): (-1, 1), (8, 8, 1, 4): (-1, 1), (8, 8, 1, 5): (-1, 1), (8, 8, 2, -5): (0, 1), (8, 8, 2, -4): (0, 1), (8, 8, 2, -3): (0, 1), (8, 8, 2, -2): (0, 1), (8, 8, 2, -1): (0, 1), (8, 8, 2, 0): (-1, 1), (8, 8, 2, 1): (-1, 1), (8, 8, 2, 2): (-1, 1), (8, 8, 2, 3): (-1, 1), (8, 8, 2, 4): (-1, 1), (8, 8, 2, 5): (-1, 1), (8, 8, 3, -5): (0, 1), (8, 8, 3, -4): (0, 1), (8, 8, 3, -3): (0, 1), (8, 8, 3, -2): (0, 1), (8, 8, 3, -1): (0, 1), (8, 8, 3, 0): (0, 1), (8, 8, 3, 1): (0, 1), (8, 8, 3, 2): (0, 1), (8, 8, 3, 3): (0, 1), (8, 8, 3, 4): (0, 1), (8, 8, 3, 5): (0, 1), (8, 8, 4, -5): (0, 1), (8, 8, 4, -4): (0, 1), (8, 8, 4, -3): (0, 1), (8, 8, 4, -2): (0, 1), (8, 8, 4, -1): (0, 1), (8, 8, 4, 0): (0, 1), (8, 8, 4, 1): (0, 1), (8, 8, 4, 2): (0, 1), (8, 8, 4, 3): (0, 1), (8, 8, 4, 4): (0, 1), (8, 8, 4, 5): (0, 1), (8, 8, 5, -5): (0, 1), (8, 8, 5, -4): (0, 1), (8, 8, 5, -3): (0, 1), (8, 8, 5, -2): (0, 1), (8, 8, 5, -1): (0, 1), (8, 8, 5, 0): (0, 1), (8, 8, 5, 1): (0, 1), (8, 8, 5, 2): (0, 1), (8, 8, 5, 3): (0, 1), (8, 8, 5, 4): (0, 1), (8, 8, 5, 5): (0, 1), (8, 9, -5, -5): (0, 1), (8, 9, -5, -4): (0, 1), (8, 9, -5, -3): (0, 1), (8, 9, -5, -2): (0, 1), (8, 9, -5, -1): (0, 1), (8, 9, -5, 0): (0, 1), (8, 9, -5, 1): (0, 1), (8, 9, -5, 2): (0, 1), (8, 9, -5, 3): (0, 1), (8, 9, -5, 4): (0, 1), (8, 9, -5, 5): (0, 1), (8, 9, -4, -5): (0, 1), (8, 9, -4, -4): (0, 1), (8, 9, -4, -3): (0, 1), (8, 9, -4, -2): (0, 1), (8, 9, -4, -1): (0, 1), (8, 9, -4, 0): (0, 1), (8, 9, -4, 1): (0, 1), (8, 9, -4, 2): (0, 1), (8, 9, -4, 3): (0, 1), (8, 9, -4, 4): (0, 1), (8, 9, -4, 5): (0, 1), (8, 9, -3, -5): (0, 1), (8, 9, -3, -4): (0, 1), (8, 9, -3, -3): (0, 1), (8, 9, -3, -2): (0, 1), (8, 9, -3, -1): (0, 1), (8, 9, -3, 0): (0, 1), (8, 9, -3, 1): (0, 1), (8, 9, -3, 2): (0, 1), (8, 9, -3, 3): (1, 1), (8, 9, -3, 4): (1, 1), (8, 9, -3, 5): (1, 0), (8, 9, -2, -5): (-1, 1), (8, 9, -2, -4): (-1, 1), (8, 9, -2, -3): (-1, 1), (8, 9, -2, -2): (-1, 1), (8, 9, -2, -1): (-1, 1), (8, 9, -2, 0): (1, 1), (8, 9, -2, 1): (1, 1), (8, 9, -2, 2): (1, 1), (8, 9, -2, 3): (1, 1), (8, 9, -2, 4): (1, 1), (8, 9, -2, 5): (1, 0), (8, 9, -1, -5): (-1, 0), (8, 9, -1, -4): (-1, 1), (8, 9, -1, -3): (-1, 1), (8, 9, -1, -2): (-1, 1), (8, 9, -1, -1): (1, 1), (8, 9, -1, 0): (1, 1), (8, 9, -1, 1): (1, 1), (8, 9, -1, 2): (1, 1), (8, 9, -1, 3): (1, 1), (8, 9, -1, 4): (1, 1), (8, 9, -1, 5): (1, 0), (8, 9, 0, -5): (1, 1), (8, 9, 0, -4): (1, 1), (8, 9, 0, -3): (1, 1), (8, 9, 0, -2): (1, 1), (8, 9, 0, -1): (1, 1), (8, 9, 0, 0): (1, 1), (8, 9, 0, 1): (0, 1), (8, 9, 0, 2): (0, 1), (8, 9, 0, 3): (0, 1), (8, 9, 0, 4): (0, 1), (8, 9, 0, 5): (0, 1), (8, 9, 1, -5): (1, 1), (8, 9, 1, -4): (1, 1), (8, 9, 1, -3): (1, 1), (8, 9, 1, -2): (1, 1), (8, 9, 1, -1): (0, 1), (8, 9, 1, 0): (0, 1), (8, 9, 1, 1): (-1, 1), (8, 9, 1, 2): (-1, 1), (8, 9, 1, 3): (-1, 1), (8, 9, 1, 4): (-1, 1), (8, 9, 1, 5): (-1, 1), (8, 9, 2, -5): (0, 1), (8, 9, 2, -4): (0, 1), (8, 9, 2, -3): (0, 1), (8, 9, 2, -2): (0, 1), (8, 9, 2, -1): (0, 1), (8, 9, 2, 0): (-1, 1), (8, 9, 2, 1): (-1, 1), (8, 9, 2, 2): (-1, 1), (8, 9, 2, 3): (-1, 1), (8, 9, 2, 4): (-1, 1), (8, 9, 2, 5): (-1, 1), (8, 9, 3, -5): (0, 1), (8, 9, 3, -4): (0, 1), (8, 9, 3, -3): (0, 1), (8, 9, 3, -2): (0, 1), (8, 9, 3, -1): (0, 1), (8, 9, 3, 0): (0, 1), (8, 9, 3, 1): (0, 1), (8, 9, 3, 2): (0, 1), (8, 9, 3, 3): (0, 1), (8, 9, 3, 4): (0, 1), (8, 9, 3, 5): (0, 1), (8, 9, 4, -5): (0, 1), (8, 9, 4, -4): (0, 1), (8, 9, 4, -3): (0, 1), (8, 9, 4, -2): (0, 1), (8, 9, 4, -1): (0, 1), (8, 9, 4, 0): (0, 1), (8, 9, 4, 1): (0, 1), (8, 9, 4, 2): (0, 1), (8, 9, 4, 3): (0, 1), (8, 9, 4, 4): (0, 1), (8, 9, 4, 5): (0, 1), (8, 9, 5, -5): (0, 1), (8, 9, 5, -4): (0, 1), (8, 9, 5, -3): (0, 1), (8, 9, 5, -2): (0, 1), (8, 9, 5, -1): (0, 1), (8, 9, 5, 0): (0, 1), (8, 9, 5, 1): (0, 1), (8, 9, 5, 2): (0, 1), (8, 9, 5, 3): (0, 1), (8, 9, 5, 4): (0, 1), (8, 9, 5, 5): (0, 1), (8, 10, -5, -5): (0, 1), (8, 10, -5, -4): (0, 1), (8, 10, -5, -3): (0, 1), (8, 10, -5, -2): (0, 1), (8, 10, -5, -1): (0, 1), (8, 10, -5, 0): (0, 1), (8, 10, -5, 1): (0, 1), (8, 10, -5, 2): (0, 1), (8, 10, -5, 3): (0, 1), (8, 10, -5, 4): (0, 1), (8, 10, -5, 5): (0, 1), (8, 10, -4, -5): (0, 1), (8, 10, -4, -4): (0, 1), (8, 10, -4, -3): (0, 1), (8, 10, -4, -2): (0, 1), (8, 10, -4, -1): (0, 1), (8, 10, -4, 0): (0, 1), (8, 10, -4, 1): (0, 1), (8, 10, -4, 2): (0, 1), (8, 10, -4, 3): (0, 1), (8, 10, -4, 4): (0, 1), (8, 10, -4, 5): (0, 1), (8, 10, -3, -5): (0, 1), (8, 10, -3, -4): (0, 1), (8, 10, -3, -3): (0, 1), (8, 10, -3, -2): (0, 1), (8, 10, -3, -1): (0, 1), (8, 10, -3, 0): (0, 1), (8, 10, -3, 1): (0, 1), (8, 10, -3, 2): (0, 1), (8, 10, -3, 3): (1, 1), (8, 10, -3, 4): (1, 1), (8, 10, -3, 5): (1, 0), (8, 10, -2, -5): (-1, 1), (8, 10, -2, -4): (-1, 1), (8, 10, -2, -3): (-1, 1), (8, 10, -2, -2): (-1, 1), (8, 10, -2, -1): (-1, 1), (8, 10, -2, 0): (1, 1), (8, 10, -2, 1): (1, 1), (8, 10, -2, 2): (1, 1), (8, 10, -2, 3): (1, 1), (8, 10, -2, 4): (1, 1), (8, 10, -2, 5): (1, 0), (8, 10, -1, -5): (-1, 1), (8, 10, -1, -4): (-1, 1), (8, 10, -1, -3): (-1, 1), (8, 10, -1, -2): (-1, 1), (8, 10, -1, -1): (1, 1), (8, 10, -1, 0): (1, 1), (8, 10, -1, 1): (1, 1), (8, 10, -1, 2): (1, 1), (8, 10, -1, 3): (1, 1), (8, 10, -1, 4): (1, 0), (8, 10, -1, 5): (1, -1), (8, 10, 0, -5): (1, 1), (8, 10, 0, -4): (1, 1), (8, 10, 0, -3): (1, 1), (8, 10, 0, -2): (1, 1), (8, 10, 0, -1): (1, 1), (8, 10, 0, 0): (1, 1), (8, 10, 0, 1): (0, 1), (8, 10, 0, 2): (0, 1), (8, 10, 0, 3): (0, 1), (8, 10, 0, 4): (0, 0), (8, 10, 0, 5): (0, -1), (8, 10, 1, -5): (1, 1), (8, 10, 1, -4): (1, 1), (8, 10, 1, -3): (1, 1), (8, 10, 1, -2): (1, 1), (8, 10, 1, -1): (0, 1), (8, 10, 1, 0): (0, 1), (8, 10, 1, 1): (-1, 1), (8, 10, 1, 2): (-1, 1), (8, 10, 1, 3): (-1, 1), (8, 10, 1, 4): (-1, 0), (8, 10, 1, 5): (-1, -1), (8, 10, 2, -5): (0, 1), (8, 10, 2, -4): (0, 1), (8, 10, 2, -3): (0, 1), (8, 10, 2, -2): (0, 1), (8, 10, 2, -1): (0, 1), (8, 10, 2, 0): (-1, 1), (8, 10, 2, 1): (-1, 1), (8, 10, 2, 2): (-1, 1), (8, 10, 2, 3): (-1, 1), (8, 10, 2, 4): (-1, 1), (8, 10, 2, 5): (-1, 1), (8, 10, 3, -5): (0, 1), (8, 10, 3, -4): (0, 1), (8, 10, 3, -3): (0, 1), (8, 10, 3, -2): (0, 1), (8, 10, 3, -1): (0, 1), (8, 10, 3, 0): (0, 1), (8, 10, 3, 1): (0, 1), (8, 10, 3, 2): (0, 1), (8, 10, 3, 3): (0, 1), (8, 10, 3, 4): (0, 1), (8, 10, 3, 5): (0, 1), (8, 10, 4, -5): (0, 1), (8, 10, 4, -4): (0, 1), (8, 10, 4, -3): (0, 1), (8, 10, 4, -2): (0, 1), (8, 10, 4, -1): (0, 1), (8, 10, 4, 0): (0, 1), (8, 10, 4, 1): (0, 1), (8, 10, 4, 2): (0, 1), (8, 10, 4, 3): (0, 1), (8, 10, 4, 4): (0, 1), (8, 10, 4, 5): (0, 1), (8, 10, 5, -5): (0, 1), (8, 10, 5, -4): (0, 1), (8, 10, 5, -3): (0, 1), (8, 10, 5, -2): (0, 1), (8, 10, 5, -1): (0, 1), (8, 10, 5, 0): (0, 1), (8, 10, 5, 1): (0, 1), (8, 10, 5, 2): (0, 1), (8, 10, 5, 3): (0, 1), (8, 10, 5, 4): (0, 1), (8, 10, 5, 5): (0, 1), (8, 11, -5, -5): (0, 1), (8, 11, -5, -4): (0, 1), (8, 11, -5, -3): (0, 1), (8, 11, -5, -2): (0, 1), (8, 11, -5, -1): (0, 1), (8, 11, -5, 0): (0, 1), (8, 11, -5, 1): (0, 1), (8, 11, -5, 2): (0, 1), (8, 11, -5, 3): (0, 1), (8, 11, -5, 4): (0, 1), (8, 11, -5, 5): (0, 1), (8, 11, -4, -5): (0, 1), (8, 11, -4, -4): (0, 1), (8, 11, -4, -3): (0, 1), (8, 11, -4, -2): (0, 1), (8, 11, -4, -1): (0, 1), (8, 11, -4, 0): (0, 1), (8, 11, -4, 1): (0, 1), (8, 11, -4, 2): (0, 1), (8, 11, -4, 3): (0, 1), (8, 11, -4, 4): (0, 1), (8, 11, -4, 5): (0, 1), (8, 11, -3, -5): (0, 1), (8, 11, -3, -4): (0, 1), (8, 11, -3, -3): (0, 1), (8, 11, -3, -2): (0, 1), (8, 11, -3, -1): (0, 1), (8, 11, -3, 0): (0, 1), (8, 11, -3, 1): (0, 1), (8, 11, -3, 2): (0, 1), (8, 11, -3, 3): (1, 1), (8, 11, -3, 4): (1, 1), (8, 11, -3, 5): (1, 0), (8, 11, -2, -5): (-1, 1), (8, 11, -2, -4): (-1, 1), (8, 11, -2, -3): (-1, 1), (8, 11, -2, -2): (-1, 1), (8, 11, -2, -1): (-1, 1), (8, 11, -2, 0): (1, 1), (8, 11, -2, 1): (1, 1), (8, 11, -2, 2): (1, 1), (8, 11, -2, 3): (1, 1), (8, 11, -2, 4): (1, 1), (8, 11, -2, 5): (1, 0), (8, 11, -1, -5): (-1, 1), (8, 11, -1, -4): (-1, 1), (8, 11, -1, -3): (-1, 1), (8, 11, -1, -2): (-1, 1), (8, 11, -1, -1): (1, 1), (8, 11, -1, 0): (1, 1), (8, 11, -1, 1): (1, 1), (8, 11, -1, 2): (1, 1), (8, 11, -1, 3): (1, 1), (8, 11, -1, 4): (1, 1), (8, 11, -1, 5): (1, 0), (8, 11, 0, -5): (1, 1), (8, 11, 0, -4): (1, 1), (8, 11, 0, -3): (1, 1), (8, 11, 0, -2): (1, 1), (8, 11, 0, -1): (1, 1), (8, 11, 0, 0): (1, 1), (8, 11, 0, 1): (0, 1), (8, 11, 0, 2): (0, 1), (8, 11, 0, 3): (0, 1), (8, 11, 0, 4): (0, 1), (8, 11, 0, 5): (0, 1), (8, 11, 1, -5): (1, 1), (8, 11, 1, -4): (1, 1), (8, 11, 1, -3): (1, 1), (8, 11, 1, -2): (1, 1), (8, 11, 1, -1): (0, 1), (8, 11, 1, 0): (0, 1), (8, 11, 1, 1): (-1, 1), (8, 11, 1, 2): (-1, 1), (8, 11, 1, 3): (-1, 1), (8, 11, 1, 4): (-1, 1), (8, 11, 1, 5): (-1, 1), (8, 11, 2, -5): (0, 1), (8, 11, 2, -4): (0, 1), (8, 11, 2, -3): (0, 1), (8, 11, 2, -2): (0, 1), (8, 11, 2, -1): (0, 1), (8, 11, 2, 0): (-1, 1), (8, 11, 2, 1): (-1, 1), (8, 11, 2, 2): (-1, 1), (8, 11, 2, 3): (-1, 1), (8, 11, 2, 4): (-1, 1), (8, 11, 2, 5): (-1, 1), (8, 11, 3, -5): (0, 1), (8, 11, 3, -4): (0, 1), (8, 11, 3, -3): (0, 1), (8, 11, 3, -2): (0, 1), (8, 11, 3, -1): (0, 1), (8, 11, 3, 0): (0, 1), (8, 11, 3, 1): (0, 1), (8, 11, 3, 2): (0, 1), (8, 11, 3, 3): (0, 1), (8, 11, 3, 4): (0, 1), (8, 11, 3, 5): (0, 1), (8, 11, 4, -5): (0, 1), (8, 11, 4, -4): (0, 1), (8, 11, 4, -3): (0, 1), (8, 11, 4, -2): (0, 1), (8, 11, 4, -1): (0, 1), (8, 11, 4, 0): (0, 1), (8, 11, 4, 1): (0, 1), (8, 11, 4, 2): (0, 1), (8, 11, 4, 3): (0, 1), (8, 11, 4, 4): (0, 1), (8, 11, 4, 5): (0, 1), (8, 11, 5, -5): (0, 1), (8, 11, 5, -4): (0, 1), (8, 11, 5, -3): (0, 1), (8, 11, 5, -2): (0, 1), (8, 11, 5, -1): (0, 1), (8, 11, 5, 0): (0, 1), (8, 11, 5, 1): (0, 1), (8, 11, 5, 2): (0, 1), (8, 11, 5, 3): (0, 1), (8, 11, 5, 4): (0, 1), (8, 11, 5, 5): (0, 1), (8, 12, -5, -5): (0, 1), (8, 12, -5, -4): (0, 1), (8, 12, -5, -3): (0, 1), (8, 12, -5, -2): (0, 1), (8, 12, -5, -1): (0, 1), (8, 12, -5, 0): (0, 1), (8, 12, -5, 1): (0, 1), (8, 12, -5, 2): (0, 1), (8, 12, -5, 3): (0, 1), (8, 12, -5, 4): (0, 1), (8, 12, -5, 5): (0, 1), (8, 12, -4, -5): (0, 1), (8, 12, -4, -4): (0, 1), (8, 12, -4, -3): (0, 1), (8, 12, -4, -2): (0, 1), (8, 12, -4, -1): (0, 1), (8, 12, -4, 0): (0, 1), (8, 12, -4, 1): (0, 1), (8, 12, -4, 2): (0, 1), (8, 12, -4, 3): (0, 1), (8, 12, -4, 4): (0, 1), (8, 12, -4, 5): (0, 1), (8, 12, -3, -5): (0, 1), (8, 12, -3, -4): (0, 1), (8, 12, -3, -3): (0, 1), (8, 12, -3, -2): (0, 1), (8, 12, -3, -1): (0, 1), (8, 12, -3, 0): (0, 1), (8, 12, -3, 1): (0, 1), (8, 12, -3, 2): (0, 1), (8, 12, -3, 3): (1, 1), (8, 12, -3, 4): (1, 1), (8, 12, -3, 5): (1, 0), (8, 12, -2, -5): (-1, 1), (8, 12, -2, -4): (-1, 1), (8, 12, -2, -3): (-1, 1), (8, 12, -2, -2): (-1, 1), (8, 12, -2, -1): (-1, 1), (8, 12, -2, 0): (1, 1), (8, 12, -2, 1): (1, 1), (8, 12, -2, 2): (1, 1), (8, 12, -2, 3): (1, 1), (8, 12, -2, 4): (1, 1), (8, 12, -2, 5): (1, 0), (8, 12, -1, -5): (-1, 1), (8, 12, -1, -4): (-1, 1), (8, 12, -1, -3): (-1, 1), (8, 12, -1, -2): (-1, 1), (8, 12, -1, -1): (1, 1), (8, 12, -1, 0): (1, 1), (8, 12, -1, 1): (1, 1), (8, 12, -1, 2): (1, 1), (8, 12, -1, 3): (1, 1), (8, 12, -1, 4): (1, 1), (8, 12, -1, 5): (1, 0), (8, 12, 0, -5): (1, 1), (8, 12, 0, -4): (1, 1), (8, 12, 0, -3): (1, 1), (8, 12, 0, -2): (1, 1), (8, 12, 0, -1): (1, 1), (8, 12, 0, 0): (0, 1), (8, 12, 0, 1): (0, 1), (8, 12, 0, 2): (0, 1), (8, 12, 0, 3): (0, 1), (8, 12, 0, 4): (0, 1), (8, 12, 0, 5): (0, 1), (8, 12, 1, -5): (1, 1), (8, 12, 1, -4): (1, 1), (8, 12, 1, -3): (1, 1), (8, 12, 1, -2): (1, 1), (8, 12, 1, -1): (0, 1), (8, 12, 1, 0): (-1, 1), (8, 12, 1, 1): (-1, 1), (8, 12, 1, 2): (-1, 1), (8, 12, 1, 3): (-1, 1), (8, 12, 1, 4): (-1, 1), (8, 12, 1, 5): (-1, 1), (8, 12, 2, -5): (0, 1), (8, 12, 2, -4): (0, 1), (8, 12, 2, -3): (0, 1), (8, 12, 2, -2): (0, 1), (8, 12, 2, -1): (0, 1), (8, 12, 2, 0): (-1, 1), (8, 12, 2, 1): (-1, 1), (8, 12, 2, 2): (-1, 1), (8, 12, 2, 3): (-1, 1), (8, 12, 2, 4): (-1, 1), (8, 12, 2, 5): (-1, 1), (8, 12, 3, -5): (0, 1), (8, 12, 3, -4): (0, 1), (8, 12, 3, -3): (0, 1), (8, 12, 3, -2): (0, 1), (8, 12, 3, -1): (0, 1), (8, 12, 3, 0): (0, 1), (8, 12, 3, 1): (0, 1), (8, 12, 3, 2): (0, 1), (8, 12, 3, 3): (0, 1), (8, 12, 3, 4): (0, 1), (8, 12, 3, 5): (0, 1), (8, 12, 4, -5): (0, 1), (8, 12, 4, -4): (0, 1), (8, 12, 4, -3): (0, 1), (8, 12, 4, -2): (0, 1), (8, 12, 4, -1): (0, 1), (8, 12, 4, 0): (0, 1), (8, 12, 4, 1): (0, 1), (8, 12, 4, 2): (0, 1), (8, 12, 4, 3): (0, 1), (8, 12, 4, 4): (0, 1), (8, 12, 4, 5): (0, 1), (8, 12, 5, -5): (0, 1), (8, 12, 5, -4): (0, 1), (8, 12, 5, -3): (0, 1), (8, 12, 5, -2): (0, 1), (8, 12, 5, -1): (0, 1), (8, 12, 5, 0): (0, 1), (8, 12, 5, 1): (0, 1), (8, 12, 5, 2): (0, 1), (8, 12, 5, 3): (0, 1), (8, 12, 5, 4): (0, 1), (8, 12, 5, 5): (0, 1), (8, 13, -5, -5): (0, 1), (8, 13, -5, -4): (0, 1), (8, 13, -5, -3): (0, 1), (8, 13, -5, -2): (0, 1), (8, 13, -5, -1): (0, 1), (8, 13, -5, 0): (0, 1), (8, 13, -5, 1): (0, 1), (8, 13, -5, 2): (0, 1), (8, 13, -5, 3): (0, 1), (8, 13, -5, 4): (0, 1), (8, 13, -5, 5): (0, 1), (8, 13, -4, -5): (0, 1), (8, 13, -4, -4): (0, 1), (8, 13, -4, -3): (0, 1), (8, 13, -4, -2): (0, 1), (8, 13, -4, -1): (0, 1), (8, 13, -4, 0): (0, 1), (8, 13, -4, 1): (0, 1), (8, 13, -4, 2): (0, 1), (8, 13, -4, 3): (0, 1), (8, 13, -4, 4): (0, 1), (8, 13, -4, 5): (0, 1), (8, 13, -3, -5): (0, 1), (8, 13, -3, -4): (0, 1), (8, 13, -3, -3): (0, 1), (8, 13, -3, -2): (0, 1), (8, 13, -3, -1): (0, 1), (8, 13, -3, 0): (0, 1), (8, 13, -3, 1): (0, 1), (8, 13, -3, 2): (0, 1), (8, 13, -3, 3): (1, 1), (8, 13, -3, 4): (1, 1), (8, 13, -3, 5): (1, 0), (8, 13, -2, -5): (-1, 1), (8, 13, -2, -4): (-1, 1), (8, 13, -2, -3): (-1, 1), (8, 13, -2, -2): (-1, 1), (8, 13, -2, -1): (-1, 1), (8, 13, -2, 0): (1, 1), (8, 13, -2, 1): (1, 1), (8, 13, -2, 2): (1, 1), (8, 13, -2, 3): (1, 1), (8, 13, -2, 4): (1, 1), (8, 13, -2, 5): (1, 0), (8, 13, -1, -5): (-1, 1), (8, 13, -1, -4): (-1, 1), (8, 13, -1, -3): (-1, 1), (8, 13, -1, -2): (-1, 1), (8, 13, -1, -1): (1, 1), (8, 13, -1, 0): (1, 1), (8, 13, -1, 1): (1, 1), (8, 13, -1, 2): (1, 1), (8, 13, -1, 3): (1, 1), (8, 13, -1, 4): (1, 1), (8, 13, -1, 5): (1, 0), (8, 13, 0, -5): (1, 1), (8, 13, 0, -4): (1, 1), (8, 13, 0, -3): (1, 1), (8, 13, 0, -2): (1, 1), (8, 13, 0, -1): (1, 1), (8, 13, 0, 0): (0, 1), (8, 13, 0, 1): (0, 1), (8, 13, 0, 2): (0, 1), (8, 13, 0, 3): (0, 1), (8, 13, 0, 4): (0, 1), (8, 13, 0, 5): (0, 1), (8, 13, 1, -5): (1, 1), (8, 13, 1, -4): (1, 1), (8, 13, 1, -3): (1, 1), (8, 13, 1, -2): (1, 1), (8, 13, 1, -1): (0, 1), (8, 13, 1, 0): (-1, 1), (8, 13, 1, 1): (-1, 1), (8, 13, 1, 2): (-1, 1), (8, 13, 1, 3): (-1, 1), (8, 13, 1, 4): (-1, 1), (8, 13, 1, 5): (-1, 1), (8, 13, 2, -5): (0, 1), (8, 13, 2, -4): (0, 1), (8, 13, 2, -3): (0, 1), (8, 13, 2, -2): (0, 1), (8, 13, 2, -1): (0, 1), (8, 13, 2, 0): (-1, 1), (8, 13, 2, 1): (-1, 1), (8, 13, 2, 2): (-1, 1), (8, 13, 2, 3): (-1, 1), (8, 13, 2, 4): (-1, 1), (8, 13, 2, 5): (-1, 1), (8, 13, 3, -5): (0, 1), (8, 13, 3, -4): (0, 1), (8, 13, 3, -3): (0, 1), (8, 13, 3, -2): (0, 1), (8, 13, 3, -1): (0, 1), (8, 13, 3, 0): (0, 1), (8, 13, 3, 1): (0, 1), (8, 13, 3, 2): (0, 1), (8, 13, 3, 3): (0, 1), (8, 13, 3, 4): (0, 1), (8, 13, 3, 5): (0, 1), (8, 13, 4, -5): (0, 1), (8, 13, 4, -4): (0, 1), (8, 13, 4, -3): (0, 1), (8, 13, 4, -2): (0, 1), (8, 13, 4, -1): (0, 1), (8, 13, 4, 0): (0, 1), (8, 13, 4, 1): (0, 1), (8, 13, 4, 2): (0, 1), (8, 13, 4, 3): (0, 1), (8, 13, 4, 4): (0, 1), (8, 13, 4, 5): (0, 1), (8, 13, 5, -5): (0, 1), (8, 13, 5, -4): (0, 1), (8, 13, 5, -3): (0, 1), (8, 13, 5, -2): (0, 1), (8, 13, 5, -1): (0, 1), (8, 13, 5, 0): (0, 1), (8, 13, 5, 1): (0, 1), (8, 13, 5, 2): (0, 1), (8, 13, 5, 3): (0, 1), (8, 13, 5, 4): (0, 1), (8, 13, 5, 5): (0, 1), (8, 14, -5, -5): (0, 1), (8, 14, -5, -4): (0, 1), (8, 14, -5, -3): (0, 1), (8, 14, -5, -2): (0, 1), (8, 14, -5, -1): (0, 1), (8, 14, -5, 0): (0, 1), (8, 14, -5, 1): (0, 1), (8, 14, -5, 2): (0, 1), (8, 14, -5, 3): (0, 1), (8, 14, -5, 4): (0, 0), (8, 14, -5, 5): (-1, -1), (8, 14, -4, -5): (0, 1), (8, 14, -4, -4): (0, 1), (8, 14, -4, -3): (0, 1), (8, 14, -4, -2): (0, 1), (8, 14, -4, -1): (0, 1), (8, 14, -4, 0): (0, 1), (8, 14, -4, 1): (0, 1), (8, 14, -4, 2): (0, 1), (8, 14, -4, 3): (0, 1), (8, 14, -4, 4): (0, 0), (8, 14, -4, 5): (-1, -1), (8, 14, -3, -5): (0, 1), (8, 14, -3, -4): (0, 1), (8, 14, -3, -3): (0, 1), (8, 14, -3, -2): (0, 1), (8, 14, -3, -1): (0, 1), (8, 14, -3, 0): (0, 1), (8, 14, -3, 1): (0, 1), (8, 14, -3, 2): (0, 1), (8, 14, -3, 3): (1, 1), (8, 14, -3, 4): (1, 1), (8, 14, -3, 5): (1, 0), (8, 14, -2, -5): (-1, 1), (8, 14, -2, -4): (-1, 1), (8, 14, -2, -3): (-1, 1), (8, 14, -2, -2): (-1, 1), (8, 14, -2, -1): (-1, 1), (8, 14, -2, 0): (1, 1), (8, 14, -2, 1): (1, 1), (8, 14, -2, 2): (1, 1), (8, 14, -2, 3): (1, 1), (8, 14, -2, 4): (1, 1), (8, 14, -2, 5): (1, 0), (8, 14, -1, -5): (-1, 1), (8, 14, -1, -4): (-1, 1), (8, 14, -1, -3): (-1, 1), (8, 14, -1, -2): (-1, 1), (8, 14, -1, -1): (1, 1), (8, 14, -1, 0): (1, 1), (8, 14, -1, 1): (1, 1), (8, 14, -1, 2): (1, 1), (8, 14, -1, 3): (1, 1), (8, 14, -1, 4): (1, 0), (8, 14, -1, 5): (1, -1), (8, 14, 0, -5): (1, 1), (8, 14, 0, -4): (1, 1), (8, 14, 0, -3): (1, 1), (8, 14, 0, -2): (1, 1), (8, 14, 0, -1): (1, 1), (8, 14, 0, 0): (0, 1), (8, 14, 0, 1): (0, 1), (8, 14, 0, 2): (0, 1), (8, 14, 0, 3): (0, 1), (8, 14, 0, 4): (0, 0), (8, 14, 0, 5): (0, -1), (8, 14, 1, -5): (1, 1), (8, 14, 1, -4): (1, 1), (8, 14, 1, -3): (1, 1), (8, 14, 1, -2): (1, 1), (8, 14, 1, -1): (0, 1), (8, 14, 1, 0): (-1, 1), (8, 14, 1, 1): (-1, 1), (8, 14, 1, 2): (-1, 1), (8, 14, 1, 3): (-1, 1), (8, 14, 1, 4): (-1, 0), (8, 14, 1, 5): (-1, -1), (8, 14, 2, -5): (0, 1), (8, 14, 2, -4): (0, 1), (8, 14, 2, -3): (0, 1), (8, 14, 2, -2): (0, 1), (8, 14, 2, -1): (0, 1), (8, 14, 2, 0): (-1, 1), (8, 14, 2, 1): (-1, 1), (8, 14, 2, 2): (-1, 1), (8, 14, 2, 3): (-1, 1), (8, 14, 2, 4): (-1, 1), (8, 14, 2, 5): (-1, 1), (8, 14, 3, -5): (0, 1), (8, 14, 3, -4): (0, 1), (8, 14, 3, -3): (0, 1), (8, 14, 3, -2): (0, 1), (8, 14, 3, -1): (0, 1), (8, 14, 3, 0): (0, 1), (8, 14, 3, 1): (0, 1), (8, 14, 3, 2): (0, 1), (8, 14, 3, 3): (0, 1), (8, 14, 3, 4): (0, 0), (8, 14, 3, 5): (-1, -1), (8, 14, 4, -5): (0, 1), (8, 14, 4, -4): (0, 1), (8, 14, 4, -3): (0, 1), (8, 14, 4, -2): (0, 1), (8, 14, 4, -1): (0, 1), (8, 14, 4, 0): (0, 1), (8, 14, 4, 1): (0, 1), (8, 14, 4, 2): (0, 1), (8, 14, 4, 3): (0, 1), (8, 14, 4, 4): (0, 0), (8, 14, 4, 5): (-1, -1), (8, 14, 5, -5): (0, 1), (8, 14, 5, -4): (0, 1), (8, 14, 5, -3): (0, 1), (8, 14, 5, -2): (0, 1), (8, 14, 5, -1): (0, 1), (8, 14, 5, 0): (0, 1), (8, 14, 5, 1): (0, 1), (8, 14, 5, 2): (0, 1), (8, 14, 5, 3): (0, 1), (8, 14, 5, 4): (0, 0), (8, 14, 5, 5): (-1, -1), (8, 15, -5, -5): (0, 1), (8, 15, -5, -4): (0, 1), (8, 15, -5, -3): (0, 1), (8, 15, -5, -2): (0, 1), (8, 15, -5, -1): (0, 1), (8, 15, -5, 0): (0, 1), (8, 15, -5, 1): (0, 1), (8, 15, -5, 2): (0, 1), (8, 15, -5, 3): (0, 0), (8, 15, -5, 4): (0, 1), (8, 15, -5, 5): (0, 1), (8, 15, -4, -5): (0, 1), (8, 15, -4, -4): (0, 1), (8, 15, -4, -3): (0, 1), (8, 15, -4, -2): (0, 1), (8, 15, -4, -1): (0, 1), (8, 15, -4, 0): (0, 1), (8, 15, -4, 1): (0, 1), (8, 15, -4, 2): (0, 1), (8, 15, -4, 3): (0, 0), (8, 15, -4, 4): (0, 1), (8, 15, -4, 5): (0, 1), (8, 15, -3, -5): (0, 1), (8, 15, -3, -4): (0, 1), (8, 15, -3, -3): (0, 1), (8, 15, -3, -2): (0, 1), (8, 15, -3, -1): (0, 1), (8, 15, -3, 0): (0, 1), (8, 15, -3, 1): (0, 1), (8, 15, -3, 2): (0, 1), (8, 15, -3, 3): (1, 1), (8, 15, -3, 4): (0, 1), (8, 15, -3, 5): (0, 1), (8, 15, -2, -5): (-1, 1), (8, 15, -2, -4): (-1, 1), (8, 15, -2, -3): (-1, 1), (8, 15, -2, -2): (-1, 1), (8, 15, -2, -1): (-1, 1), (8, 15, -2, 0): (1, 1), (8, 15, -2, 1): (1, 1), (8, 15, -2, 2): (1, 1), (8, 15, -2, 3): (1, 1), (8, 15, -2, 4): (1, 1), (8, 15, -2, 5): (1, 0), (8, 15, -1, -5): (-1, 1), (8, 15, -1, -4): (-1, 1), (8, 15, -1, -3): (-1, 1), (8, 15, -1, -2): (-1, 1), (8, 15, -1, -1): (1, 1), (8, 15, -1, 0): (1, 1), (8, 15, -1, 1): (1, 1), (8, 15, -1, 2): (1, 1), (8, 15, -1, 3): (1, 1), (8, 15, -1, 4): (1, 1), (8, 15, -1, 5): (1, 0), (8, 15, 0, -5): (1, 1), (8, 15, 0, -4): (1, 1), (8, 15, 0, -3): (1, 1), (8, 15, 0, -2): (1, 1), (8, 15, 0, -1): (1, 1), (8, 15, 0, 0): (1, 1), (8, 15, 0, 1): (0, 1), (8, 15, 0, 2): (0, 1), (8, 15, 0, 3): (0, 1), (8, 15, 0, 4): (0, 1), (8, 15, 0, 5): (0, 1), (8, 15, 1, -5): (1, 1), (8, 15, 1, -4): (1, 1), (8, 15, 1, -3): (1, 1), (8, 15, 1, -2): (1, 1), (8, 15, 1, -1): (0, 1), (8, 15, 1, 0): (0, 1), (8, 15, 1, 1): (-1, 1), (8, 15, 1, 2): (-1, 1), (8, 15, 1, 3): (-1, 1), (8, 15, 1, 4): (-1, 1), (8, 15, 1, 5): (-1, 1), (8, 15, 2, -5): (0, 1), (8, 15, 2, -4): (0, 1), (8, 15, 2, -3): (0, 1), (8, 15, 2, -2): (0, 1), (8, 15, 2, -1): (0, 1), (8, 15, 2, 0): (-1, 1), (8, 15, 2, 1): (-1, 1), (8, 15, 2, 2): (-1, 1), (8, 15, 2, 3): (-1, 1), (8, 15, 2, 4): (-1, 0), (8, 15, 2, 5): (-1, -1), (8, 15, 3, -5): (0, 1), (8, 15, 3, -4): (0, 1), (8, 15, 3, -3): (0, 1), (8, 15, 3, -2): (0, 1), (8, 15, 3, -1): (0, 1), (8, 15, 3, 0): (0, 1), (8, 15, 3, 1): (0, 1), (8, 15, 3, 2): (0, 1), (8, 15, 3, 3): (0, 0), (8, 15, 3, 4): (0, 1), (8, 15, 3, 5): (0, 1), (8, 15, 4, -5): (0, 1), (8, 15, 4, -4): (0, 1), (8, 15, 4, -3): (0, 1), (8, 15, 4, -2): (0, 1), (8, 15, 4, -1): (0, 1), (8, 15, 4, 0): (0, 1), (8, 15, 4, 1): (0, 1), (8, 15, 4, 2): (0, 1), (8, 15, 4, 3): (0, 0), (8, 15, 4, 4): (0, 1), (8, 15, 4, 5): (0, 1), (8, 15, 5, -5): (0, 1), (8, 15, 5, -4): (0, 1), (8, 15, 5, -3): (0, 1), (8, 15, 5, -2): (0, 1), (8, 15, 5, -1): (0, 1), (8, 15, 5, 0): (0, 1), (8, 15, 5, 1): (0, 1), (8, 15, 5, 2): (0, 1), (8, 15, 5, 3): (0, 0), (8, 15, 5, 4): (0, 1), (8, 15, 5, 5): (0, 1), (8, 16, -5, -5): (0, 1), (8, 16, -5, -4): (0, 1), (8, 16, -5, -3): (0, 1), (8, 16, -5, -2): (0, 1), (8, 16, -5, -1): (0, 1), (8, 16, -5, 0): (0, 1), (8, 16, -5, 1): (0, 1), (8, 16, -5, 2): (0, 0), (8, 16, -5, 3): (0, 1), (8, 16, -5, 4): (0, 1), (8, 16, -5, 5): (0, 1), (8, 16, -4, -5): (0, 1), (8, 16, -4, -4): (0, 1), (8, 16, -4, -3): (0, 1), (8, 16, -4, -2): (0, 1), (8, 16, -4, -1): (0, 1), (8, 16, -4, 0): (0, 1), (8, 16, -4, 1): (0, 1), (8, 16, -4, 2): (0, 0), (8, 16, -4, 3): (0, 1), (8, 16, -4, 4): (0, 1), (8, 16, -4, 5): (0, 1), (8, 16, -3, -5): (0, 1), (8, 16, -3, -4): (0, 1), (8, 16, -3, -3): (0, 1), (8, 16, -3, -2): (0, 1), (8, 16, -3, -1): (0, 1), (8, 16, -3, 0): (0, 1), (8, 16, -3, 1): (0, 1), (8, 16, -3, 2): (1, 1), (8, 16, -3, 3): (0, 1), (8, 16, -3, 4): (1, 1), (8, 16, -3, 5): (1, 0), (8, 16, -2, -5): (-1, 1), (8, 16, -2, -4): (-1, 1), (8, 16, -2, -3): (-1, 1), (8, 16, -2, -2): (-1, 1), (8, 16, -2, -1): (-1, 1), (8, 16, -2, 0): (1, 1), (8, 16, -2, 1): (1, 1), (8, 16, -2, 2): (1, 1), (8, 16, -2, 3): (1, 1), (8, 16, -2, 4): (1, 1), (8, 16, -2, 5): (1, 0), (8, 16, -1, -5): (-1, 1), (8, 16, -1, -4): (-1, 1), (8, 16, -1, -3): (-1, 1), (8, 16, -1, -2): (-1, 1), (8, 16, -1, -1): (1, 1), (8, 16, -1, 0): (1, 1), (8, 16, -1, 1): (1, 1), (8, 16, -1, 2): (1, 1), (8, 16, -1, 3): (1, 1), (8, 16, -1, 4): (0, 1), (8, 16, -1, 5): (0, 1), (8, 16, 0, -5): (1, 1), (8, 16, 0, -4): (1, 1), (8, 16, 0, -3): (1, 1), (8, 16, 0, -2): (1, 1), (8, 16, 0, -1): (1, 1), (8, 16, 0, 0): (1, 1), (8, 16, 0, 1): (0, 1), (8, 16, 0, 2): (0, 1), (8, 16, 0, 3): (0, 1), (8, 16, 0, 4): (-1, 1), (8, 16, 0, 5): (-1, 1), (8, 16, 1, -5): (1, 1), (8, 16, 1, -4): (1, 1), (8, 16, 1, -3): (1, 1), (8, 16, 1, -2): (1, 1), (8, 16, 1, -1): (0, 1), (8, 16, 1, 0): (0, 1), (8, 16, 1, 1): (-1, 1), (8, 16, 1, 2): (-1, 1), (8, 16, 1, 3): (-1, 1), (8, 16, 1, 4): (-1, 0), (8, 16, 1, 5): (-1, -1), (8, 16, 2, -5): (0, 1), (8, 16, 2, -4): (0, 1), (8, 16, 2, -3): (0, 1), (8, 16, 2, -2): (0, 1), (8, 16, 2, -1): (0, 1), (8, 16, 2, 0): (-1, 1), (8, 16, 2, 1): (-1, 1), (8, 16, 2, 2): (-1, 1), (8, 16, 2, 3): (-1, 1), (8, 16, 2, 4): (-1, 1), (8, 16, 2, 5): (-1, 1), (8, 16, 3, -5): (0, 1), (8, 16, 3, -4): (0, 1), (8, 16, 3, -3): (0, 1), (8, 16, 3, -2): (0, 1), (8, 16, 3, -1): (0, 1), (8, 16, 3, 0): (0, 1), (8, 16, 3, 1): (0, 1), (8, 16, 3, 2): (0, 0), (8, 16, 3, 3): (0, 1), (8, 16, 3, 4): (0, 1), (8, 16, 3, 5): (0, 1), (8, 16, 4, -5): (0, 1), (8, 16, 4, -4): (0, 1), (8, 16, 4, -3): (0, 1), (8, 16, 4, -2): (0, 1), (8, 16, 4, -1): (0, 1), (8, 16, 4, 0): (0, 1), (8, 16, 4, 1): (0, 1), (8, 16, 4, 2): (0, 0), (8, 16, 4, 3): (0, 1), (8, 16, 4, 4): (0, 1), (8, 16, 4, 5): (0, 1), (8, 16, 5, -5): (0, 1), (8, 16, 5, -4): (0, 1), (8, 16, 5, -3): (0, 1), (8, 16, 5, -2): (0, 1), (8, 16, 5, -1): (0, 1), (8, 16, 5, 0): (0, 1), (8, 16, 5, 1): (0, 1), (8, 16, 5, 2): (0, 0), (8, 16, 5, 3): (0, 1), (8, 16, 5, 4): (0, 1), (8, 16, 5, 5): (0, 1), (8, 17, -5, -5): (0, 1), (8, 17, -5, -4): (0, 1), (8, 17, -5, -3): (0, 1), (8, 17, -5, -2): (0, 1), (8, 17, -5, -1): (0, 1), (8, 17, -5, 0): (0, 1), (8, 17, -5, 1): (0, 0), (8, 17, -5, 2): (0, 1), (8, 17, -5, 3): (0, 1), (8, 17, -5, 4): (0, 1), (8, 17, -5, 5): (0, 1), (8, 17, -4, -5): (0, 1), (8, 17, -4, -4): (0, 1), (8, 17, -4, -3): (0, 1), (8, 17, -4, -2): (0, 1), (8, 17, -4, -1): (0, 1), (8, 17, -4, 0): (0, 1), (8, 17, -4, 1): (0, 0), (8, 17, -4, 2): (0, 1), (8, 17, -4, 3): (0, 1), (8, 17, -4, 4): (0, 1), (8, 17, -4, 5): (0, 1), (8, 17, -3, -5): (0, 1), (8, 17, -3, -4): (0, 1), (8, 17, -3, -3): (0, 1), (8, 17, -3, -2): (0, 1), (8, 17, -3, -1): (0, 1), (8, 17, -3, 0): (0, 1), (8, 17, -3, 1): (0, 0), (8, 17, -3, 2): (0, 1), (8, 17, -3, 3): (1, 1), (8, 17, -3, 4): (0, 1), (8, 17, -3, 5): (0, 1), (8, 17, -2, -5): (-1, 1), (8, 17, -2, -4): (-1, 1), (8, 17, -2, -3): (-1, 1), (8, 17, -2, -2): (-1, 1), (8, 17, -2, -1): (-1, 1), (8, 17, -2, 0): (1, 1), (8, 17, -2, 1): (1, 1), (8, 17, -2, 2): (1, 1), (8, 17, -2, 3): (1, 1), (8, 17, -2, 4): (1, 1), (8, 17, -2, 5): (1, 0), (8, 17, -1, -5): (-1, 1), (8, 17, -1, -4): (-1, 1), (8, 17, -1, -3): (-1, 1), (8, 17, -1, -2): (1, 1), (8, 17, -1, -1): (1, 1), (8, 17, -1, 0): (1, 1), (8, 17, -1, 1): (1, 1), (8, 17, -1, 2): (1, 1), (8, 17, -1, 3): (1, 0), (8, 17, -1, 4): (0, 1), (8, 17, -1, 5): (0, 1), (8, 17, 0, -5): (1, 1), (8, 17, 0, -4): (1, 1), (8, 17, 0, -3): (1, 1), (8, 17, 0, -2): (1, 1), (8, 17, 0, -1): (1, 1), (8, 17, 0, 0): (1, 1), (8, 17, 0, 1): (0, 1), (8, 17, 0, 2): (0, 1), (8, 17, 0, 3): (0, 0), (8, 17, 0, 4): (-1, 1), (8, 17, 0, 5): (-1, 1), (8, 17, 1, -5): (1, 1), (8, 17, 1, -4): (1, 1), (8, 17, 1, -3): (1, 1), (8, 17, 1, -2): (1, 1), (8, 17, 1, -1): (0, 1), (8, 17, 1, 0): (0, 1), (8, 17, 1, 1): (-1, 1), (8, 17, 1, 2): (-1, 1), (8, 17, 1, 3): (-1, 0), (8, 17, 1, 4): (-1, -1), (8, 17, 1, 5): (-1, 1), (8, 17, 2, -5): (0, 1), (8, 17, 2, -4): (0, 1), (8, 17, 2, -3): (0, 1), (8, 17, 2, -2): (0, 1), (8, 17, 2, -1): (0, 1), (8, 17, 2, 0): (-1, 1), (8, 17, 2, 1): (-1, 1), (8, 17, 2, 2): (-1, 1), (8, 17, 2, 3): (-1, 1), (8, 17, 2, 4): (-1, 1), (8, 17, 2, 5): (-1, 1), (8, 17, 3, -5): (0, 1), (8, 17, 3, -4): (0, 1), (8, 17, 3, -3): (0, 1), (8, 17, 3, -2): (0, 1), (8, 17, 3, -1): (0, 1), (8, 17, 3, 0): (0, 1), (8, 17, 3, 1): (0, 0), (8, 17, 3, 2): (0, 1), (8, 17, 3, 3): (0, 1), (8, 17, 3, 4): (0, 1), (8, 17, 3, 5): (0, 1), (8, 17, 4, -5): (0, 1), (8, 17, 4, -4): (0, 1), (8, 17, 4, -3): (0, 1), (8, 17, 4, -2): (0, 1), (8, 17, 4, -1): (0, 1), (8, 17, 4, 0): (0, 1), (8, 17, 4, 1): (0, 0), (8, 17, 4, 2): (0, 1), (8, 17, 4, 3): (0, 1), (8, 17, 4, 4): (0, 1), (8, 17, 4, 5): (0, 1), (8, 17, 5, -5): (0, 1), (8, 17, 5, -4): (0, 1), (8, 17, 5, -3): (0, 1), (8, 17, 5, -2): (0, 1), (8, 17, 5, -1): (0, 1), (8, 17, 5, 0): (0, 1), (8, 17, 5, 1): (0, 0), (8, 17, 5, 2): (0, 1), (8, 17, 5, 3): (0, 1), (8, 17, 5, 4): (0, 1), (8, 17, 5, 5): (0, 1), (8, 18, -5, -5): (0, 1), (8, 18, -5, -4): (0, 1), (8, 18, -5, -3): (0, 1), (8, 18, -5, -2): (0, 1), (8, 18, -5, -1): (0, 1), (8, 18, -5, 0): (0, 0), (8, 18, -5, 1): (0, 1), (8, 18, -5, 2): (0, 1), (8, 18, -5, 3): (0, 1), (8, 18, -5, 4): (0, 1), (8, 18, -5, 5): (0, 1), (8, 18, -4, -5): (0, 1), (8, 18, -4, -4): (0, 1), (8, 18, -4, -3): (0, 1), (8, 18, -4, -2): (0, 1), (8, 18, -4, -1): (0, 1), (8, 18, -4, 0): (0, 0), (8, 18, -4, 1): (0, 1), (8, 18, -4, 2): (0, 1), (8, 18, -4, 3): (0, 1), (8, 18, -4, 4): (0, 1), (8, 18, -4, 5): (0, 1), (8, 18, -3, -5): (0, 1), (8, 18, -3, -4): (0, 1), (8, 18, -3, -3): (0, 1), (8, 18, -3, -2): (0, 1), (8, 18, -3, -1): (0, 1), (8, 18, -3, 0): (0, 0), (8, 18, -3, 1): (0, 1), (8, 18, -3, 2): (0, 1), (8, 18, -3, 3): (0, 1), (8, 18, -3, 4): (0, 1), (8, 18, -3, 5): (0, 1), (8, 18, -2, -5): (-1, 1), (8, 18, -2, -4): (-1, 1), (8, 18, -2, -3): (-1, 1), (8, 18, -2, -2): (-1, 1), (8, 18, -2, -1): (-1, 1), (8, 18, -2, 0): (1, 1), (8, 18, -2, 1): (1, 1), (8, 18, -2, 2): (1, 1), (8, 18, -2, 3): (1, 1), (8, 18, -2, 4): (1, 1), (8, 18, -2, 5): (1, 0), (8, 18, -1, -5): (-1, 1), (8, 18, -1, -4): (-1, 1), (8, 18, -1, -3): (-1, 1), (8, 18, -1, -2): (1, 1), (8, 18, -1, -1): (1, 1), (8, 18, -1, 0): (1, 1), (8, 18, -1, 1): (1, 1), (8, 18, -1, 2): (1, 1), (8, 18, -1, 3): (0, 1), (8, 18, -1, 4): (0, 1), (8, 18, -1, 5): (0, 1), (8, 18, 0, -5): (1, 1), (8, 18, 0, -4): (1, 1), (8, 18, 0, -3): (1, 1), (8, 18, 0, -2): (1, 1), (8, 18, 0, -1): (1, 1), (8, 18, 0, 0): (1, 1), (8, 18, 0, 1): (0, 1), (8, 18, 0, 2): (0, 1), (8, 18, 0, 3): (-1, 1), (8, 18, 0, 4): (-1, 1), (8, 18, 0, 5): (-1, 1), (8, 18, 1, -5): (1, 1), (8, 18, 1, -4): (1, 1), (8, 18, 1, -3): (1, 1), (8, 18, 1, -2): (1, 1), (8, 18, 1, -1): (0, 1), (8, 18, 1, 0): (0, 1), (8, 18, 1, 1): (-1, 1), (8, 18, 1, 2): (-1, 1), (8, 18, 1, 3): (-1, 1), (8, 18, 1, 4): (-1, 0), (8, 18, 1, 5): (-1, -1), (8, 18, 2, -5): (0, 1), (8, 18, 2, -4): (0, 1), (8, 18, 2, -3): (0, 1), (8, 18, 2, -2): (0, 1), (8, 18, 2, -1): (0, 1), (8, 18, 2, 0): (-1, 1), (8, 18, 2, 1): (-1, 1), (8, 18, 2, 2): (-1, 1), (8, 18, 2, 3): (-1, 1), (8, 18, 2, 4): (-1, 1), (8, 18, 2, 5): (-1, 1), (8, 18, 3, -5): (0, 1), (8, 18, 3, -4): (0, 1), (8, 18, 3, -3): (0, 1), (8, 18, 3, -2): (0, 1), (8, 18, 3, -1): (0, 1), (8, 18, 3, 0): (0, 0), (8, 18, 3, 1): (0, 1), (8, 18, 3, 2): (0, 1), (8, 18, 3, 3): (0, 1), (8, 18, 3, 4): (0, 1), (8, 18, 3, 5): (0, 1), (8, 18, 4, -5): (0, 1), (8, 18, 4, -4): (0, 1), (8, 18, 4, -3): (0, 1), (8, 18, 4, -2): (0, 1), (8, 18, 4, -1): (0, 1), (8, 18, 4, 0): (0, 0), (8, 18, 4, 1): (0, 1), (8, 18, 4, 2): (0, 1), (8, 18, 4, 3): (0, 1), (8, 18, 4, 4): (0, 1), (8, 18, 4, 5): (0, 1), (8, 18, 5, -5): (0, 1), (8, 18, 5, -4): (0, 1), (8, 18, 5, -3): (0, 1), (8, 18, 5, -2): (0, 1), (8, 18, 5, -1): (0, 1), (8, 18, 5, 0): (0, 0), (8, 18, 5, 1): (0, 1), (8, 18, 5, 2): (0, 1), (8, 18, 5, 3): (0, 1), (8, 18, 5, 4): (0, 1), (8, 18, 5, 5): (0, 1), (8, 19, -5, -5): (0, 1), (8, 19, -5, -4): (0, 1), (8, 19, -5, -3): (0, 1), (8, 19, -5, -2): (0, 1), (8, 19, -5, -1): (0, 0), (8, 19, -5, 0): (0, 1), (8, 19, -5, 1): (0, 1), (8, 19, -5, 2): (0, 1), (8, 19, -5, 3): (0, 1), (8, 19, -5, 4): (0, 1), (8, 19, -5, 5): (0, 1), (8, 19, -4, -5): (0, 1), (8, 19, -4, -4): (0, 1), (8, 19, -4, -3): (0, 1), (8, 19, -4, -2): (0, 1), (8, 19, -4, -1): (0, 0), (8, 19, -4, 0): (0, 1), (8, 19, -4, 1): (0, 1), (8, 19, -4, 2): (0, 1), (8, 19, -4, 3): (0, 1), (8, 19, -4, 4): (0, 1), (8, 19, -4, 5): (0, 1), (8, 19, -3, -5): (0, 1), (8, 19, -3, -4): (0, 1), (8, 19, -3, -3): (0, 1), (8, 19, -3, -2): (0, 1), (8, 19, -3, -1): (0, 0), (8, 19, -3, 0): (0, 1), (8, 19, -3, 1): (0, 1), (8, 19, -3, 2): (0, 1), (8, 19, -3, 3): (0, 1), (8, 19, -3, 4): (1, 1), (8, 19, -3, 5): (1, 0), (8, 19, -2, -5): (-1, 1), (8, 19, -2, -4): (-1, 1), (8, 19, -2, -3): (-1, 1), (8, 19, -2, -2): (-1, 1), (8, 19, -2, -1): (-1, 0), (8, 19, -2, 0): (1, 1), (8, 19, -2, 1): (1, 1), (8, 19, -2, 2): (1, 1), (8, 19, -2, 3): (1, 1), (8, 19, -2, 4): (1, 1), (8, 19, -2, 5): (1, 0), (8, 19, -1, -5): (-1, 1), (8, 19, -1, -4): (-1, 1), (8, 19, -1, -3): (-1, 1), (8, 19, -1, -2): (1, 1), (8, 19, -1, -1): (1, 1), (8, 19, -1, 0): (1, 1), (8, 19, -1, 1): (1, 1), (8, 19, -1, 2): (1, 1), (8, 19, -1, 3): (0, 1), (8, 19, -1, 4): (0, 1), (8, 19, -1, 5): (0, 1), (8, 19, 0, -5): (1, 1), (8, 19, 0, -4): (1, 1), (8, 19, 0, -3): (1, 1), (8, 19, 0, -2): (1, 1), (8, 19, 0, -1): (1, 1), (8, 19, 0, 0): (0, 1), (8, 19, 0, 1): (0, 1), (8, 19, 0, 2): (0, 1), (8, 19, 0, 3): (-1, 1), (8, 19, 0, 4): (-1, 1), (8, 19, 0, 5): (-1, 1), (8, 19, 1, -5): (1, 1), (8, 19, 1, -4): (1, 1), (8, 19, 1, -3): (1, 1), (8, 19, 1, -2): (1, 1), (8, 19, 1, -1): (1, 0), (8, 19, 1, 0): (-1, 1), (8, 19, 1, 1): (-1, 1), (8, 19, 1, 2): (-1, 1), (8, 19, 1, 3): (-1, 1), (8, 19, 1, 4): (-1, 0), (8, 19, 1, 5): (-1, -1), (8, 19, 2, -5): (0, 1), (8, 19, 2, -4): (0, 1), (8, 19, 2, -3): (0, 1), (8, 19, 2, -2): (0, 1), (8, 19, 2, -1): (0, 0), (8, 19, 2, 0): (-1, 1), (8, 19, 2, 1): (-1, 1), (8, 19, 2, 2): (-1, 1), (8, 19, 2, 3): (-1, 1), (8, 19, 2, 4): (-1, 1), (8, 19, 2, 5): (-1, 1), (8, 19, 3, -5): (0, 1), (8, 19, 3, -4): (0, 1), (8, 19, 3, -3): (0, 1), (8, 19, 3, -2): (0, 1), (8, 19, 3, -1): (0, 0), (8, 19, 3, 0): (0, 1), (8, 19, 3, 1): (0, 1), (8, 19, 3, 2): (0, 1), (8, 19, 3, 3): (0, 1), (8, 19, 3, 4): (0, 1), (8, 19, 3, 5): (0, 1), (8, 19, 4, -5): (0, 1), (8, 19, 4, -4): (0, 1), (8, 19, 4, -3): (0, 1), (8, 19, 4, -2): (0, 1), (8, 19, 4, -1): (0, 0), (8, 19, 4, 0): (0, 1), (8, 19, 4, 1): (0, 1), (8, 19, 4, 2): (0, 1), (8, 19, 4, 3): (0, 1), (8, 19, 4, 4): (0, 1), (8, 19, 4, 5): (0, 1), (8, 19, 5, -5): (0, 1), (8, 19, 5, -4): (0, 1), (8, 19, 5, -3): (0, 1), (8, 19, 5, -2): (0, 1), (8, 19, 5, -1): (0, 0), (8, 19, 5, 0): (0, 1), (8, 19, 5, 1): (0, 1), (8, 19, 5, 2): (0, 1), (8, 19, 5, 3): (0, 1), (8, 19, 5, 4): (0, 1), (8, 19, 5, 5): (0, 1), (8, 20, -5, -5): (0, 1), (8, 20, -5, -4): (0, 1), (8, 20, -5, -3): (0, 1), (8, 20, -5, -2): (0, 0), (8, 20, -5, -1): (0, 1), (8, 20, -5, 0): (0, 1), (8, 20, -5, 1): (0, 1), (8, 20, -5, 2): (0, 1), (8, 20, -5, 3): (0, 1), (8, 20, -5, 4): (0, 1), (8, 20, -5, 5): (0, 1), (8, 20, -4, -5): (0, 1), (8, 20, -4, -4): (0, 1), (8, 20, -4, -3): (0, 1), (8, 20, -4, -2): (0, 0), (8, 20, -4, -1): (0, 1), (8, 20, -4, 0): (0, 1), (8, 20, -4, 1): (0, 1), (8, 20, -4, 2): (0, 1), (8, 20, -4, 3): (0, 1), (8, 20, -4, 4): (0, 1), (8, 20, -4, 5): (0, 1), (8, 20, -3, -5): (0, 1), (8, 20, -3, -4): (0, 1), (8, 20, -3, -3): (0, 1), (8, 20, -3, -2): (0, 0), (8, 20, -3, -1): (0, 1), (8, 20, -3, 0): (0, 1), (8, 20, -3, 1): (0, 1), (8, 20, -3, 2): (0, 1), (8, 20, -3, 3): (1, 1), (8, 20, -3, 4): (1, 1), (8, 20, -3, 5): (1, 0), (8, 20, -2, -5): (-1, 1), (8, 20, -2, -4): (-1, 1), (8, 20, -2, -3): (-1, 1), (8, 20, -2, -2): (-1, 0), (8, 20, -2, -1): (-1, 1), (8, 20, -2, 0): (1, 1), (8, 20, -2, 1): (1, 1), (8, 20, -2, 2): (1, 1), (8, 20, -2, 3): (1, 1), (8, 20, -2, 4): (1, 0), (8, 20, -2, 5): (1, -1), (8, 20, -1, -5): (-1, 1), (8, 20, -1, -4): (-1, 1), (8, 20, -1, -3): (-1, 1), (8, 20, -1, -2): (-1, 1), (8, 20, -1, -1): (1, 1), (8, 20, -1, 0): (1, 1), (8, 20, -1, 1): (1, 1), (8, 20, -1, 2): (0, 1), (8, 20, -1, 3): (0, 1), (8, 20, -1, 4): (0, 0), (8, 20, -1, 5): (0, -1), (8, 20, 0, -5): (1, 1), (8, 20, 0, -4): (1, 1), (8, 20, 0, -3): (1, 1), (8, 20, 0, -2): (1, 1), (8, 20, 0, -1): (1, 1), (8, 20, 0, 0): (1, 1), (8, 20, 0, 1): (0, 1), (8, 20, 0, 2): (-1, 1), (8, 20, 0, 3): (-1, 1), (8, 20, 0, 4): (-1, 0), (8, 20, 0, 5): (-1, -1), (8, 20, 1, -5): (1, 1), (8, 20, 1, -4): (1, 1), (8, 20, 1, -3): (1, 1), (8, 20, 1, -2): (1, 0), (8, 20, 1, -1): (0, 1), (8, 20, 1, 0): (0, 1), (8, 20, 1, 1): (-1, 1), (8, 20, 1, 2): (-1, 1), (8, 20, 1, 3): (-1, 0), (8, 20, 1, 4): (-1, -1), (8, 20, 1, 5): (-1, -1), (8, 20, 2, -5): (0, 1), (8, 20, 2, -4): (0, 1), (8, 20, 2, -3): (0, 1), (8, 20, 2, -2): (0, 0), (8, 20, 2, -1): (0, 1), (8, 20, 2, 0): (-1, 1), (8, 20, 2, 1): (-1, 1), (8, 20, 2, 2): (-1, 1), (8, 20, 2, 3): (-1, 1), (8, 20, 2, 4): (-1, 1), (8, 20, 2, 5): (-1, 1), (8, 20, 3, -5): (0, 1), (8, 20, 3, -4): (0, 1), (8, 20, 3, -3): (0, 1), (8, 20, 3, -2): (0, 0), (8, 20, 3, -1): (0, 1), (8, 20, 3, 0): (0, 1), (8, 20, 3, 1): (0, 1), (8, 20, 3, 2): (0, 1), (8, 20, 3, 3): (0, 1), (8, 20, 3, 4): (0, 1), (8, 20, 3, 5): (0, 1), (8, 20, 4, -5): (0, 1), (8, 20, 4, -4): (0, 1), (8, 20, 4, -3): (0, 1), (8, 20, 4, -2): (0, 0), (8, 20, 4, -1): (0, 1), (8, 20, 4, 0): (0, 1), (8, 20, 4, 1): (0, 1), (8, 20, 4, 2): (0, 1), (8, 20, 4, 3): (0, 1), (8, 20, 4, 4): (0, 1), (8, 20, 4, 5): (0, 1), (8, 20, 5, -5): (0, 1), (8, 20, 5, -4): (0, 1), (8, 20, 5, -3): (0, 1), (8, 20, 5, -2): (0, 0), (8, 20, 5, -1): (0, 1), (8, 20, 5, 0): (0, 1), (8, 20, 5, 1): (0, 1), (8, 20, 5, 2): (0, 1), (8, 20, 5, 3): (0, 1), (8, 20, 5, 4): (0, 1), (8, 20, 5, 5): (0, 1), (8, 21, -5, -5): (0, 1), (8, 21, -5, -4): (0, 1), (8, 21, -5, -3): (0, 0), (8, 21, -5, -2): (0, 1), (8, 21, -5, -1): (0, 1), (8, 21, -5, 0): (0, 1), (8, 21, -5, 1): (0, 1), (8, 21, -5, 2): (0, 1), (8, 21, -5, 3): (0, 1), (8, 21, -5, 4): (0, 1), (8, 21, -5, 5): (0, 1), (8, 21, -4, -5): (0, 1), (8, 21, -4, -4): (0, 1), (8, 21, -4, -3): (0, 0), (8, 21, -4, -2): (0, 1), (8, 21, -4, -1): (0, 1), (8, 21, -4, 0): (0, 1), (8, 21, -4, 1): (0, 1), (8, 21, -4, 2): (0, 1), (8, 21, -4, 3): (0, 1), (8, 21, -4, 4): (0, 1), (8, 21, -4, 5): (0, 1), (8, 21, -3, -5): (0, 1), (8, 21, -3, -4): (0, 1), (8, 21, -3, -3): (0, 0), (8, 21, -3, -2): (0, 1), (8, 21, -3, -1): (0, 1), (8, 21, -3, 0): (0, 1), (8, 21, -3, 1): (0, 1), (8, 21, -3, 2): (0, 1), (8, 21, -3, 3): (1, 1), (8, 21, -3, 4): (1, 1), (8, 21, -3, 5): (1, 0), (8, 21, -2, -5): (-1, 1), (8, 21, -2, -4): (-1, 1), (8, 21, -2, -3): (-1, 0), (8, 21, -2, -2): (-1, 1), (8, 21, -2, -1): (1, 1), (8, 21, -2, 0): (1, 1), (8, 21, -2, 1): (1, 1), (8, 21, -2, 2): (1, 1), (8, 21, -2, 3): (1, 1), (8, 21, -2, 4): (0, 1), (8, 21, -2, 5): (0, 1), (8, 21, -1, -5): (-1, 1), (8, 21, -1, -4): (-1, 1), (8, 21, -1, -3): (-1, 1), (8, 21, -1, -2): (-1, 1), (8, 21, -1, -1): (1, 1), (8, 21, -1, 0): (1, 1), (8, 21, -1, 1): (1, 1), (8, 21, -1, 2): (0, 1), (8, 21, -1, 3): (0, 1), (8, 21, -1, 4): (-1, 1), (8, 21, -1, 5): (-1, 1), (8, 21, 0, -5): (1, 1), (8, 21, 0, -4): (1, 1), (8, 21, 0, -3): (1, 1), (8, 21, 0, -2): (1, 1), (8, 21, 0, -1): (1, 1), (8, 21, 0, 0): (0, 1), (8, 21, 0, 1): (0, 1), (8, 21, 0, 2): (-1, 1), (8, 21, 0, 3): (-1, 1), (8, 21, 0, 4): (-1, 0), (8, 21, 0, 5): (-1, -1), (8, 21, 1, -5): (1, 1), (8, 21, 1, -4): (1, 1), (8, 21, 1, -3): (1, 0), (8, 21, 1, -2): (1, 1), (8, 21, 1, -1): (0, 1), (8, 21, 1, 0): (-1, 1), (8, 21, 1, 1): (-1, 1), (8, 21, 1, 2): (-1, 1), (8, 21, 1, 3): (-1, 1), (8, 21, 1, 4): (-1, 0), (8, 21, 1, 5): (-1, -1), (8, 21, 2, -5): (0, 1), (8, 21, 2, -4): (0, 1), (8, 21, 2, -3): (0, 0), (8, 21, 2, -2): (0, 1), (8, 21, 2, -1): (0, 1), (8, 21, 2, 0): (-1, 1), (8, 21, 2, 1): (-1, 1), (8, 21, 2, 2): (-1, 1), (8, 21, 2, 3): (-1, 1), (8, 21, 2, 4): (0, 1), (8, 21, 2, 5): (0, 1), (8, 21, 3, -5): (0, 1), (8, 21, 3, -4): (0, 1), (8, 21, 3, -3): (0, 0), (8, 21, 3, -2): (0, 1), (8, 21, 3, -1): (0, 1), (8, 21, 3, 0): (0, 1), (8, 21, 3, 1): (0, 1), (8, 21, 3, 2): (0, 1), (8, 21, 3, 3): (0, 1), (8, 21, 3, 4): (0, 1), (8, 21, 3, 5): (0, 1), (8, 21, 4, -5): (0, 1), (8, 21, 4, -4): (0, 1), (8, 21, 4, -3): (0, 0), (8, 21, 4, -2): (0, 1), (8, 21, 4, -1): (0, 1), (8, 21, 4, 0): (0, 1), (8, 21, 4, 1): (0, 1), (8, 21, 4, 2): (0, 1), (8, 21, 4, 3): (0, 1), (8, 21, 4, 4): (0, 1), (8, 21, 4, 5): (0, 1), (8, 21, 5, -5): (0, 1), (8, 21, 5, -4): (0, 1), (8, 21, 5, -3): (0, 0), (8, 21, 5, -2): (0, 1), (8, 21, 5, -1): (0, 1), (8, 21, 5, 0): (0, 1), (8, 21, 5, 1): (0, 1), (8, 21, 5, 2): (0, 1), (8, 21, 5, 3): (0, 1), (8, 21, 5, 4): (0, 1), (8, 21, 5, 5): (0, 1), (8, 22, -5, -5): (0, 1), (8, 22, -5, -4): (0, 0), (8, 22, -5, -3): (0, 1), (8, 22, -5, -2): (0, 1), (8, 22, -5, -1): (0, 1), (8, 22, -5, 0): (0, 1), (8, 22, -5, 1): (0, 1), (8, 22, -5, 2): (0, 1), (8, 22, -5, 3): (0, 1), (8, 22, -5, 4): (0, 1), (8, 22, -5, 5): (0, 1), (8, 22, -4, -5): (0, 1), (8, 22, -4, -4): (0, 0), (8, 22, -4, -3): (0, 1), (8, 22, -4, -2): (0, 1), (8, 22, -4, -1): (0, 1), (8, 22, -4, 0): (0, 1), (8, 22, -4, 1): (0, 1), (8, 22, -4, 2): (0, 1), (8, 22, -4, 3): (0, 1), (8, 22, -4, 4): (0, 1), (8, 22, -4, 5): (0, 1), (8, 22, -3, -5): (0, 1), (8, 22, -3, -4): (0, 0), (8, 22, -3, -3): (0, 1), (8, 22, -3, -2): (0, 1), (8, 22, -3, -1): (0, 1), (8, 22, -3, 0): (0, 1), (8, 22, -3, 1): (0, 1), (8, 22, -3, 2): (1, 1), (8, 22, -3, 3): (1, 1), (8, 22, -3, 4): (1, 1), (8, 22, -3, 5): (1, 0), (8, 22, -2, -5): (-1, 1), (8, 22, -2, -4): (-1, 0), (8, 22, -2, -3): (-1, 1), (8, 22, -2, -2): (-1, 1), (8, 22, -2, -1): (-1, 1), (8, 22, -2, 0): (1, 1), (8, 22, -2, 1): (1, 1), (8, 22, -2, 2): (1, 1), (8, 22, -2, 3): (1, 1), (8, 22, -2, 4): (0, 1), (8, 22, -2, 5): (0, 1), (8, 22, -1, -5): (-1, 1), (8, 22, -1, -4): (-1, 1), (8, 22, -1, -3): (-1, 1), (8, 22, -1, -2): (1, 1), (8, 22, -1, -1): (1, 1), (8, 22, -1, 0): (1, 1), (8, 22, -1, 1): (1, 1), (8, 22, -1, 2): (0, 1), (8, 22, -1, 3): (0, 1), (8, 22, -1, 4): (-1, 1), (8, 22, -1, 5): (-1, 1), (8, 22, 0, -5): (1, 1), (8, 22, 0, -4): (1, 1), (8, 22, 0, -3): (1, 1), (8, 22, 0, -2): (1, 1), (8, 22, 0, -1): (1, 1), (8, 22, 0, 0): (0, 1), (8, 22, 0, 1): (0, 1), (8, 22, 0, 2): (-1, 1), (8, 22, 0, 3): (-1, 1), (8, 22, 0, 4): (-1, 0), (8, 22, 0, 5): (-1, -1), (8, 22, 1, -5): (1, 1), (8, 22, 1, -4): (1, 0), (8, 22, 1, -3): (1, 1), (8, 22, 1, -2): (1, 1), (8, 22, 1, -1): (0, 1), (8, 22, 1, 0): (-1, 1), (8, 22, 1, 1): (-1, 1), (8, 22, 1, 2): (-1, 1), (8, 22, 1, 3): (-1, 0), (8, 22, 1, 4): (1, 1), (8, 22, 1, 5): (1, 0), (8, 22, 2, -5): (0, 1), (8, 22, 2, -4): (0, 0), (8, 22, 2, -3): (0, 1), (8, 22, 2, -2): (0, 1), (8, 22, 2, -1): (0, 1), (8, 22, 2, 0): (-1, 1), (8, 22, 2, 1): (-1, 1), (8, 22, 2, 2): (-1, 1), (8, 22, 2, 3): (0, 1), (8, 22, 2, 4): (0, 1), (8, 22, 2, 5): (0, 1), (8, 22, 3, -5): (0, 1), (8, 22, 3, -4): (0, 0), (8, 22, 3, -3): (0, 1), (8, 22, 3, -2): (0, 1), (8, 22, 3, -1): (0, 1), (8, 22, 3, 0): (0, 1), (8, 22, 3, 1): (0, 1), (8, 22, 3, 2): (0, 1), (8, 22, 3, 3): (0, 1), (8, 22, 3, 4): (0, 1), (8, 22, 3, 5): (0, 1), (8, 22, 4, -5): (0, 1), (8, 22, 4, -4): (0, 0), (8, 22, 4, -3): (0, 1), (8, 22, 4, -2): (0, 1), (8, 22, 4, -1): (0, 1), (8, 22, 4, 0): (0, 1), (8, 22, 4, 1): (0, 1), (8, 22, 4, 2): (0, 1), (8, 22, 4, 3): (0, 1), (8, 22, 4, 4): (0, 1), (8, 22, 4, 5): (0, 1), (8, 22, 5, -5): (0, 1), (8, 22, 5, -4): (0, 0), (8, 22, 5, -3): (0, 1), (8, 22, 5, -2): (0, 1), (8, 22, 5, -1): (0, 1), (8, 22, 5, 0): (0, 1), (8, 22, 5, 1): (0, 1), (8, 22, 5, 2): (0, 1), (8, 22, 5, 3): (0, 1), (8, 22, 5, 4): (0, 1), (8, 22, 5, 5): (0, 1), (8, 23, -5, -5): (0, 0), (8, 23, -5, -4): (0, 1), (8, 23, -5, -3): (0, 1), (8, 23, -5, -2): (0, 1), (8, 23, -5, -1): (0, 1), (8, 23, -5, 0): (0, 1), (8, 23, -5, 1): (0, 1), (8, 23, -5, 2): (0, 1), (8, 23, -5, 3): (0, 1), (8, 23, -5, 4): (0, 1), (8, 23, -5, 5): (0, 1), (8, 23, -4, -5): (0, 0), (8, 23, -4, -4): (0, 1), (8, 23, -4, -3): (0, 1), (8, 23, -4, -2): (0, 1), (8, 23, -4, -1): (0, 1), (8, 23, -4, 0): (0, 1), (8, 23, -4, 1): (0, 1), (8, 23, -4, 2): (0, 1), (8, 23, -4, 3): (0, 1), (8, 23, -4, 4): (0, 1), (8, 23, -4, 5): (0, 1), (8, 23, -3, -5): (0, 0), (8, 23, -3, -4): (0, 1), (8, 23, -3, -3): (0, 1), (8, 23, -3, -2): (0, 1), (8, 23, -3, -1): (0, 1), (8, 23, -3, 0): (0, 1), (8, 23, -3, 1): (0, 1), (8, 23, -3, 2): (1, 1), (8, 23, -3, 3): (1, 1), (8, 23, -3, 4): (1, 1), (8, 23, -3, 5): (1, 0), (8, 23, -2, -5): (-1, 0), (8, 23, -2, -4): (-1, 1), (8, 23, -2, -3): (-1, 1), (8, 23, -2, -2): (-1, 1), (8, 23, -2, -1): (-1, 1), (8, 23, -2, 0): (1, 1), (8, 23, -2, 1): (1, 1), (8, 23, -2, 2): (1, 1), (8, 23, -2, 3): (0, 1), (8, 23, -2, 4): (0, 1), (8, 23, -2, 5): (0, 1), (8, 23, -1, -5): (-1, 1), (8, 23, -1, -4): (-1, 1), (8, 23, -1, -3): (-1, 1), (8, 23, -1, -2): (1, 1), (8, 23, -1, -1): (1, 1), (8, 23, -1, 0): (1, 1), (8, 23, -1, 1): (0, 1), (8, 23, -1, 2): (0, 1), (8, 23, -1, 3): (-1, 1), (8, 23, -1, 4): (-1, 1), (8, 23, -1, 5): (-1, 1), (8, 23, 0, -5): (1, 1), (8, 23, 0, -4): (1, 1), (8, 23, 0, -3): (1, 1), (8, 23, 0, -2): (1, 1), (8, 23, 0, -1): (1, 1), (8, 23, 0, 0): (0, 1), (8, 23, 0, 1): (-1, 1), (8, 23, 0, 2): (-1, 1), (8, 23, 0, 3): (-1, 0), (8, 23, 0, 4): (-1, -1), (8, 23, 0, 5): (-1, -1), (8, 23, 1, -5): (1, 0), (8, 23, 1, -4): (1, 1), (8, 23, 1, -3): (1, 1), (8, 23, 1, -2): (1, 1), (8, 23, 1, -1): (0, 1), (8, 23, 1, 0): (-1, 1), (8, 23, 1, 1): (-1, 1), (8, 23, 1, 2): (-1, 1), (8, 23, 1, 3): (-1, 0), (8, 23, 1, 4): (-1, -1), (8, 23, 1, 5): (1, 0), (8, 23, 2, -5): (0, 0), (8, 23, 2, -4): (0, 1), (8, 23, 2, -3): (0, 1), (8, 23, 2, -2): (0, 1), (8, 23, 2, -1): (0, 1), (8, 23, 2, 0): (-1, 1), (8, 23, 2, 1): (-1, 1), (8, 23, 2, 2): (0, 1), (8, 23, 2, 3): (0, 1), (8, 23, 2, 4): (0, 1), (8, 23, 2, 5): (0, 1), (8, 23, 3, -5): (0, 0), (8, 23, 3, -4): (0, 1), (8, 23, 3, -3): (0, 1), (8, 23, 3, -2): (0, 1), (8, 23, 3, -1): (0, 1), (8, 23, 3, 0): (0, 1), (8, 23, 3, 1): (0, 1), (8, 23, 3, 2): (0, 1), (8, 23, 3, 3): (0, 1), (8, 23, 3, 4): (0, 1), (8, 23, 3, 5): (0, 1), (8, 23, 4, -5): (0, 0), (8, 23, 4, -4): (0, 1), (8, 23, 4, -3): (0, 1), (8, 23, 4, -2): (0, 1), (8, 23, 4, -1): (0, 1), (8, 23, 4, 0): (0, 1), (8, 23, 4, 1): (0, 1), (8, 23, 4, 2): (0, 1), (8, 23, 4, 3): (0, 1), (8, 23, 4, 4): (0, 1), (8, 23, 4, 5): (0, 1), (8, 23, 5, -5): (0, 0), (8, 23, 5, -4): (0, 1), (8, 23, 5, -3): (0, 1), (8, 23, 5, -2): (0, 1), (8, 23, 5, -1): (0, 1), (8, 23, 5, 0): (0, 1), (8, 23, 5, 1): (0, 1), (8, 23, 5, 2): (0, 1), (8, 23, 5, 3): (0, 1), (8, 23, 5, 4): (0, 1), (8, 23, 5, 5): (0, 1), (8, 24, -5, -5): (0, 1), (8, 24, -5, -4): (0, 1), (8, 24, -5, -3): (0, 1), (8, 24, -5, -2): (0, 1), (8, 24, -5, -1): (0, 1), (8, 24, -5, 0): (0, 1), (8, 24, -5, 1): (0, 1), (8, 24, -5, 2): (0, 1), (8, 24, -5, 3): (0, 1), (8, 24, -5, 4): (0, 1), (8, 24, -5, 5): (0, 1), (8, 24, -4, -5): (0, 1), (8, 24, -4, -4): (0, 1), (8, 24, -4, -3): (0, 1), (8, 24, -4, -2): (0, 1), (8, 24, -4, -1): (0, 1), (8, 24, -4, 0): (0, 1), (8, 24, -4, 1): (0, 1), (8, 24, -4, 2): (0, 1), (8, 24, -4, 3): (0, 1), (8, 24, -4, 4): (0, 1), (8, 24, -4, 5): (0, 1), (8, 24, -3, -5): (0, 1), (8, 24, -3, -4): (0, 1), (8, 24, -3, -3): (0, 1), (8, 24, -3, -2): (0, 1), (8, 24, -3, -1): (0, 1), (8, 24, -3, 0): (0, 1), (8, 24, -3, 1): (1, 1), (8, 24, -3, 2): (1, 1), (8, 24, -3, 3): (1, 1), (8, 24, -3, 4): (1, 0), (8, 24, -3, 5): (1, -1), (8, 24, -2, -5): (-1, 1), (8, 24, -2, -4): (-1, 1), (8, 24, -2, -3): (-1, 1), (8, 24, -2, -2): (-1, 1), (8, 24, -2, -1): (1, 1), (8, 24, -2, 0): (1, 1), (8, 24, -2, 1): (1, 1), (8, 24, -2, 2): (1, 1), (8, 24, -2, 3): (0, 1), (8, 24, -2, 4): (0, 0), (8, 24, -2, 5): (0, -1), (8, 24, -1, -5): (-1, 1), (8, 24, -1, -4): (-1, 1), (8, 24, -1, -3): (-1, 1), (8, 24, -1, -2): (1, 1), (8, 24, -1, -1): (1, 1), (8, 24, -1, 0): (1, 1), (8, 24, -1, 1): (0, 1), (8, 24, -1, 2): (0, 1), (8, 24, -1, 3): (-1, 1), (8, 24, -1, 4): (-1, 0), (8, 24, -1, 5): (-1, -1), (8, 24, 0, -5): (1, 1), (8, 24, 0, -4): (1, 1), (8, 24, 0, -3): (1, 1), (8, 24, 0, -2): (1, 1), (8, 24, 0, -1): (1, 1), (8, 24, 0, 0): (0, 1), (8, 24, 0, 1): (-1, 1), (8, 24, 0, 2): (-1, 1), (8, 24, 0, 3): (-1, 0), (8, 24, 0, 4): (-1, -1), (8, 24, 0, 5): (-1, -1), (8, 24, 1, -5): (1, 1), (8, 24, 1, -4): (1, 1), (8, 24, 1, -3): (1, 1), (8, 24, 1, -2): (1, 1), (8, 24, 1, -1): (0, 1), (8, 24, 1, 0): (-1, 1), (8, 24, 1, 1): (-1, 1), (8, 24, 1, 2): (-1, 1), (8, 24, 1, 3): (-1, 0), (8, 24, 1, 4): (-1, -1), (8, 24, 1, 5): (1, 0), (8, 24, 2, -5): (0, 1), (8, 24, 2, -4): (0, 1), (8, 24, 2, -3): (0, 1), (8, 24, 2, -2): (0, 1), (8, 24, 2, -1): (0, 1), (8, 24, 2, 0): (-1, 1), (8, 24, 2, 1): (0, 1), (8, 24, 2, 2): (0, 1), (8, 24, 2, 3): (0, 1), (8, 24, 2, 4): (0, 1), (8, 24, 2, 5): (0, 1), (8, 24, 3, -5): (0, 1), (8, 24, 3, -4): (0, 1), (8, 24, 3, -3): (0, 1), (8, 24, 3, -2): (0, 1), (8, 24, 3, -1): (0, 1), (8, 24, 3, 0): (0, 1), (8, 24, 3, 1): (0, 1), (8, 24, 3, 2): (0, 1), (8, 24, 3, 3): (0, 1), (8, 24, 3, 4): (0, 1), (8, 24, 3, 5): (0, 1), (8, 24, 4, -5): (0, 1), (8, 24, 4, -4): (0, 1), (8, 24, 4, -3): (0, 1), (8, 24, 4, -2): (0, 1), (8, 24, 4, -1): (0, 1), (8, 24, 4, 0): (0, 1), (8, 24, 4, 1): (0, 1), (8, 24, 4, 2): (0, 1), (8, 24, 4, 3): (0, 1), (8, 24, 4, 4): (0, 1), (8, 24, 4, 5): (0, 1), (8, 24, 5, -5): (0, 1), (8, 24, 5, -4): (0, 1), (8, 24, 5, -3): (0, 1), (8, 24, 5, -2): (0, 1), (8, 24, 5, -1): (0, 1), (8, 24, 5, 0): (0, 1), (8, 24, 5, 1): (0, 1), (8, 24, 5, 2): (0, 1), (8, 24, 5, 3): (0, 1), (8, 24, 5, 4): (0, 1), (8, 24, 5, 5): (0, 1), (8, 25, -5, -5): (0, 1), (8, 25, -5, -4): (0, 1), (8, 25, -5, -3): (0, 1), (8, 25, -5, -2): (0, 1), (8, 25, -5, -1): (0, 1), (8, 25, -5, 0): (0, 1), (8, 25, -5, 1): (0, 1), (8, 25, -5, 2): (0, 1), (8, 25, -5, 3): (0, 1), (8, 25, -5, 4): (0, 1), (8, 25, -5, 5): (0, 1), (8, 25, -4, -5): (0, 1), (8, 25, -4, -4): (0, 1), (8, 25, -4, -3): (0, 1), (8, 25, -4, -2): (0, 1), (8, 25, -4, -1): (0, 1), (8, 25, -4, 0): (0, 1), (8, 25, -4, 1): (0, 1), (8, 25, -4, 2): (0, 1), (8, 25, -4, 3): (0, 1), (8, 25, -4, 4): (-1, 1), (8, 25, -4, 5): (-1, 1), (8, 25, -3, -5): (0, 1), (8, 25, -3, -4): (0, 1), (8, 25, -3, -3): (0, 1), (8, 25, -3, -2): (0, 1), (8, 25, -3, -1): (0, 1), (8, 25, -3, 0): (0, 1), (8, 25, -3, 1): (1, 1), (8, 25, -3, 2): (1, 1), (8, 25, -3, 3): (1, 1), (8, 25, -3, 4): (1, 0), (8, 25, -3, 5): (1, -1), (8, 25, -2, -5): (-1, 1), (8, 25, -2, -4): (-1, 1), (8, 25, -2, -3): (-1, 1), (8, 25, -2, -2): (-1, 1), (8, 25, -2, -1): (1, 1), (8, 25, -2, 0): (1, 1), (8, 25, -2, 1): (1, 1), (8, 25, -2, 2): (0, 1), (8, 25, -2, 3): (0, 1), (8, 25, -2, 4): (0, 0), (8, 25, -2, 5): (0, -1), (8, 25, -1, -5): (-1, 1), (8, 25, -1, -4): (-1, 1), (8, 25, -1, -3): (-1, 1), (8, 25, -1, -2): (1, 1), (8, 25, -1, -1): (1, 1), (8, 25, -1, 0): (1, 1), (8, 25, -1, 1): (0, 1), (8, 25, -1, 2): (-1, 1), (8, 25, -1, 3): (-1, 1), (8, 25, -1, 4): (-1, 0), (8, 25, -1, 5): (-1, -1), (8, 25, 0, -5): (1, 1), (8, 25, 0, -4): (1, 1), (8, 25, 0, -3): (1, 1), (8, 25, 0, -2): (1, 1), (8, 25, 0, -1): (1, 1), (8, 25, 0, 0): (0, 1), (8, 25, 0, 1): (-1, 1), (8, 25, 0, 2): (-1, 1), (8, 25, 0, 3): (-1, 0), (8, 25, 0, 4): (-1, -1), (8, 25, 0, 5): (-1, -1), (8, 25, 1, -5): (1, 1), (8, 25, 1, -4): (1, 1), (8, 25, 1, -3): (1, 1), (8, 25, 1, -2): (1, 1), (8, 25, 1, -1): (1, 1), (8, 25, 1, 0): (-1, 1), (8, 25, 1, 1): (-1, 1), (8, 25, 1, 2): (-1, 1), (8, 25, 1, 3): (-1, 0), (8, 25, 1, 4): (-1, -1), (8, 25, 1, 5): (1, -1), (8, 25, 2, -5): (0, 1), (8, 25, 2, -4): (0, 1), (8, 25, 2, -3): (0, 1), (8, 25, 2, -2): (0, 1), (8, 25, 2, -1): (0, 1), (8, 25, 2, 0): (0, 1), (8, 25, 2, 1): (0, 1), (8, 25, 2, 2): (0, 1), (8, 25, 2, 3): (0, 1), (8, 25, 2, 4): (0, 0), (8, 25, 2, 5): (0, -1), (8, 25, 3, -5): (0, 1), (8, 25, 3, -4): (0, 1), (8, 25, 3, -3): (0, 1), (8, 25, 3, -2): (0, 1), (8, 25, 3, -1): (0, 1), (8, 25, 3, 0): (0, 1), (8, 25, 3, 1): (0, 1), (8, 25, 3, 2): (0, 1), (8, 25, 3, 3): (0, 1), (8, 25, 3, 4): (0, 0), (8, 25, 3, 5): (-1, -1), (8, 25, 4, -5): (0, 1), (8, 25, 4, -4): (0, 1), (8, 25, 4, -3): (0, 1), (8, 25, 4, -2): (0, 1), (8, 25, 4, -1): (0, 1), (8, 25, 4, 0): (0, 1), (8, 25, 4, 1): (0, 1), (8, 25, 4, 2): (0, 1), (8, 25, 4, 3): (0, 1), (8, 25, 4, 4): (0, 0), (8, 25, 4, 5): (-1, -1), (8, 25, 5, -5): (0, 1), (8, 25, 5, -4): (0, 1), (8, 25, 5, -3): (0, 1), (8, 25, 5, -2): (0, 1), (8, 25, 5, -1): (0, 1), (8, 25, 5, 0): (0, 1), (8, 25, 5, 1): (0, 1), (8, 25, 5, 2): (0, 1), (8, 25, 5, 3): (0, 1), (8, 25, 5, 4): (0, 0), (8, 25, 5, 5): (-1, -1), (8, 26, -5, -5): (0, 1), (8, 26, -5, -4): (0, 1), (8, 26, -5, -3): (0, 1), (8, 26, -5, -2): (0, 1), (8, 26, -5, -1): (0, 1), (8, 26, -5, 0): (0, 1), (8, 26, -5, 1): (0, 1), (8, 26, -5, 2): (0, 1), (8, 26, -5, 3): (0, 1), (8, 26, -5, 4): (0, 1), (8, 26, -5, 5): (0, 1), (8, 26, -4, -5): (0, 1), (8, 26, -4, -4): (0, 1), (8, 26, -4, -3): (0, 1), (8, 26, -4, -2): (0, 1), (8, 26, -4, -1): (0, 1), (8, 26, -4, 0): (0, 1), (8, 26, -4, 1): (0, 1), (8, 26, -4, 2): (0, 1), (8, 26, -4, 3): (-1, 1), (8, 26, -4, 4): (-1, 1), (8, 26, -4, 5): (-1, 1), (8, 26, -3, -5): (0, 1), (8, 26, -3, -4): (0, 1), (8, 26, -3, -3): (0, 1), (8, 26, -3, -2): (0, 1), (8, 26, -3, -1): (0, 1), (8, 26, -3, 0): (1, 1), (8, 26, -3, 1): (1, 1), (8, 26, -3, 2): (1, 1), (8, 26, -3, 3): (1, 0), (8, 26, -3, 4): (1, -1), (8, 26, -3, 5): (1, -1), (8, 26, -2, -5): (-1, 1), (8, 26, -2, -4): (-1, 1), (8, 26, -2, -3): (-1, 1), (8, 26, -2, -2): (-1, 1), (8, 26, -2, -1): (1, 1), (8, 26, -2, 0): (1, 1), (8, 26, -2, 1): (1, 1), (8, 26, -2, 2): (0, 1), (8, 26, -2, 3): (0, 0), (8, 26, -2, 4): (0, -1), (8, 26, -2, 5): (0, -1), (8, 26, -1, -5): (-1, 1), (8, 26, -1, -4): (-1, 1), (8, 26, -1, -3): (-1, 1), (8, 26, -1, -2): (1, 1), (8, 26, -1, -1): (0, 1), (8, 26, -1, 0): (0, 1), (8, 26, -1, 1): (0, 1), (8, 26, -1, 2): (-1, 1), (8, 26, -1, 3): (-1, 0), (8, 26, -1, 4): (-1, -1), (8, 26, -1, 5): (-1, -1), (8, 26, 0, -5): (1, 1), (8, 26, 0, -4): (1, 1), (8, 26, 0, -3): (1, 1), (8, 26, 0, -2): (1, 1), (8, 26, 0, -1): (-1, 1), (8, 26, 0, 0): (-1, 1), (8, 26, 0, 1): (-1, 1), (8, 26, 0, 2): (-1, 0), (8, 26, 0, 3): (-1, -1), (8, 26, 0, 4): (-1, -1), (8, 26, 0, 5): (-1, 1), (8, 26, 1, -5): (1, 1), (8, 26, 1, -4): (1, 1), (8, 26, 1, -3): (1, 1), (8, 26, 1, -2): (1, 1), (8, 26, 1, -1): (1, 1), (8, 26, 1, 0): (-1, 1), (8, 26, 1, 1): (-1, 1), (8, 26, 1, 2): (-1, 0), (8, 26, 1, 3): (-1, -1), (8, 26, 1, 4): (-1, -1), (8, 26, 1, 5): (1, -1), (8, 26, 2, -5): (0, 1), (8, 26, 2, -4): (0, 1), (8, 26, 2, -3): (0, 1), (8, 26, 2, -2): (0, 1), (8, 26, 2, -1): (0, 1), (8, 26, 2, 0): (0, 1), (8, 26, 2, 1): (0, 1), (8, 26, 2, 2): (0, 1), (8, 26, 2, 3): (0, 0), (8, 26, 2, 4): (0, -1), (8, 26, 2, 5): (0, -1), (8, 26, 3, -5): (0, 1), (8, 26, 3, -4): (0, 1), (8, 26, 3, -3): (0, 1), (8, 26, 3, -2): (0, 1), (8, 26, 3, -1): (0, 1), (8, 26, 3, 0): (0, 1), (8, 26, 3, 1): (0, 1), (8, 26, 3, 2): (0, 1), (8, 26, 3, 3): (0, 0), (8, 26, 3, 4): (-1, -1), (8, 26, 3, 5): (-1, -1), (8, 26, 4, -5): (0, 1), (8, 26, 4, -4): (0, 1), (8, 26, 4, -3): (0, 1), (8, 26, 4, -2): (0, 1), (8, 26, 4, -1): (0, 1), (8, 26, 4, 0): (0, 1), (8, 26, 4, 1): (0, 1), (8, 26, 4, 2): (0, 1), (8, 26, 4, 3): (0, 0), (8, 26, 4, 4): (-1, -1), (8, 26, 4, 5): (-1, -1), (8, 26, 5, -5): (0, 1), (8, 26, 5, -4): (0, 1), (8, 26, 5, -3): (0, 1), (8, 26, 5, -2): (0, 1), (8, 26, 5, -1): (0, 1), (8, 26, 5, 0): (0, 1), (8, 26, 5, 1): (0, 1), (8, 26, 5, 2): (0, 1), (8, 26, 5, 3): (0, 0), (8, 26, 5, 4): (-1, -1), (8, 26, 5, 5): (-1, -1), (8, 27, -5, -5): (0, 1), (8, 27, -5, -4): (0, 1), (8, 27, -5, -3): (0, 1), (8, 27, -5, -2): (0, 1), (8, 27, -5, -1): (0, 1), (8, 27, -5, 0): (0, 1), (8, 27, -5, 1): (0, 1), (8, 27, -5, 2): (0, 1), (8, 27, -5, 3): (0, 1), (8, 27, -5, 4): (0, 1), (8, 27, -5, 5): (0, 1), (8, 27, -4, -5): (0, 1), (8, 27, -4, -4): (0, 1), (8, 27, -4, -3): (0, 1), (8, 27, -4, -2): (0, 1), (8, 27, -4, -1): (0, 1), (8, 27, -4, 0): (0, 1), (8, 27, -4, 1): (0, 1), (8, 27, -4, 2): (-1, 1), (8, 27, -4, 3): (-1, 1), (8, 27, -4, 4): (0, 1), (8, 27, -4, 5): (0, 1), (8, 27, -3, -5): (0, 1), (8, 27, -3, -4): (0, 1), (8, 27, -3, -3): (0, 1), (8, 27, -3, -2): (0, 1), (8, 27, -3, -1): (0, 1), (8, 27, -3, 0): (1, 1), (8, 27, -3, 1): (1, 1), (8, 27, -3, 2): (1, 1), (8, 27, -3, 3): (1, 0), (8, 27, -3, 4): (1, -1), (8, 27, -3, 5): (0, 1), (8, 27, -2, -5): (-1, 1), (8, 27, -2, -4): (-1, 1), (8, 27, -2, -3): (-1, 1), (8, 27, -2, -2): (-1, 1), (8, 27, -2, -1): (1, 1), (8, 27, -2, 0): (1, 1), (8, 27, -2, 1): (0, 1), (8, 27, -2, 2): (0, 1), (8, 27, -2, 3): (0, 0), (8, 27, -2, 4): (0, -1), (8, 27, -2, 5): (-1, 1), (8, 27, -1, -5): (-1, 1), (8, 27, -1, -4): (-1, 1), (8, 27, -1, -3): (-1, 1), (8, 27, -1, -2): (0, 1), (8, 27, -1, -1): (1, 1), (8, 27, -1, 0): (0, 1), (8, 27, -1, 1): (-1, 1), (8, 27, -1, 2): (-1, 1), (8, 27, -1, 3): (-1, 0), (8, 27, -1, 4): (-1, -1), (8, 27, -1, 5): (-1, -1), (8, 27, 0, -5): (1, 1), (8, 27, 0, -4): (1, 1), (8, 27, 0, -3): (1, 1), (8, 27, 0, -2): (1, 1), (8, 27, 0, -1): (0, 1), (8, 27, 0, 0): (-1, 1), (8, 27, 0, 1): (-1, 1), (8, 27, 0, 2): (-1, 0), (8, 27, 0, 3): (-1, -1), (8, 27, 0, 4): (-1, -1), (8, 27, 0, 5): (-1, -1), (8, 27, 1, -5): (1, 1), (8, 27, 1, -4): (1, 1), (8, 27, 1, -3): (1, 1), (8, 27, 1, -2): (1, 1), (8, 27, 1, -1): (1, 1), (8, 27, 1, 0): (-1, 1), (8, 27, 1, 1): (-1, 0), (8, 27, 1, 2): (-1, -1), (8, 27, 1, 3): (-1, -1), (8, 27, 1, 4): (-1, -1), (8, 27, 1, 5): (1, 0), (8, 27, 2, -5): (0, 1), (8, 27, 2, -4): (0, 1), (8, 27, 2, -3): (0, 1), (8, 27, 2, -2): (0, 1), (8, 27, 2, -1): (0, 1), (8, 27, 2, 0): (0, 1), (8, 27, 2, 1): (0, 1), (8, 27, 2, 2): (0, 0), (8, 27, 2, 3): (0, -1), (8, 27, 2, 4): (0, 1), (8, 27, 2, 5): (0, 1), (8, 27, 3, -5): (0, 1), (8, 27, 3, -4): (0, 1), (8, 27, 3, -3): (0, 1), (8, 27, 3, -2): (0, 1), (8, 27, 3, -1): (0, 1), (8, 27, 3, 0): (0, 1), (8, 27, 3, 1): (0, 1), (8, 27, 3, 2): (0, 0), (8, 27, 3, 3): (-1, -1), (8, 27, 3, 4): (0, 1), (8, 27, 3, 5): (0, 1), (8, 27, 4, -5): (0, 1), (8, 27, 4, -4): (0, 1), (8, 27, 4, -3): (0, 1), (8, 27, 4, -2): (0, 1), (8, 27, 4, -1): (0, 1), (8, 27, 4, 0): (0, 1), (8, 27, 4, 1): (0, 1), (8, 27, 4, 2): (0, 0), (8, 27, 4, 3): (-1, -1), (8, 27, 4, 4): (0, 1), (8, 27, 4, 5): (0, 1), (8, 27, 5, -5): (0, 1), (8, 27, 5, -4): (0, 1), (8, 27, 5, -3): (0, 1), (8, 27, 5, -2): (0, 1), (8, 27, 5, -1): (0, 1), (8, 27, 5, 0): (0, 1), (8, 27, 5, 1): (0, 1), (8, 27, 5, 2): (0, 0), (8, 27, 5, 3): (-1, -1), (8, 27, 5, 4): (0, 1), (8, 27, 5, 5): (0, 1), (8, 28, -5, -5): (0, 1), (8, 28, -5, -4): (0, 1), (8, 28, -5, -3): (0, 1), (8, 28, -5, -2): (0, 1), (8, 28, -5, -1): (0, 1), (8, 28, -5, 0): (0, 1), (8, 28, -5, 1): (0, 1), (8, 28, -5, 2): (0, 1), (8, 28, -5, 3): (0, 1), (8, 28, -5, 4): (0, 0), (8, 28, -5, 5): (-1, -1), (8, 28, -4, -5): (0, 1), (8, 28, -4, -4): (0, 1), (8, 28, -4, -3): (0, 1), (8, 28, -4, -2): (0, 1), (8, 28, -4, -1): (0, 1), (8, 28, -4, 0): (0, 1), (8, 28, -4, 1): (-1, 1), (8, 28, -4, 2): (-1, 1), (8, 28, -4, 3): (0, 1), (8, 28, -4, 4): (0, 0), (8, 28, -4, 5): (-1, -1), (8, 28, -3, -5): (0, 1), (8, 28, -3, -4): (0, 1), (8, 28, -3, -3): (0, 1), (8, 28, -3, -2): (0, 1), (8, 28, -3, -1): (0, 1), (8, 28, -3, 0): (1, 1), (8, 28, -3, 1): (1, 1), (8, 28, -3, 2): (1, 0), (8, 28, -3, 3): (0, 1), (8, 28, -3, 4): (0, 0), (8, 28, -3, 5): (-1, -1), (8, 28, -2, -5): (-1, 1), (8, 28, -2, -4): (-1, 1), (8, 28, -2, -3): (-1, 1), (8, 28, -2, -2): (-1, 1), (8, 28, -2, -1): (1, 1), (8, 28, -2, 0): (1, 1), (8, 28, -2, 1): (0, 1), (8, 28, -2, 2): (0, 0), (8, 28, -2, 3): (-1, 1), (8, 28, -2, 4): (-1, 0), (8, 28, -2, 5): (-1, -1), (8, 28, -1, -5): (-1, 1), (8, 28, -1, -4): (-1, 1), (8, 28, -1, -3): (-1, 1), (8, 28, -1, -2): (1, 1), (8, 28, -1, -1): (1, 1), (8, 28, -1, 0): (0, 1), (8, 28, -1, 1): (-1, 1), (8, 28, -1, 2): (-1, 0), (8, 28, -1, 3): (-1, -1), (8, 28, -1, 4): (-1, -1), (8, 28, -1, 5): (-1, -1), (8, 28, 0, -5): (1, 1), (8, 28, 0, -4): (1, 1), (8, 28, 0, -3): (1, 1), (8, 28, 0, -2): (1, 1), (8, 28, 0, -1): (0, 1), (8, 28, 0, 0): (-1, 1), (8, 28, 0, 1): (-1, 1), (8, 28, 0, 2): (-1, 0), (8, 28, 0, 3): (-1, -1), (8, 28, 0, 4): (-1, -1), (8, 28, 0, 5): (-1, -1), (8, 28, 1, -5): (1, 1), (8, 28, 1, -4): (1, 1), (8, 28, 1, -3): (1, 1), (8, 28, 1, -2): (1, 1), (8, 28, 1, -1): (1, 1), (8, 28, 1, 0): (-1, 1), (8, 28, 1, 1): (-1, 0), (8, 28, 1, 2): (-1, -1), (8, 28, 1, 3): (-1, -1), (8, 28, 1, 4): (1, 0), (8, 28, 1, 5): (1, 0), (8, 28, 2, -5): (0, 1), (8, 28, 2, -4): (0, 1), (8, 28, 2, -3): (0, 1), (8, 28, 2, -2): (0, 1), (8, 28, 2, -1): (0, 1), (8, 28, 2, 0): (0, 1), (8, 28, 2, 1): (0, 0), (8, 28, 2, 2): (0, -1), (8, 28, 2, 3): (0, 1), (8, 28, 2, 4): (0, 1), (8, 28, 2, 5): (0, 1), (8, 28, 3, -5): (0, 1), (8, 28, 3, -4): (0, 1), (8, 28, 3, -3): (0, 1), (8, 28, 3, -2): (0, 1), (8, 28, 3, -1): (0, 1), (8, 28, 3, 0): (0, 1), (8, 28, 3, 1): (0, 0), (8, 28, 3, 2): (-1, -1), (8, 28, 3, 3): (0, 1), (8, 28, 3, 4): (0, 1), (8, 28, 3, 5): (0, 1), (8, 28, 4, -5): (0, 1), (8, 28, 4, -4): (0, 1), (8, 28, 4, -3): (0, 1), (8, 28, 4, -2): (0, 1), (8, 28, 4, -1): (0, 1), (8, 28, 4, 0): (0, 1), (8, 28, 4, 1): (0, 0), (8, 28, 4, 2): (-1, -1), (8, 28, 4, 3): (0, 1), (8, 28, 4, 4): (0, 1), (8, 28, 4, 5): (0, 1), (8, 28, 5, -5): (0, 1), (8, 28, 5, -4): (0, 1), (8, 28, 5, -3): (0, 1), (8, 28, 5, -2): (0, 1), (8, 28, 5, -1): (0, 1), (8, 28, 5, 0): (0, 1), (8, 28, 5, 1): (0, 0), (8, 28, 5, 2): (-1, -1), (8, 28, 5, 3): (0, 1), (8, 28, 5, 4): (0, 1), (8, 28, 5, 5): (0, 1), (8, 29, -5, -5): (0, 1), (8, 29, -5, -4): (0, 1), (8, 29, -5, -3): (0, 1), (8, 29, -5, -2): (0, 1), (8, 29, -5, -1): (0, 1), (8, 29, -5, 0): (0, 1), (8, 29, -5, 1): (0, 1), (8, 29, -5, 2): (0, 1), (8, 29, -5, 3): (0, 0), (8, 29, -5, 4): (-1, -1), (8, 29, -5, 5): (0, 1), (8, 29, -4, -5): (0, 1), (8, 29, -4, -4): (0, 1), (8, 29, -4, -3): (0, 1), (8, 29, -4, -2): (0, 1), (8, 29, -4, -1): (0, 1), (8, 29, -4, 0): (-1, 1), (8, 29, -4, 1): (-1, 1), (8, 29, -4, 2): (0, 1), (8, 29, -4, 3): (0, 0), (8, 29, -4, 4): (-1, -1), (8, 29, -4, 5): (0, 1), (8, 29, -3, -5): (0, 1), (8, 29, -3, -4): (0, 1), (8, 29, -3, -3): (0, 1), (8, 29, -3, -2): (0, 1), (8, 29, -3, -1): (1, 1), (8, 29, -3, 0): (1, 1), (8, 29, -3, 1): (1, 1), (8, 29, -3, 2): (-1, 1), (8, 29, -3, 3): (-1, 0), (8, 29, -3, 4): (-1, -1), (8, 29, -3, 5): (0, 1), (8, 29, -2, -5): (-1, 1), (8, 29, -2, -4): (-1, 1), (8, 29, -2, -3): (-1, 1), (8, 29, -2, -2): (-1, 1), (8, 29, -2, -1): (0, 1), (8, 29, -2, 0): (0, 1), (8, 29, -2, 1): (0, 1), (8, 29, -2, 2): (-1, 1), (8, 29, -2, 3): (-1, 0), (8, 29, -2, 4): (-1, -1), (8, 29, -2, 5): (-1, 1), (8, 29, -1, -5): (-1, 1), (8, 29, -1, -4): (-1, 1), (8, 29, -1, -3): (-1, 1), (8, 29, -1, -2): (1, 1), (8, 29, -1, -1): (-1, 1), (8, 29, -1, 0): (-1, 1), (8, 29, -1, 1): (-1, 1), (8, 29, -1, 2): (-1, 0), (8, 29, -1, 3): (-1, -1), (8, 29, -1, 4): (-1, -1), (8, 29, -1, 5): (-1, 1), (8, 29, 0, -5): (1, 1), (8, 29, 0, -4): (1, 1), (8, 29, 0, -3): (1, 1), (8, 29, 0, -2): (1, 1), (8, 29, 0, -1): (-1, 1), (8, 29, 0, 0): (-1, 1), (8, 29, 0, 1): (-1, 0), (8, 29, 0, 2): (-1, -1), (8, 29, 0, 3): (-1, -1), (8, 29, 0, 4): (-1, -1), (8, 29, 0, 5): (-1, 1), (8, 29, 1, -5): (1, 1), (8, 29, 1, -4): (1, 1), (8, 29, 1, -3): (1, 1), (8, 29, 1, -2): (1, 1), (8, 29, 1, -1): (-1, 1), (8, 29, 1, 0): (-1, 0), (8, 29, 1, 1): (-1, -1), (8, 29, 1, 2): (-1, -1), (8, 29, 1, 3): (-1, -1), (8, 29, 1, 4): (1, 0), (8, 29, 1, 5): (1, 0), (8, 29, 2, -5): (0, 1), (8, 29, 2, -4): (0, 1), (8, 29, 2, -3): (0, 1), (8, 29, 2, -2): (0, 1), (8, 29, 2, -1): (0, 1), (8, 29, 2, 0): (0, 0), (8, 29, 2, 1): (0, -1), (8, 29, 2, 2): (0, 1), (8, 29, 2, 3): (0, 1), (8, 29, 2, 4): (0, 1), (8, 29, 2, 5): (0, 1), (8, 29, 3, -5): (0, 1), (8, 29, 3, -4): (0, 1), (8, 29, 3, -3): (0, 1), (8, 29, 3, -2): (0, 1), (8, 29, 3, -1): (0, 1), (8, 29, 3, 0): (0, 0), (8, 29, 3, 1): (-1, -1), (8, 29, 3, 2): (0, 1), (8, 29, 3, 3): (0, 1), (8, 29, 3, 4): (0, 1), (8, 29, 3, 5): (0, 1), (8, 29, 4, -5): (0, 1), (8, 29, 4, -4): (0, 1), (8, 29, 4, -3): (0, 1), (8, 29, 4, -2): (0, 1), (8, 29, 4, -1): (0, 1), (8, 29, 4, 0): (0, 0), (8, 29, 4, 1): (-1, -1), (8, 29, 4, 2): (0, 1), (8, 29, 4, 3): (0, 1), (8, 29, 4, 4): (0, 1), (8, 29, 4, 5): (0, 1), (8, 29, 5, -5): (0, 1), (8, 29, 5, -4): (0, 1), (8, 29, 5, -3): (0, 1), (8, 29, 5, -2): (0, 1), (8, 29, 5, -1): (0, 1), (8, 29, 5, 0): (0, 0), (8, 29, 5, 1): (-1, -1), (8, 29, 5, 2): (0, 1), (8, 29, 5, 3): (0, 1), (8, 29, 5, 4): (0, 1), (8, 29, 5, 5): (0, 1), (8, 30, -5, -5): (0, 1), (8, 30, -5, -4): (0, 1), (8, 30, -5, -3): (0, 1), (8, 30, -5, -2): (0, 1), (8, 30, -5, -1): (0, 1), (8, 30, -5, 0): (0, 1), (8, 30, -5, 1): (0, 1), (8, 30, -5, 2): (0, 0), (8, 30, -5, 3): (-1, -1), (8, 30, -5, 4): (-1, -1), (8, 30, -5, 5): (0, 1), (8, 30, -4, -5): (0, 1), (8, 30, -4, -4): (0, 1), (8, 30, -4, -3): (0, 1), (8, 30, -4, -2): (0, 1), (8, 30, -4, -1): (-1, 1), (8, 30, -4, 0): (-1, 1), (8, 30, -4, 1): (0, 1), (8, 30, -4, 2): (0, 0), (8, 30, -4, 3): (-1, -1), (8, 30, -4, 4): (-1, -1), (8, 30, -4, 5): (0, 1), (8, 30, -3, -5): (0, 1), (8, 30, -3, -4): (0, 1), (8, 30, -3, -3): (0, 1), (8, 30, -3, -2): (0, 1), (8, 30, -3, -1): (1, 1), (8, 30, -3, 0): (1, 1), (8, 30, -3, 1): (-1, 1), (8, 30, -3, 2): (-1, 0), (8, 30, -3, 3): (-1, -1), (8, 30, -3, 4): (-1, -1), (8, 30, -3, 5): (0, 1), (8, 30, -2, -5): (-1, 1), (8, 30, -2, -4): (-1, 1), (8, 30, -2, -3): (-1, 1), (8, 30, -2, -2): (-1, 1), (8, 30, -2, -1): (1, 1), (8, 30, -2, 0): (0, 1), (8, 30, -2, 1): (-1, 1), (8, 30, -2, 2): (-1, 1), (8, 30, -2, 3): (-1, 0), (8, 30, -2, 4): (-1, -1), (8, 30, -2, 5): (-1, 1), (8, 30, -1, -5): (-1, 1), (8, 30, -1, -4): (-1, 1), (8, 30, -1, -3): (-1, 1), (8, 30, -1, -2): (1, 1), (8, 30, -1, -1): (0, 1), (8, 30, -1, 0): (-1, 1), (8, 30, -1, 1): (-1, 0), (8, 30, -1, 2): (-1, -1), (8, 30, -1, 3): (-1, -1), (8, 30, -1, 4): (-1, -1), (8, 30, -1, 5): (-1, 1), (8, 30, 0, -5): (1, 1), (8, 30, 0, -4): (1, 1), (8, 30, 0, -3): (1, 1), (8, 30, 0, -2): (0, 1), (8, 30, 0, -1): (-1, 1), (8, 30, 0, 0): (-1, 1), (8, 30, 0, 1): (-1, 0), (8, 30, 0, 2): (-1, -1), (8, 30, 0, 3): (-1, -1), (8, 30, 0, 4): (-1, -1), (8, 30, 0, 5): (-1, 1), (8, 30, 1, -5): (1, 1), (8, 30, 1, -4): (1, 1), (8, 30, 1, -3): (1, 1), (8, 30, 1, -2): (1, 1), (8, 30, 1, -1): (-1, 1), (8, 30, 1, 0): (-1, 0), (8, 30, 1, 1): (-1, -1), (8, 30, 1, 2): (-1, -1), (8, 30, 1, 3): (-1, -1), (8, 30, 1, 4): (1, 0), (8, 30, 1, 5): (1, 0), (8, 30, 2, -5): (0, 1), (8, 30, 2, -4): (0, 1), (8, 30, 2, -3): (0, 1), (8, 30, 2, -2): (0, 1), (8, 30, 2, -1): (0, 0), (8, 30, 2, 0): (0, -1), (8, 30, 2, 1): (0, 1), (8, 30, 2, 2): (0, 1), (8, 30, 2, 3): (0, 1), (8, 30, 2, 4): (0, 1), (8, 30, 2, 5): (0, 1), (8, 30, 3, -5): (0, 1), (8, 30, 3, -4): (0, 1), (8, 30, 3, -3): (0, 1), (8, 30, 3, -2): (0, 1), (8, 30, 3, -1): (0, 0), (8, 30, 3, 0): (-1, -1), (8, 30, 3, 1): (0, 1), (8, 30, 3, 2): (0, 1), (8, 30, 3, 3): (0, 1), (8, 30, 3, 4): (0, 1), (8, 30, 3, 5): (0, 1), (8, 30, 4, -5): (0, 1), (8, 30, 4, -4): (0, 1), (8, 30, 4, -3): (0, 1), (8, 30, 4, -2): (0, 1), (8, 30, 4, -1): (0, 0), (8, 30, 4, 0): (-1, -1), (8, 30, 4, 1): (0, 1), (8, 30, 4, 2): (0, 1), (8, 30, 4, 3): (0, 1), (8, 30, 4, 4): (0, 1), (8, 30, 4, 5): (0, 1), (8, 30, 5, -5): (0, 1), (8, 30, 5, -4): (0, 1), (8, 30, 5, -3): (0, 1), (8, 30, 5, -2): (0, 1), (8, 30, 5, -1): (0, 0), (8, 30, 5, 0): (-1, -1), (8, 30, 5, 1): (0, 1), (8, 30, 5, 2): (0, 1), (8, 30, 5, 3): (0, 1), (8, 30, 5, 4): (0, 1), (8, 30, 5, 5): (0, 1), (8, 31, -5, -5): (0, 1), (8, 31, -5, -4): (0, 1), (8, 31, -5, -3): (0, 1), (8, 31, -5, -2): (0, 1), (8, 31, -5, -1): (0, 1), (8, 31, -5, 0): (0, 1), (8, 31, -5, 1): (0, 1), (8, 31, -5, 2): (0, 0), (8, 31, -5, 3): (-1, -1), (8, 31, -5, 4): (0, 0), (8, 31, -5, 5): (-1, -1), (8, 31, -4, -5): (0, 1), (8, 31, -4, -4): (0, 1), (8, 31, -4, -3): (0, 1), (8, 31, -4, -2): (-1, 1), (8, 31, -4, -1): (-1, 1), (8, 31, -4, 0): (0, 1), (8, 31, -4, 1): (0, 1), (8, 31, -4, 2): (0, 0), (8, 31, -4, 3): (-1, -1), (8, 31, -4, 4): (0, 0), (8, 31, -4, 5): (-1, -1), (8, 31, -3, -5): (0, 1), (8, 31, -3, -4): (0, 1), (8, 31, -3, -3): (0, 1), (8, 31, -3, -2): (1, 1), (8, 31, -3, -1): (1, 1), (8, 31, -3, 0): (-1, 1), (8, 31, -3, 1): (-1, 1), (8, 31, -3, 2): (-1, 0), (8, 31, -3, 3): (-1, -1), (8, 31, -3, 4): (0, 0), (8, 31, -3, 5): (-1, -1), (8, 31, -2, -5): (-1, 1), (8, 31, -2, -4): (-1, 1), (8, 31, -2, -3): (-1, 1), (8, 31, -2, -2): (0, 1), (8, 31, -2, -1): (0, 1), (8, 31, -2, 0): (-1, 1), (8, 31, -2, 1): (-1, 0), (8, 31, -2, 2): (-1, -1), (8, 31, -2, 3): (-1, -1), (8, 31, -2, 4): (-1, 0), (8, 31, -2, 5): (-1, -1), (8, 31, -1, -5): (-1, 1), (8, 31, -1, -4): (-1, 1), (8, 31, -1, -3): (-1, 1), (8, 31, -1, -2): (-1, 1), (8, 31, -1, -1): (-1, 1), (8, 31, -1, 0): (-1, 1), (8, 31, -1, 1): (-1, 0), (8, 31, -1, 2): (-1, -1), (8, 31, -1, 3): (-1, -1), (8, 31, -1, 4): (-1, 0), (8, 31, -1, 5): (-1, -1), (8, 31, 0, -5): (1, 1), (8, 31, 0, -4): (1, 1), (8, 31, 0, -3): (1, 1), (8, 31, 0, -2): (0, 1), (8, 31, 0, -1): (-1, 1), (8, 31, 0, 0): (-1, 1), (8, 31, 0, 1): (-1, 0), (8, 31, 0, 2): (-1, -1), (8, 31, 0, 3): (-1, -1), (8, 31, 0, 4): (-1, 1), (8, 31, 0, 5): (-1, 1), (8, 31, 1, -5): (1, 1), (8, 31, 1, -4): (1, 1), (8, 31, 1, -3): (1, 1), (8, 31, 1, -2): (1, 0), (8, 31, 1, -1): (-1, 1), (8, 31, 1, 0): (-1, 1), (8, 31, 1, 1): (-1, 0), (8, 31, 1, 2): (-1, -1), (8, 31, 1, 3): (-1, -1), (8, 31, 1, 4): (-1, 1), (8, 31, 1, 5): (-1, 1), (8, 31, 2, -5): (0, 1), (8, 31, 2, -4): (0, 1), (8, 31, 2, -3): (0, 1), (8, 31, 2, -2): (0, 0), (8, 31, 2, -1): (0, -1), (8, 31, 2, 0): (0, 1), (8, 31, 2, 1): (0, 1), (8, 31, 2, 2): (0, 1), (8, 31, 2, 3): (0, 1), (8, 31, 2, 4): (0, 1), (8, 31, 2, 5): (0, 1), (8, 31, 3, -5): (0, 1), (8, 31, 3, -4): (0, 1), (8, 31, 3, -3): (0, 1), (8, 31, 3, -2): (0, 0), (8, 31, 3, -1): (-1, -1), (8, 31, 3, 0): (0, 1), (8, 31, 3, 1): (0, 1), (8, 31, 3, 2): (0, 1), (8, 31, 3, 3): (0, 1), (8, 31, 3, 4): (0, 1), (8, 31, 3, 5): (0, 1), (8, 31, 4, -5): (0, 1), (8, 31, 4, -4): (0, 1), (8, 31, 4, -3): (0, 1), (8, 31, 4, -2): (0, 0), (8, 31, 4, -1): (-1, -1), (8, 31, 4, 0): (0, 1), (8, 31, 4, 1): (0, 1), (8, 31, 4, 2): (0, 1), (8, 31, 4, 3): (0, 1), (8, 31, 4, 4): (0, 1), (8, 31, 4, 5): (0, 1), (8, 31, 5, -5): (0, 1), (8, 31, 5, -4): (0, 1), (8, 31, 5, -3): (0, 1), (8, 31, 5, -2): (0, 0), (8, 31, 5, -1): (-1, -1), (8, 31, 5, 0): (0, 1), (8, 31, 5, 1): (0, 1), (8, 31, 5, 2): (0, 1), (8, 31, 5, 3): (0, 1), (8, 31, 5, 4): (0, 1), (8, 31, 5, 5): (0, 1), (8, 32, -5, -5): (0, 1), (8, 32, -5, -4): (0, 1), (8, 32, -5, -3): (0, 1), (8, 32, -5, -2): (0, 1), (8, 32, -5, -1): (0, 1), (8, 32, -5, 0): (0, 1), (8, 32, -5, 1): (0, 0), (8, 32, -5, 2): (-1, -1), (8, 32, -5, 3): (-1, -1), (8, 32, -5, 4): (-1, -1), (8, 32, -5, 5): (0, 1), (8, 32, -4, -5): (0, 1), (8, 32, -4, -4): (0, 1), (8, 32, -4, -3): (-1, 1), (8, 32, -4, -2): (-1, 1), (8, 32, -4, -1): (0, 1), (8, 32, -4, 0): (0, 1), (8, 32, -4, 1): (0, 0), (8, 32, -4, 2): (-1, -1), (8, 32, -4, 3): (-1, -1), (8, 32, -4, 4): (-1, -1), (8, 32, -4, 5): (-1, 1), (8, 32, -3, -5): (0, 1), (8, 32, -3, -4): (0, 1), (8, 32, -3, -3): (0, 1), (8, 32, -3, -2): (-1, 1), (8, 32, -3, -1): (-1, 1), (8, 32, -3, 0): (-1, 1), (8, 32, -3, 1): (-1, 0), (8, 32, -3, 2): (-1, -1), (8, 32, -3, 3): (-1, -1), (8, 32, -3, 4): (-1, -1), (8, 32, -3, 5): (-1, 1), (8, 32, -2, -5): (-1, 1), (8, 32, -2, -4): (-1, 1), (8, 32, -2, -3): (-1, 1), (8, 32, -2, -2): (-1, 1), (8, 32, -2, -1): (-1, 1), (8, 32, -2, 0): (-1, 1), (8, 32, -2, 1): (-1, 0), (8, 32, -2, 2): (-1, -1), (8, 32, -2, 3): (-1, -1), (8, 32, -2, 4): (-1, -1), (8, 32, -2, 5): (-1, 1), (8, 32, -1, -5): (-1, 1), (8, 32, -1, -4): (-1, 1), (8, 32, -1, -3): (-1, 1), (8, 32, -1, -2): (-1, 1), (8, 32, -1, -1): (-1, 1), (8, 32, -1, 0): (-1, 0), (8, 32, -1, 1): (-1, -1), (8, 32, -1, 2): (-1, -1), (8, 32, -1, 3): (-1, -1), (8, 32, -1, 4): (-1, -1), (8, 32, -1, 5): (-1, 1), (8, 32, 0, -5): (1, 1), (8, 32, 0, -4): (1, 1), (8, 32, 0, -3): (1, 1), (8, 32, 0, -2): (-1, 1), (8, 32, 0, -1): (-1, 1), (8, 32, 0, 0): (-1, 0), (8, 32, 0, 1): (-1, -1), (8, 32, 0, 2): (-1, -1), (8, 32, 0, 3): (-1, -1), (8, 32, 0, 4): (-1, 1), (8, 32, 0, 5): (-1, 1), (8, 32, 1, -5): (1, 1), (8, 32, 1, -4): (1, 1), (8, 32, 1, -3): (1, 0), (8, 32, 1, -2): (-1, 1), (8, 32, 1, -1): (-1, 1), (8, 32, 1, 0): (-1, 1), (8, 32, 1, 1): (-1, 0), (8, 32, 1, 2): (-1, -1), (8, 32, 1, 3): (-1, 1), (8, 32, 1, 4): (-1, 1), (8, 32, 1, 5): (-1, 1), (8, 32, 2, -5): (0, 1), (8, 32, 2, -4): (0, 1), (8, 32, 2, -3): (0, 0), (8, 32, 2, -2): (0, -1), (8, 32, 2, -1): (0, 1), (8, 32, 2, 0): (0, 1), (8, 32, 2, 1): (0, 1), (8, 32, 2, 2): (0, 1), (8, 32, 2, 3): (0, 1), (8, 32, 2, 4): (0, 1), (8, 32, 2, 5): (0, 1), (8, 32, 3, -5): (0, 1), (8, 32, 3, -4): (0, 1), (8, 32, 3, -3): (0, 0), (8, 32, 3, -2): (-1, -1), (8, 32, 3, -1): (0, 1), (8, 32, 3, 0): (0, 1), (8, 32, 3, 1): (0, 1), (8, 32, 3, 2): (0, 1), (8, 32, 3, 3): (0, 1), (8, 32, 3, 4): (0, 1), (8, 32, 3, 5): (0, 1), (8, 32, 4, -5): (0, 1), (8, 32, 4, -4): (0, 1), (8, 32, 4, -3): (0, 0), (8, 32, 4, -2): (-1, -1), (8, 32, 4, -1): (0, 1), (8, 32, 4, 0): (0, 1), (8, 32, 4, 1): (0, 1), (8, 32, 4, 2): (0, 1), (8, 32, 4, 3): (0, 1), (8, 32, 4, 4): (0, 1), (8, 32, 4, 5): (0, 1), (8, 32, 5, -5): (0, 1), (8, 32, 5, -4): (0, 1), (8, 32, 5, -3): (0, 0), (8, 32, 5, -2): (-1, -1), (8, 32, 5, -1): (0, 1), (8, 32, 5, 0): (0, 1), (8, 32, 5, 1): (0, 1), (8, 32, 5, 2): (0, 1), (8, 32, 5, 3): (0, 1), (8, 32, 5, 4): (0, 1), (8, 32, 5, 5): (0, 1), (8, 33, -5, -5): (0, 1), (8, 33, -5, -4): (0, 1), (8, 33, -5, -3): (0, 1), (8, 33, -5, -2): (0, 1), (8, 33, -5, -1): (0, 1), (8, 33, -5, 0): (0, 1), (8, 33, -5, 1): (0, 0), (8, 33, -5, 2): (-1, -1), (8, 33, -5, 3): (-1, -1), (8, 33, -5, 4): (0, 1), (8, 33, -5, 5): (0, 1), (8, 33, -4, -5): (0, 1), (8, 33, -4, -4): (-1, 1), (8, 33, -4, -3): (-1, 1), (8, 33, -4, -2): (0, 1), (8, 33, -4, -1): (0, 1), (8, 33, -4, 0): (0, 1), (8, 33, -4, 1): (0, 0), (8, 33, -4, 2): (-1, -1), (8, 33, -4, 3): (-1, -1), (8, 33, -4, 4): (-1, 1), (8, 33, -4, 5): (-1, 1), (8, 33, -3, -5): (0, 1), (8, 33, -3, -4): (0, 1), (8, 33, -3, -3): (-1, 1), (8, 33, -3, -2): (0, 1), (8, 33, -3, -1): (-1, 1), (8, 33, -3, 0): (-1, 1), (8, 33, -3, 1): (-1, 0), (8, 33, -3, 2): (-1, -1), (8, 33, -3, 3): (-1, -1), (8, 33, -3, 4): (-1, 1), (8, 33, -3, 5): (-1, 1), (8, 33, -2, -5): (-1, 1), (8, 33, -2, -4): (-1, 1), (8, 33, -2, -3): (-1, 1), (8, 33, -2, -2): (-1, 1), (8, 33, -2, -1): (-1, 1), (8, 33, -2, 0): (-1, 0), (8, 33, -2, 1): (-1, -1), (8, 33, -2, 2): (-1, -1), (8, 33, -2, 3): (-1, -1), (8, 33, -2, 4): (-1, 1), (8, 33, -2, 5): (-1, 1), (8, 33, -1, -5): (-1, 1), (8, 33, -1, -4): (-1, 1), (8, 33, -1, -3): (-1, 1), (8, 33, -1, -2): (-1, 1), (8, 33, -1, -1): (-1, 1), (8, 33, -1, 0): (-1, 0), (8, 33, -1, 1): (-1, -1), (8, 33, -1, 2): (-1, -1), (8, 33, -1, 3): (-1, -1), (8, 33, -1, 4): (-1, 1), (8, 33, -1, 5): (-1, 1), (8, 33, 0, -5): (1, 1), (8, 33, 0, -4): (1, 1), (8, 33, 0, -3): (1, 1), (8, 33, 0, -2): (-1, 1), (8, 33, 0, -1): (-1, 1), (8, 33, 0, 0): (-1, 0), (8, 33, 0, 1): (-1, -1), (8, 33, 0, 2): (-1, -1), (8, 33, 0, 3): (-1, 1), (8, 33, 0, 4): (-1, 1), (8, 33, 0, 5): (-1, 1), (8, 33, 1, -5): (1, 1), (8, 33, 1, -4): (1, 0), (8, 33, 1, -3): (1, -1), (8, 33, 1, -2): (-1, 1), (8, 33, 1, -1): (-1, 1), (8, 33, 1, 0): (-1, 1), (8, 33, 1, 1): (-1, 0), (8, 33, 1, 2): (-1, 1), (8, 33, 1, 3): (-1, 1), (8, 33, 1, 4): (-1, 1), (8, 33, 1, 5): (-1, 1), (8, 33, 2, -5): (0, 1), (8, 33, 2, -4): (0, 0), (8, 33, 2, -3): (0, -1), (8, 33, 2, -2): (0, 1), (8, 33, 2, -1): (0, 1), (8, 33, 2, 0): (0, 1), (8, 33, 2, 1): (0, 1), (8, 33, 2, 2): (0, 1), (8, 33, 2, 3): (0, 1), (8, 33, 2, 4): (0, 1), (8, 33, 2, 5): (0, 1), (8, 33, 3, -5): (0, 1), (8, 33, 3, -4): (0, 0), (8, 33, 3, -3): (-1, -1), (8, 33, 3, -2): (0, 1), (8, 33, 3, -1): (0, 1), (8, 33, 3, 0): (0, 1), (8, 33, 3, 1): (0, 1), (8, 33, 3, 2): (0, 1), (8, 33, 3, 3): (0, 1), (8, 33, 3, 4): (0, 1), (8, 33, 3, 5): (0, 1), (8, 33, 4, -5): (0, 1), (8, 33, 4, -4): (0, 0), (8, 33, 4, -3): (-1, -1), (8, 33, 4, -2): (0, 1), (8, 33, 4, -1): (0, 1), (8, 33, 4, 0): (0, 1), (8, 33, 4, 1): (0, 1), (8, 33, 4, 2): (0, 1), (8, 33, 4, 3): (0, 1), (8, 33, 4, 4): (0, 1), (8, 33, 4, 5): (0, 1), (8, 33, 5, -5): (0, 1), (8, 33, 5, -4): (0, 0), (8, 33, 5, -3): (-1, -1), (8, 33, 5, -2): (0, 1), (8, 33, 5, -1): (0, 1), (8, 33, 5, 0): (0, 1), (8, 33, 5, 1): (0, 1), (8, 33, 5, 2): (0, 1), (8, 33, 5, 3): (0, 1), (8, 33, 5, 4): (0, 1), (8, 33, 5, 5): (0, 1), (8, 34, -5, -5): (0, 1), (8, 34, -5, -4): (0, 1), (8, 34, -5, -3): (0, 1), (8, 34, -5, -2): (0, 1), (8, 34, -5, -1): (0, 1), (8, 34, -5, 0): (0, 0), (8, 34, -5, 1): (-1, -1), (8, 34, -5, 2): (-1, -1), (8, 34, -5, 3): (0, 1), (8, 34, -5, 4): (0, 1), (8, 34, -5, 5): (0, 1), (8, 34, -4, -5): (-1, 1), (8, 34, -4, -4): (-1, 1), (8, 34, -4, -3): (0, 1), (8, 34, -4, -2): (0, 1), (8, 34, -4, -1): (0, 1), (8, 34, -4, 0): (0, 0), (8, 34, -4, 1): (-1, -1), (8, 34, -4, 2): (-1, -1), (8, 34, -4, 3): (-1, 1), (8, 34, -4, 4): (-1, 1), (8, 34, -4, 5): (-1, 1), (8, 34, -3, -5): (0, 1), (8, 34, -3, -4): (-1, 1), (8, 34, -3, -3): (0, 1), (8, 34, -3, -2): (-1, 1), (8, 34, -3, -1): (-1, 1), (8, 34, -3, 0): (-1, 0), (8, 34, -3, 1): (-1, -1), (8, 34, -3, 2): (-1, -1), (8, 34, -3, 3): (-1, 1), (8, 34, -3, 4): (-1, 1), (8, 34, -3, 5): (-1, 1), (8, 34, -2, -5): (-1, 1), (8, 34, -2, -4): (-1, 1), (8, 34, -2, -3): (-1, 1), (8, 34, -2, -2): (-1, 1), (8, 34, -2, -1): (-1, 1), (8, 34, -2, 0): (-1, 0), (8, 34, -2, 1): (-1, -1), (8, 34, -2, 2): (-1, -1), (8, 34, -2, 3): (-1, 1), (8, 34, -2, 4): (-1, 1), (8, 34, -2, 5): (-1, 1), (8, 34, -1, -5): (-1, 1), (8, 34, -1, -4): (-1, 1), (8, 34, -1, -3): (-1, 1), (8, 34, -1, -2): (-1, 1), (8, 34, -1, -1): (-1, 1), (8, 34, -1, 0): (-1, 0), (8, 34, -1, 1): (-1, -1), (8, 34, -1, 2): (-1, -1), (8, 34, -1, 3): (-1, 1), (8, 34, -1, 4): (-1, 1), (8, 34, -1, 5): (-1, 1), (8, 34, 0, -5): (1, 1), (8, 34, 0, -4): (1, 1), (8, 34, 0, -3): (-1, 1), (8, 34, 0, -2): (-1, 1), (8, 34, 0, -1): (-1, 1), (8, 34, 0, 0): (-1, 0), (8, 34, 0, 1): (-1, -1), (8, 34, 0, 2): (-1, -1), (8, 34, 0, 3): (-1, 1), (8, 34, 0, 4): (-1, 1), (8, 34, 0, 5): (-1, 1), (8, 34, 1, -5): (1, 0), (8, 34, 1, -4): (1, -1), (8, 34, 1, -3): (1, 1), (8, 34, 1, -2): (-1, 1), (8, 34, 1, -1): (-1, 1), (8, 34, 1, 0): (-1, 1), (8, 34, 1, 1): (-1, 1), (8, 34, 1, 2): (-1, 1), (8, 34, 1, 3): (-1, 1), (8, 34, 1, 4): (-1, 1), (8, 34, 1, 5): (-1, 1), (8, 34, 2, -5): (0, 0), (8, 34, 2, -4): (0, -1), (8, 34, 2, -3): (0, 1), (8, 34, 2, -2): (0, 1), (8, 34, 2, -1): (0, 1), (8, 34, 2, 0): (0, 1), (8, 34, 2, 1): (0, 1), (8, 34, 2, 2): (0, 1), (8, 34, 2, 3): (0, 1), (8, 34, 2, 4): (0, 1), (8, 34, 2, 5): (0, 1), (8, 34, 3, -5): (0, 0), (8, 34, 3, -4): (-1, -1), (8, 34, 3, -3): (0, 1), (8, 34, 3, -2): (0, 1), (8, 34, 3, -1): (0, 1), (8, 34, 3, 0): (0, 1), (8, 34, 3, 1): (0, 1), (8, 34, 3, 2): (0, 1), (8, 34, 3, 3): (0, 1), (8, 34, 3, 4): (0, 1), (8, 34, 3, 5): (0, 1), (8, 34, 4, -5): (0, 0), (8, 34, 4, -4): (-1, -1), (8, 34, 4, -3): (0, 1), (8, 34, 4, -2): (0, 1), (8, 34, 4, -1): (0, 1), (8, 34, 4, 0): (0, 1), (8, 34, 4, 1): (0, 1), (8, 34, 4, 2): (0, 1), (8, 34, 4, 3): (0, 1), (8, 34, 4, 4): (0, 1), (8, 34, 4, 5): (0, 1), (8, 34, 5, -5): (0, 0), (8, 34, 5, -4): (-1, -1), (8, 34, 5, -3): (0, 1), (8, 34, 5, -2): (0, 1), (8, 34, 5, -1): (0, 1), (8, 34, 5, 0): (0, 1), (8, 34, 5, 1): (0, 1), (8, 34, 5, 2): (0, 1), (8, 34, 5, 3): (0, 1), (8, 34, 5, 4): (0, 1), (8, 34, 5, 5): (0, 1), (8, 35, -5, -5): (0, 1), (8, 35, -5, -4): (0, 0), (8, 35, -5, -3): (0, 1), (8, 35, -5, -2): (0, 1), (8, 35, -5, -1): (0, 1), (8, 35, -5, 0): (0, 0), (8, 35, -5, 1): (-1, -1), (8, 35, -5, 2): (0, 1), (8, 35, -5, 3): (0, 1), (8, 35, -5, 4): (0, 1), (8, 35, -5, 5): (0, 1), (8, 35, -4, -5): (-1, 1), (8, 35, -4, -4): (1, 1), (8, 35, -4, -3): (0, 1), (8, 35, -4, -2): (0, 1), (8, 35, -4, -1): (0, 1), (8, 35, -4, 0): (0, 0), (8, 35, -4, 1): (-1, -1), (8, 35, -4, 2): (-1, 1), (8, 35, -4, 3): (-1, 1), (8, 35, -4, 4): (-1, 1), (8, 35, -4, 5): (-1, 1), (8, 35, -3, -5): (-1, 1), (8, 35, -3, -4): (0, 1), (8, 35, -3, -3): (0, 1), (8, 35, -3, -2): (-1, 1), (8, 35, -3, -1): (-1, 1), (8, 35, -3, 0): (-1, 0), (8, 35, -3, 1): (-1, -1), (8, 35, -3, 2): (-1, 1), (8, 35, -3, 3): (-1, 1), (8, 35, -3, 4): (-1, 1), (8, 35, -3, 5): (-1, 1), (8, 35, -2, -5): (-1, 1), (8, 35, -2, -4): (-1, 1), (8, 35, -2, -3): (-1, 1), (8, 35, -2, -2): (-1, 1), (8, 35, -2, -1): (-1, 1), (8, 35, -2, 0): (-1, 0), (8, 35, -2, 1): (-1, -1), (8, 35, -2, 2): (-1, 1), (8, 35, -2, 3): (-1, 1), (8, 35, -2, 4): (-1, 1), (8, 35, -2, 5): (-1, 1), (8, 35, -1, -5): (-1, 1), (8, 35, -1, -4): (-1, 1), (8, 35, -1, -3): (-1, 1), (8, 35, -1, -2): (-1, 1), (8, 35, -1, -1): (-1, 1), (8, 35, -1, 0): (-1, 0), (8, 35, -1, 1): (-1, -1), (8, 35, -1, 2): (-1, 1), (8, 35, -1, 3): (-1, 1), (8, 35, -1, 4): (-1, 1), (8, 35, -1, 5): (-1, 1), (8, 35, 0, -5): (1, 1), (8, 35, 0, -4): (1, 1), (8, 35, 0, -3): (-1, 1), (8, 35, 0, -2): (-1, 1), (8, 35, 0, -1): (-1, 1), (8, 35, 0, 0): (-1, 0), (8, 35, 0, 1): (-1, -1), (8, 35, 0, 2): (-1, 1), (8, 35, 0, 3): (-1, 1), (8, 35, 0, 4): (-1, 1), (8, 35, 0, 5): (-1, 1), (8, 35, 1, -5): (1, 0), (8, 35, 1, -4): (1, 1), (8, 35, 1, -3): (1, 0), (8, 35, 1, -2): (-1, 1), (8, 35, 1, -1): (-1, 1), (8, 35, 1, 0): (-1, 1), (8, 35, 1, 1): (-1, 1), (8, 35, 1, 2): (-1, 1), (8, 35, 1, 3): (-1, 1), (8, 35, 1, 4): (-1, 1), (8, 35, 1, 5): (-1, 1), (8, 35, 2, -5): (0, 0), (8, 35, 2, -4): (0, 1), (8, 35, 2, -3): (0, 1), (8, 35, 2, -2): (0, 1), (8, 35, 2, -1): (0, 1), (8, 35, 2, 0): (0, 1), (8, 35, 2, 1): (0, 1), (8, 35, 2, 2): (0, 1), (8, 35, 2, 3): (0, 1), (8, 35, 2, 4): (0, 1), (8, 35, 2, 5): (0, 1), (8, 35, 3, -5): (0, 0), (8, 35, 3, -4): (0, 1), (8, 35, 3, -3): (0, 1), (8, 35, 3, -2): (0, 1), (8, 35, 3, -1): (0, 1), (8, 35, 3, 0): (0, 1), (8, 35, 3, 1): (0, 1), (8, 35, 3, 2): (0, 1), (8, 35, 3, 3): (0, 1), (8, 35, 3, 4): (0, 1), (8, 35, 3, 5): (0, 1), (8, 35, 4, -5): (0, 0), (8, 35, 4, -4): (0, 1), (8, 35, 4, -3): (0, 1), (8, 35, 4, -2): (0, 1), (8, 35, 4, -1): (0, 1), (8, 35, 4, 0): (0, 1), (8, 35, 4, 1): (0, 1), (8, 35, 4, 2): (0, 1), (8, 35, 4, 3): (0, 1), (8, 35, 4, 4): (0, 1), (8, 35, 4, 5): (0, 1), (8, 35, 5, -5): (0, 0), (8, 35, 5, -4): (0, 1), (8, 35, 5, -3): (0, 1), (8, 35, 5, -2): (0, 1), (8, 35, 5, -1): (0, 1), (8, 35, 5, 0): (0, 1), (8, 35, 5, 1): (0, 1), (8, 35, 5, 2): (0, 1), (8, 35, 5, 3): (0, 1), (8, 35, 5, 4): (0, 1), (8, 35, 5, 5): (0, 1), (9, 1, -5, -5): (0, 1), (9, 1, -5, -4): (0, 1), (9, 1, -5, -3): (0, 1), (9, 1, -5, -2): (0, 1), (9, 1, -5, -1): (0, 0), (9, 1, -5, 0): (0, 1), (9, 1, -5, 1): (0, 1), (9, 1, -5, 2): (0, 1), (9, 1, -5, 3): (0, 1), (9, 1, -5, 4): (0, 1), (9, 1, -5, 5): (0, 1), (9, 1, -4, -5): (-1, 1), (9, 1, -4, -4): (-1, 1), (9, 1, -4, -3): (-1, 1), (9, 1, -4, -2): (-1, 1), (9, 1, -4, -1): (-1, 0), (9, 1, -4, 0): (0, 1), (9, 1, -4, 1): (0, 1), (9, 1, -4, 2): (0, 1), (9, 1, -4, 3): (1, 1), (9, 1, -4, 4): (1, 1), (9, 1, -4, 5): (1, 0), (9, 1, -3, -5): (0, 1), (9, 1, -3, -4): (0, 1), (9, 1, -3, -3): (0, 1), (9, 1, -3, -2): (0, 1), (9, 1, -3, -1): (-1, 1), (9, 1, -3, 0): (1, 1), (9, 1, -3, 1): (1, 1), (9, 1, -3, 2): (1, 1), (9, 1, -3, 3): (1, 1), (9, 1, -3, 4): (1, 1), (9, 1, -3, 5): (1, 0), (9, 1, -2, -5): (1, 0), (9, 1, -2, -4): (1, 0), (9, 1, -2, -3): (1, 0), (9, 1, -2, -2): (1, 0), (9, 1, -2, -1): (1, 0), (9, 1, -2, 0): (1, 1), (9, 1, -2, 1): (1, 1), (9, 1, -2, 2): (1, 1), (9, 1, -2, 3): (1, 1), (9, 1, -2, 4): (1, 1), (9, 1, -2, 5): (1, 0), (9, 1, -1, -5): (1, 0), (9, 1, -1, -4): (1, 0), (9, 1, -1, -3): (1, 0), (9, 1, -1, -2): (1, 0), (9, 1, -1, -1): (1, 0), (9, 1, -1, 0): (1, 1), (9, 1, -1, 1): (1, 1), (9, 1, -1, 2): (1, 1), (9, 1, -1, 3): (1, 1), (9, 1, -1, 4): (1, 1), (9, 1, -1, 5): (1, 0), (9, 1, 0, -5): (0, 1), (9, 1, 0, -4): (0, 1), (9, 1, 0, -3): (0, 1), (9, 1, 0, -2): (0, 1), (9, 1, 0, -1): (0, 1), (9, 1, 0, 0): (0, 1), (9, 1, 0, 1): (0, 1), (9, 1, 0, 2): (0, 1), (9, 1, 0, 3): (0, 1), (9, 1, 0, 4): (0, 1), (9, 1, 0, 5): (0, 1), (9, 1, 1, -5): (0, 1), (9, 1, 1, -4): (0, 1), (9, 1, 1, -3): (0, 1), (9, 1, 1, -2): (0, 1), (9, 1, 1, -1): (0, 1), (9, 1, 1, 0): (-1, 1), (9, 1, 1, 1): (-1, 1), (9, 1, 1, 2): (-1, 1), (9, 1, 1, 3): (-1, 1), (9, 1, 1, 4): (-1, 1), (9, 1, 1, 5): (-1, 1), (9, 1, 2, -5): (0, 1), (9, 1, 2, -4): (0, 1), (9, 1, 2, -3): (0, 1), (9, 1, 2, -2): (0, 1), (9, 1, 2, -1): (0, 1), (9, 1, 2, 0): (0, 1), (9, 1, 2, 1): (0, 1), (9, 1, 2, 2): (0, 1), (9, 1, 2, 3): (0, 1), (9, 1, 2, 4): (0, 1), (9, 1, 2, 5): (0, 1), (9, 1, 3, -5): (0, 1), (9, 1, 3, -4): (0, 1), (9, 1, 3, -3): (0, 1), (9, 1, 3, -2): (0, 1), (9, 1, 3, -1): (0, 1), (9, 1, 3, 0): (0, 1), (9, 1, 3, 1): (0, 1), (9, 1, 3, 2): (0, 1), (9, 1, 3, 3): (0, 1), (9, 1, 3, 4): (0, 1), (9, 1, 3, 5): (0, 1), (9, 1, 4, -5): (0, 1), (9, 1, 4, -4): (0, 1), (9, 1, 4, -3): (0, 1), (9, 1, 4, -2): (0, 1), (9, 1, 4, -1): (0, 1), (9, 1, 4, 0): (0, 1), (9, 1, 4, 1): (0, 1), (9, 1, 4, 2): (0, 1), (9, 1, 4, 3): (0, 1), (9, 1, 4, 4): (0, 1), (9, 1, 4, 5): (0, 1), (9, 1, 5, -5): (0, 1), (9, 1, 5, -4): (0, 1), (9, 1, 5, -3): (0, 1), (9, 1, 5, -2): (0, 1), (9, 1, 5, -1): (0, 1), (9, 1, 5, 0): (0, 1), (9, 1, 5, 1): (0, 1), (9, 1, 5, 2): (0, 1), (9, 1, 5, 3): (0, 1), (9, 1, 5, 4): (0, 1), (9, 1, 5, 5): (0, 1), (9, 2, -5, -5): (0, 1), (9, 2, -5, -4): (0, 1), (9, 2, -5, -3): (0, 1), (9, 2, -5, -2): (0, 0), (9, 2, -5, -1): (0, 1), (9, 2, -5, 0): (0, 1), (9, 2, -5, 1): (0, 1), (9, 2, -5, 2): (0, 1), (9, 2, -5, 3): (0, 1), (9, 2, -5, 4): (0, 1), (9, 2, -5, 5): (0, 1), (9, 2, -4, -5): (-1, 1), (9, 2, -4, -4): (-1, 1), (9, 2, -4, -3): (-1, 1), (9, 2, -4, -2): (-1, 0), (9, 2, -4, -1): (0, 1), (9, 2, -4, 0): (0, 1), (9, 2, -4, 1): (0, 1), (9, 2, -4, 2): (0, 1), (9, 2, -4, 3): (0, 1), (9, 2, -4, 4): (1, 1), (9, 2, -4, 5): (1, 0), (9, 2, -3, -5): (0, 1), (9, 2, -3, -4): (0, 1), (9, 2, -3, -3): (0, 1), (9, 2, -3, -2): (-1, 1), (9, 2, -3, -1): (-1, 1), (9, 2, -3, 0): (1, 1), (9, 2, -3, 1): (1, 1), (9, 2, -3, 2): (1, 1), (9, 2, -3, 3): (1, 1), (9, 2, -3, 4): (1, 1), (9, 2, -3, 5): (1, 0), (9, 2, -2, -5): (1, 0), (9, 2, -2, -4): (1, 0), (9, 2, -2, -3): (1, 0), (9, 2, -2, -2): (1, 0), (9, 2, -2, -1): (1, 1), (9, 2, -2, 0): (1, 1), (9, 2, -2, 1): (1, 1), (9, 2, -2, 2): (1, 1), (9, 2, -2, 3): (1, 1), (9, 2, -2, 4): (1, 1), (9, 2, -2, 5): (1, 0), (9, 2, -1, -5): (1, 0), (9, 2, -1, -4): (1, 0), (9, 2, -1, -3): (1, 0), (9, 2, -1, -2): (1, 0), (9, 2, -1, -1): (1, 1), (9, 2, -1, 0): (1, 1), (9, 2, -1, 1): (1, 1), (9, 2, -1, 2): (1, 1), (9, 2, -1, 3): (1, 1), (9, 2, -1, 4): (1, 1), (9, 2, -1, 5): (1, 0), (9, 2, 0, -5): (0, 1), (9, 2, 0, -4): (0, 1), (9, 2, 0, -3): (0, 1), (9, 2, 0, -2): (0, 0), (9, 2, 0, -1): (0, 1), (9, 2, 0, 0): (0, 1), (9, 2, 0, 1): (0, 1), (9, 2, 0, 2): (0, 1), (9, 2, 0, 3): (0, 1), (9, 2, 0, 4): (0, 1), (9, 2, 0, 5): (0, 1), (9, 2, 1, -5): (0, 1), (9, 2, 1, -4): (0, 1), (9, 2, 1, -3): (0, 1), (9, 2, 1, -2): (0, 1), (9, 2, 1, -1): (0, 1), (9, 2, 1, 0): (-1, 1), (9, 2, 1, 1): (-1, 1), (9, 2, 1, 2): (-1, 1), (9, 2, 1, 3): (-1, 1), (9, 2, 1, 4): (-1, 1), (9, 2, 1, 5): (-1, 1), (9, 2, 2, -5): (0, 1), (9, 2, 2, -4): (0, 1), (9, 2, 2, -3): (0, 1), (9, 2, 2, -2): (0, 1), (9, 2, 2, -1): (0, 1), (9, 2, 2, 0): (0, 1), (9, 2, 2, 1): (0, 1), (9, 2, 2, 2): (0, 1), (9, 2, 2, 3): (0, 1), (9, 2, 2, 4): (0, 1), (9, 2, 2, 5): (0, 1), (9, 2, 3, -5): (0, 1), (9, 2, 3, -4): (0, 1), (9, 2, 3, -3): (0, 1), (9, 2, 3, -2): (0, 1), (9, 2, 3, -1): (0, 1), (9, 2, 3, 0): (0, 1), (9, 2, 3, 1): (0, 1), (9, 2, 3, 2): (0, 1), (9, 2, 3, 3): (0, 1), (9, 2, 3, 4): (0, 1), (9, 2, 3, 5): (0, 1), (9, 2, 4, -5): (0, 1), (9, 2, 4, -4): (0, 1), (9, 2, 4, -3): (0, 1), (9, 2, 4, -2): (0, 1), (9, 2, 4, -1): (0, 1), (9, 2, 4, 0): (0, 1), (9, 2, 4, 1): (0, 1), (9, 2, 4, 2): (0, 1), (9, 2, 4, 3): (0, 1), (9, 2, 4, 4): (0, 1), (9, 2, 4, 5): (0, 1), (9, 2, 5, -5): (0, 1), (9, 2, 5, -4): (0, 1), (9, 2, 5, -3): (0, 1), (9, 2, 5, -2): (0, 1), (9, 2, 5, -1): (0, 1), (9, 2, 5, 0): (0, 1), (9, 2, 5, 1): (0, 1), (9, 2, 5, 2): (0, 1), (9, 2, 5, 3): (0, 1), (9, 2, 5, 4): (0, 1), (9, 2, 5, 5): (0, 1), (9, 3, -5, -5): (0, 1), (9, 3, -5, -4): (0, 1), (9, 3, -5, -3): (0, 0), (9, 3, -5, -2): (0, 1), (9, 3, -5, -1): (0, 1), (9, 3, -5, 0): (0, 1), (9, 3, -5, 1): (0, 1), (9, 3, -5, 2): (0, 1), (9, 3, -5, 3): (0, 1), (9, 3, -5, 4): (0, 1), (9, 3, -5, 5): (0, 1), (9, 3, -4, -5): (-1, 1), (9, 3, -4, -4): (-1, 1), (9, 3, -4, -3): (-1, 0), (9, 3, -4, -2): (0, 1), (9, 3, -4, -1): (0, 1), (9, 3, -4, 0): (0, 1), (9, 3, -4, 1): (0, 1), (9, 3, -4, 2): (0, 1), (9, 3, -4, 3): (0, 1), (9, 3, -4, 4): (1, 1), (9, 3, -4, 5): (1, 0), (9, 3, -3, -5): (0, 1), (9, 3, -3, -4): (0, 1), (9, 3, -3, -3): (-1, 1), (9, 3, -3, -2): (-1, 1), (9, 3, -3, -1): (-1, 1), (9, 3, -3, 0): (1, 1), (9, 3, -3, 1): (1, 1), (9, 3, -3, 2): (1, 1), (9, 3, -3, 3): (1, 1), (9, 3, -3, 4): (1, 1), (9, 3, -3, 5): (1, 0), (9, 3, -2, -5): (1, 0), (9, 3, -2, -4): (1, 0), (9, 3, -2, -3): (1, 0), (9, 3, -2, -2): (1, -1), (9, 3, -2, -1): (1, 1), (9, 3, -2, 0): (1, 1), (9, 3, -2, 1): (1, 1), (9, 3, -2, 2): (1, 1), (9, 3, -2, 3): (1, 1), (9, 3, -2, 4): (1, 1), (9, 3, -2, 5): (1, 0), (9, 3, -1, -5): (1, 0), (9, 3, -1, -4): (1, 0), (9, 3, -1, -3): (1, 0), (9, 3, -1, -2): (1, -1), (9, 3, -1, -1): (1, 1), (9, 3, -1, 0): (1, 1), (9, 3, -1, 1): (1, 1), (9, 3, -1, 2): (1, 1), (9, 3, -1, 3): (1, 1), (9, 3, -1, 4): (1, 1), (9, 3, -1, 5): (1, 0), (9, 3, 0, -5): (0, 1), (9, 3, 0, -4): (0, 1), (9, 3, 0, -3): (0, 0), (9, 3, 0, -2): (1, 1), (9, 3, 0, -1): (0, 1), (9, 3, 0, 0): (0, 1), (9, 3, 0, 1): (0, 1), (9, 3, 0, 2): (0, 1), (9, 3, 0, 3): (0, 1), (9, 3, 0, 4): (0, 1), (9, 3, 0, 5): (0, 1), (9, 3, 1, -5): (0, 1), (9, 3, 1, -4): (0, 1), (9, 3, 1, -3): (0, 1), (9, 3, 1, -2): (0, 1), (9, 3, 1, -1): (0, 1), (9, 3, 1, 0): (-1, 1), (9, 3, 1, 1): (-1, 1), (9, 3, 1, 2): (-1, 1), (9, 3, 1, 3): (-1, 1), (9, 3, 1, 4): (-1, 1), (9, 3, 1, 5): (-1, 1), (9, 3, 2, -5): (0, 1), (9, 3, 2, -4): (0, 1), (9, 3, 2, -3): (0, 1), (9, 3, 2, -2): (0, 1), (9, 3, 2, -1): (0, 1), (9, 3, 2, 0): (0, 1), (9, 3, 2, 1): (0, 1), (9, 3, 2, 2): (0, 1), (9, 3, 2, 3): (0, 1), (9, 3, 2, 4): (0, 1), (9, 3, 2, 5): (0, 1), (9, 3, 3, -5): (0, 1), (9, 3, 3, -4): (0, 1), (9, 3, 3, -3): (0, 1), (9, 3, 3, -2): (0, 1), (9, 3, 3, -1): (0, 1), (9, 3, 3, 0): (0, 1), (9, 3, 3, 1): (0, 1), (9, 3, 3, 2): (0, 1), (9, 3, 3, 3): (0, 1), (9, 3, 3, 4): (0, 1), (9, 3, 3, 5): (0, 1), (9, 3, 4, -5): (0, 1), (9, 3, 4, -4): (0, 1), (9, 3, 4, -3): (0, 1), (9, 3, 4, -2): (0, 1), (9, 3, 4, -1): (0, 1), (9, 3, 4, 0): (0, 1), (9, 3, 4, 1): (0, 1), (9, 3, 4, 2): (0, 1), (9, 3, 4, 3): (0, 1), (9, 3, 4, 4): (0, 1), (9, 3, 4, 5): (0, 1), (9, 3, 5, -5): (0, 1), (9, 3, 5, -4): (0, 1), (9, 3, 5, -3): (0, 1), (9, 3, 5, -2): (0, 1), (9, 3, 5, -1): (0, 1), (9, 3, 5, 0): (0, 1), (9, 3, 5, 1): (0, 1), (9, 3, 5, 2): (0, 1), (9, 3, 5, 3): (0, 1), (9, 3, 5, 4): (0, 1), (9, 3, 5, 5): (0, 1), (9, 4, -5, -5): (0, 1), (9, 4, -5, -4): (0, 0), (9, 4, -5, -3): (0, 1), (9, 4, -5, -2): (0, 1), (9, 4, -5, -1): (0, 1), (9, 4, -5, 0): (0, 1), (9, 4, -5, 1): (0, 1), (9, 4, -5, 2): (0, 1), (9, 4, -5, 3): (0, 1), (9, 4, -5, 4): (0, 1), (9, 4, -5, 5): (0, 1), (9, 4, -4, -5): (-1, 1), (9, 4, -4, -4): (-1, 0), (9, 4, -4, -3): (0, 1), (9, 4, -4, -2): (0, 1), (9, 4, -4, -1): (0, 1), (9, 4, -4, 0): (0, 1), (9, 4, -4, 1): (0, 1), (9, 4, -4, 2): (0, 1), (9, 4, -4, 3): (0, 1), (9, 4, -4, 4): (1, 1), (9, 4, -4, 5): (1, 0), (9, 4, -3, -5): (0, 1), (9, 4, -3, -4): (-1, 1), (9, 4, -3, -3): (-1, 1), (9, 4, -3, -2): (-1, 1), (9, 4, -3, -1): (-1, 1), (9, 4, -3, 0): (1, 1), (9, 4, -3, 1): (1, 1), (9, 4, -3, 2): (1, 1), (9, 4, -3, 3): (1, 1), (9, 4, -3, 4): (1, 1), (9, 4, -3, 5): (1, 0), (9, 4, -2, -5): (1, 0), (9, 4, -2, -4): (1, 0), (9, 4, -2, -3): (1, -1), (9, 4, -2, -2): (-1, 0), (9, 4, -2, -1): (1, 1), (9, 4, -2, 0): (1, 1), (9, 4, -2, 1): (1, 1), (9, 4, -2, 2): (1, 1), (9, 4, -2, 3): (1, 1), (9, 4, -2, 4): (1, 1), (9, 4, -2, 5): (1, 0), (9, 4, -1, -5): (1, 0), (9, 4, -1, -4): (1, 0), (9, 4, -1, -3): (1, -1), (9, 4, -1, -2): (-1, 1), (9, 4, -1, -1): (1, 1), (9, 4, -1, 0): (1, 1), (9, 4, -1, 1): (1, 1), (9, 4, -1, 2): (1, 1), (9, 4, -1, 3): (1, 1), (9, 4, -1, 4): (1, 1), (9, 4, -1, 5): (1, 0), (9, 4, 0, -5): (0, 1), (9, 4, 0, -4): (0, 0), (9, 4, 0, -3): (1, 1), (9, 4, 0, -2): (1, 1), (9, 4, 0, -1): (0, 1), (9, 4, 0, 0): (0, 1), (9, 4, 0, 1): (0, 1), (9, 4, 0, 2): (0, 1), (9, 4, 0, 3): (0, 1), (9, 4, 0, 4): (0, 1), (9, 4, 0, 5): (0, 1), (9, 4, 1, -5): (0, 1), (9, 4, 1, -4): (0, 1), (9, 4, 1, -3): (0, 1), (9, 4, 1, -2): (0, 1), (9, 4, 1, -1): (0, 1), (9, 4, 1, 0): (-1, 1), (9, 4, 1, 1): (-1, 1), (9, 4, 1, 2): (-1, 1), (9, 4, 1, 3): (-1, 1), (9, 4, 1, 4): (-1, 1), (9, 4, 1, 5): (-1, 1), (9, 4, 2, -5): (0, 1), (9, 4, 2, -4): (0, 1), (9, 4, 2, -3): (0, 1), (9, 4, 2, -2): (0, 1), (9, 4, 2, -1): (0, 1), (9, 4, 2, 0): (0, 1), (9, 4, 2, 1): (0, 1), (9, 4, 2, 2): (0, 1), (9, 4, 2, 3): (0, 1), (9, 4, 2, 4): (0, 1), (9, 4, 2, 5): (0, 1), (9, 4, 3, -5): (0, 1), (9, 4, 3, -4): (0, 1), (9, 4, 3, -3): (0, 1), (9, 4, 3, -2): (0, 1), (9, 4, 3, -1): (0, 1), (9, 4, 3, 0): (0, 1), (9, 4, 3, 1): (0, 1), (9, 4, 3, 2): (0, 1), (9, 4, 3, 3): (0, 1), (9, 4, 3, 4): (0, 1), (9, 4, 3, 5): (0, 1), (9, 4, 4, -5): (0, 1), (9, 4, 4, -4): (0, 1), (9, 4, 4, -3): (0, 1), (9, 4, 4, -2): (0, 1), (9, 4, 4, -1): (0, 1), (9, 4, 4, 0): (0, 1), (9, 4, 4, 1): (0, 1), (9, 4, 4, 2): (0, 1), (9, 4, 4, 3): (0, 1), (9, 4, 4, 4): (0, 1), (9, 4, 4, 5): (0, 1), (9, 4, 5, -5): (0, 1), (9, 4, 5, -4): (0, 1), (9, 4, 5, -3): (0, 1), (9, 4, 5, -2): (0, 1), (9, 4, 5, -1): (0, 1), (9, 4, 5, 0): (0, 1), (9, 4, 5, 1): (0, 1), (9, 4, 5, 2): (0, 1), (9, 4, 5, 3): (0, 1), (9, 4, 5, 4): (0, 1), (9, 4, 5, 5): (0, 1), (9, 5, -5, -5): (0, 0), (9, 5, -5, -4): (0, 1), (9, 5, -5, -3): (0, 1), (9, 5, -5, -2): (0, 1), (9, 5, -5, -1): (0, 1), (9, 5, -5, 0): (0, 1), (9, 5, -5, 1): (0, 1), (9, 5, -5, 2): (0, 1), (9, 5, -5, 3): (0, 1), (9, 5, -5, 4): (0, 1), (9, 5, -5, 5): (0, 1), (9, 5, -4, -5): (-1, 0), (9, 5, -4, -4): (0, 1), (9, 5, -4, -3): (0, 1), (9, 5, -4, -2): (0, 1), (9, 5, -4, -1): (0, 1), (9, 5, -4, 0): (0, 1), (9, 5, -4, 1): (0, 1), (9, 5, -4, 2): (0, 1), (9, 5, -4, 3): (1, 1), (9, 5, -4, 4): (1, 1), (9, 5, -4, 5): (1, 0), (9, 5, -3, -5): (-1, 1), (9, 5, -3, -4): (-1, 1), (9, 5, -3, -3): (-1, 1), (9, 5, -3, -2): (-1, 1), (9, 5, -3, -1): (-1, 1), (9, 5, -3, 0): (1, 1), (9, 5, -3, 1): (1, 1), (9, 5, -3, 2): (1, 1), (9, 5, -3, 3): (1, 1), (9, 5, -3, 4): (1, 1), (9, 5, -3, 5): (1, 0), (9, 5, -2, -5): (1, 0), (9, 5, -2, -4): (1, -1), (9, 5, -2, -3): (-1, 0), (9, 5, -2, -2): (0, 1), (9, 5, -2, -1): (1, 1), (9, 5, -2, 0): (1, 1), (9, 5, -2, 1): (1, 1), (9, 5, -2, 2): (1, 1), (9, 5, -2, 3): (1, 1), (9, 5, -2, 4): (1, 1), (9, 5, -2, 5): (1, 0), (9, 5, -1, -5): (1, 0), (9, 5, -1, -4): (1, -1), (9, 5, -1, -3): (-1, 1), (9, 5, -1, -2): (-1, 1), (9, 5, -1, -1): (1, 1), (9, 5, -1, 0): (1, 1), (9, 5, -1, 1): (1, 1), (9, 5, -1, 2): (1, 1), (9, 5, -1, 3): (1, 1), (9, 5, -1, 4): (1, 1), (9, 5, -1, 5): (1, 0), (9, 5, 0, -5): (0, 0), (9, 5, 0, -4): (1, 1), (9, 5, 0, -3): (1, 1), (9, 5, 0, -2): (1, 1), (9, 5, 0, -1): (0, 1), (9, 5, 0, 0): (0, 1), (9, 5, 0, 1): (0, 1), (9, 5, 0, 2): (0, 1), (9, 5, 0, 3): (0, 1), (9, 5, 0, 4): (0, 1), (9, 5, 0, 5): (0, 1), (9, 5, 1, -5): (0, 1), (9, 5, 1, -4): (0, 1), (9, 5, 1, -3): (0, 1), (9, 5, 1, -2): (0, 1), (9, 5, 1, -1): (0, 1), (9, 5, 1, 0): (-1, 1), (9, 5, 1, 1): (-1, 1), (9, 5, 1, 2): (-1, 1), (9, 5, 1, 3): (-1, 1), (9, 5, 1, 4): (-1, 1), (9, 5, 1, 5): (-1, 1), (9, 5, 2, -5): (0, 1), (9, 5, 2, -4): (0, 1), (9, 5, 2, -3): (0, 1), (9, 5, 2, -2): (0, 1), (9, 5, 2, -1): (0, 1), (9, 5, 2, 0): (0, 1), (9, 5, 2, 1): (0, 1), (9, 5, 2, 2): (0, 1), (9, 5, 2, 3): (0, 1), (9, 5, 2, 4): (0, 1), (9, 5, 2, 5): (0, 1), (9, 5, 3, -5): (0, 1), (9, 5, 3, -4): (0, 1), (9, 5, 3, -3): (0, 1), (9, 5, 3, -2): (0, 1), (9, 5, 3, -1): (0, 1), (9, 5, 3, 0): (0, 1), (9, 5, 3, 1): (0, 1), (9, 5, 3, 2): (0, 1), (9, 5, 3, 3): (0, 1), (9, 5, 3, 4): (0, 1), (9, 5, 3, 5): (0, 1), (9, 5, 4, -5): (0, 1), (9, 5, 4, -4): (0, 1), (9, 5, 4, -3): (0, 1), (9, 5, 4, -2): (0, 1), (9, 5, 4, -1): (0, 1), (9, 5, 4, 0): (0, 1), (9, 5, 4, 1): (0, 1), (9, 5, 4, 2): (0, 1), (9, 5, 4, 3): (0, 1), (9, 5, 4, 4): (0, 1), (9, 5, 4, 5): (0, 1), (9, 5, 5, -5): (0, 1), (9, 5, 5, -4): (0, 1), (9, 5, 5, -3): (0, 1), (9, 5, 5, -2): (0, 1), (9, 5, 5, -1): (0, 1), (9, 5, 5, 0): (0, 1), (9, 5, 5, 1): (0, 1), (9, 5, 5, 2): (0, 1), (9, 5, 5, 3): (0, 1), (9, 5, 5, 4): (0, 1), (9, 5, 5, 5): (0, 1), (9, 6, -5, -5): (0, 1), (9, 6, -5, -4): (0, 1), (9, 6, -5, -3): (0, 1), (9, 6, -5, -2): (0, 1), (9, 6, -5, -1): (0, 1), (9, 6, -5, 0): (0, 1), (9, 6, -5, 1): (0, 1), (9, 6, -5, 2): (0, 1), (9, 6, -5, 3): (0, 1), (9, 6, -5, 4): (0, 1), (9, 6, -5, 5): (0, 1), (9, 6, -4, -5): (0, 1), (9, 6, -4, -4): (0, 1), (9, 6, -4, -3): (0, 1), (9, 6, -4, -2): (0, 1), (9, 6, -4, -1): (0, 1), (9, 6, -4, 0): (0, 1), (9, 6, -4, 1): (0, 1), (9, 6, -4, 2): (0, 1), (9, 6, -4, 3): (1, 1), (9, 6, -4, 4): (0, 1), (9, 6, -4, 5): (0, 1), (9, 6, -3, -5): (-1, 1), (9, 6, -3, -4): (-1, 1), (9, 6, -3, -3): (-1, 1), (9, 6, -3, -2): (-1, 1), (9, 6, -3, -1): (-1, 1), (9, 6, -3, 0): (1, 1), (9, 6, -3, 1): (1, 1), (9, 6, -3, 2): (1, 1), (9, 6, -3, 3): (1, 1), (9, 6, -3, 4): (1, 1), (9, 6, -3, 5): (1, 0), (9, 6, -2, -5): (-1, 1), (9, 6, -2, -4): (-1, 1), (9, 6, -2, -3): (-1, 0), (9, 6, -2, -2): (0, 1), (9, 6, -2, -1): (1, 1), (9, 6, -2, 0): (1, 1), (9, 6, -2, 1): (1, 1), (9, 6, -2, 2): (1, 1), (9, 6, -2, 3): (1, 1), (9, 6, -2, 4): (1, 1), (9, 6, -2, 5): (1, 0), (9, 6, -1, -5): (-1, 1), (9, 6, -1, -4): (-1, 1), (9, 6, -1, -3): (-1, 1), (9, 6, -1, -2): (-1, 1), (9, 6, -1, -1): (1, 1), (9, 6, -1, 0): (1, 1), (9, 6, -1, 1): (1, 1), (9, 6, -1, 2): (1, 1), (9, 6, -1, 3): (1, 1), (9, 6, -1, 4): (1, 1), (9, 6, -1, 5): (1, 0), (9, 6, 0, -5): (1, 1), (9, 6, 0, -4): (1, 1), (9, 6, 0, -3): (1, 1), (9, 6, 0, -2): (1, 1), (9, 6, 0, -1): (0, 1), (9, 6, 0, 0): (0, 1), (9, 6, 0, 1): (0, 1), (9, 6, 0, 2): (0, 1), (9, 6, 0, 3): (0, 1), (9, 6, 0, 4): (0, 1), (9, 6, 0, 5): (0, 1), (9, 6, 1, -5): (0, 1), (9, 6, 1, -4): (0, 1), (9, 6, 1, -3): (0, 1), (9, 6, 1, -2): (0, 1), (9, 6, 1, -1): (0, 1), (9, 6, 1, 0): (-1, 1), (9, 6, 1, 1): (-1, 1), (9, 6, 1, 2): (-1, 1), (9, 6, 1, 3): (-1, 1), (9, 6, 1, 4): (-1, 1), (9, 6, 1, 5): (-1, 1), (9, 6, 2, -5): (0, 1), (9, 6, 2, -4): (0, 1), (9, 6, 2, -3): (0, 1), (9, 6, 2, -2): (0, 1), (9, 6, 2, -1): (0, 1), (9, 6, 2, 0): (0, 1), (9, 6, 2, 1): (0, 1), (9, 6, 2, 2): (0, 1), (9, 6, 2, 3): (0, 1), (9, 6, 2, 4): (0, 1), (9, 6, 2, 5): (0, 1), (9, 6, 3, -5): (0, 1), (9, 6, 3, -4): (0, 1), (9, 6, 3, -3): (0, 1), (9, 6, 3, -2): (0, 1), (9, 6, 3, -1): (0, 1), (9, 6, 3, 0): (0, 1), (9, 6, 3, 1): (0, 1), (9, 6, 3, 2): (0, 1), (9, 6, 3, 3): (0, 1), (9, 6, 3, 4): (0, 1), (9, 6, 3, 5): (0, 1), (9, 6, 4, -5): (0, 1), (9, 6, 4, -4): (0, 1), (9, 6, 4, -3): (0, 1), (9, 6, 4, -2): (0, 1), (9, 6, 4, -1): (0, 1), (9, 6, 4, 0): (0, 1), (9, 6, 4, 1): (0, 1), (9, 6, 4, 2): (0, 1), (9, 6, 4, 3): (0, 1), (9, 6, 4, 4): (0, 1), (9, 6, 4, 5): (0, 1), (9, 6, 5, -5): (0, 1), (9, 6, 5, -4): (0, 1), (9, 6, 5, -3): (0, 1), (9, 6, 5, -2): (0, 1), (9, 6, 5, -1): (0, 1), (9, 6, 5, 0): (0, 1), (9, 6, 5, 1): (0, 1), (9, 6, 5, 2): (0, 1), (9, 6, 5, 3): (0, 1), (9, 6, 5, 4): (0, 1), (9, 6, 5, 5): (0, 1), (9, 7, -5, -5): (0, 1), (9, 7, -5, -4): (0, 1), (9, 7, -5, -3): (0, 1), (9, 7, -5, -2): (0, 1), (9, 7, -5, -1): (0, 1), (9, 7, -5, 0): (0, 1), (9, 7, -5, 1): (0, 1), (9, 7, -5, 2): (0, 1), (9, 7, -5, 3): (0, 1), (9, 7, -5, 4): (0, 1), (9, 7, -5, 5): (0, 1), (9, 7, -4, -5): (0, 1), (9, 7, -4, -4): (0, 1), (9, 7, -4, -3): (0, 1), (9, 7, -4, -2): (0, 1), (9, 7, -4, -1): (0, 1), (9, 7, -4, 0): (0, 1), (9, 7, -4, 1): (0, 1), (9, 7, -4, 2): (0, 1), (9, 7, -4, 3): (0, 1), (9, 7, -4, 4): (1, 1), (9, 7, -4, 5): (1, 0), (9, 7, -3, -5): (-1, 1), (9, 7, -3, -4): (-1, 1), (9, 7, -3, -3): (-1, 1), (9, 7, -3, -2): (-1, 1), (9, 7, -3, -1): (-1, 1), (9, 7, -3, 0): (1, 1), (9, 7, -3, 1): (1, 1), (9, 7, -3, 2): (1, 1), (9, 7, -3, 3): (1, 1), (9, 7, -3, 4): (1, 1), (9, 7, -3, 5): (1, 0), (9, 7, -2, -5): (-1, 1), (9, 7, -2, -4): (-1, 0), (9, 7, -2, -3): (0, 1), (9, 7, -2, -2): (0, 1), (9, 7, -2, -1): (1, 1), (9, 7, -2, 0): (1, 1), (9, 7, -2, 1): (1, 1), (9, 7, -2, 2): (1, 1), (9, 7, -2, 3): (1, 1), (9, 7, -2, 4): (1, 1), (9, 7, -2, 5): (1, 0), (9, 7, -1, -5): (-1, 1), (9, 7, -1, -4): (-1, 1), (9, 7, -1, -3): (-1, 1), (9, 7, -1, -2): (-1, 1), (9, 7, -1, -1): (1, 1), (9, 7, -1, 0): (1, 1), (9, 7, -1, 1): (1, 1), (9, 7, -1, 2): (1, 1), (9, 7, -1, 3): (1, 1), (9, 7, -1, 4): (1, 1), (9, 7, -1, 5): (1, 0), (9, 7, 0, -5): (1, 1), (9, 7, 0, -4): (1, 1), (9, 7, 0, -3): (1, 1), (9, 7, 0, -2): (1, 1), (9, 7, 0, -1): (0, 1), (9, 7, 0, 0): (0, 1), (9, 7, 0, 1): (0, 1), (9, 7, 0, 2): (0, 1), (9, 7, 0, 3): (0, 1), (9, 7, 0, 4): (0, 1), (9, 7, 0, 5): (0, 1), (9, 7, 1, -5): (0, 1), (9, 7, 1, -4): (0, 1), (9, 7, 1, -3): (0, 1), (9, 7, 1, -2): (0, 1), (9, 7, 1, -1): (0, 1), (9, 7, 1, 0): (-1, 1), (9, 7, 1, 1): (-1, 1), (9, 7, 1, 2): (-1, 1), (9, 7, 1, 3): (-1, 1), (9, 7, 1, 4): (-1, 1), (9, 7, 1, 5): (-1, 1), (9, 7, 2, -5): (0, 1), (9, 7, 2, -4): (0, 1), (9, 7, 2, -3): (0, 1), (9, 7, 2, -2): (0, 1), (9, 7, 2, -1): (0, 1), (9, 7, 2, 0): (0, 1), (9, 7, 2, 1): (0, 1), (9, 7, 2, 2): (0, 1), (9, 7, 2, 3): (0, 1), (9, 7, 2, 4): (0, 1), (9, 7, 2, 5): (0, 1), (9, 7, 3, -5): (0, 1), (9, 7, 3, -4): (0, 1), (9, 7, 3, -3): (0, 1), (9, 7, 3, -2): (0, 1), (9, 7, 3, -1): (0, 1), (9, 7, 3, 0): (0, 1), (9, 7, 3, 1): (0, 1), (9, 7, 3, 2): (0, 1), (9, 7, 3, 3): (0, 1), (9, 7, 3, 4): (0, 1), (9, 7, 3, 5): (0, 1), (9, 7, 4, -5): (0, 1), (9, 7, 4, -4): (0, 1), (9, 7, 4, -3): (0, 1), (9, 7, 4, -2): (0, 1), (9, 7, 4, -1): (0, 1), (9, 7, 4, 0): (0, 1), (9, 7, 4, 1): (0, 1), (9, 7, 4, 2): (0, 1), (9, 7, 4, 3): (0, 1), (9, 7, 4, 4): (0, 1), (9, 7, 4, 5): (0, 1), (9, 7, 5, -5): (0, 1), (9, 7, 5, -4): (0, 1), (9, 7, 5, -3): (0, 1), (9, 7, 5, -2): (0, 1), (9, 7, 5, -1): (0, 1), (9, 7, 5, 0): (0, 1), (9, 7, 5, 1): (0, 1), (9, 7, 5, 2): (0, 1), (9, 7, 5, 3): (0, 1), (9, 7, 5, 4): (0, 1), (9, 7, 5, 5): (0, 1), (9, 8, -5, -5): (0, 1), (9, 8, -5, -4): (0, 1), (9, 8, -5, -3): (0, 1), (9, 8, -5, -2): (0, 1), (9, 8, -5, -1): (0, 1), (9, 8, -5, 0): (0, 1), (9, 8, -5, 1): (0, 1), (9, 8, -5, 2): (0, 1), (9, 8, -5, 3): (0, 1), (9, 8, -5, 4): (0, 1), (9, 8, -5, 5): (0, 1), (9, 8, -4, -5): (0, 1), (9, 8, -4, -4): (0, 1), (9, 8, -4, -3): (0, 1), (9, 8, -4, -2): (0, 1), (9, 8, -4, -1): (0, 1), (9, 8, -4, 0): (0, 1), (9, 8, -4, 1): (0, 1), (9, 8, -4, 2): (0, 1), (9, 8, -4, 3): (1, 1), (9, 8, -4, 4): (1, 1), (9, 8, -4, 5): (1, 0), (9, 8, -3, -5): (-1, 1), (9, 8, -3, -4): (-1, 1), (9, 8, -3, -3): (-1, 1), (9, 8, -3, -2): (-1, 1), (9, 8, -3, -1): (-1, 1), (9, 8, -3, 0): (1, 1), (9, 8, -3, 1): (1, 1), (9, 8, -3, 2): (1, 1), (9, 8, -3, 3): (1, 1), (9, 8, -3, 4): (1, 1), (9, 8, -3, 5): (1, 0), (9, 8, -2, -5): (-1, 1), (9, 8, -2, -4): (-1, 0), (9, 8, -2, -3): (0, 1), (9, 8, -2, -2): (0, 1), (9, 8, -2, -1): (1, 1), (9, 8, -2, 0): (1, 1), (9, 8, -2, 1): (1, 1), (9, 8, -2, 2): (1, 1), (9, 8, -2, 3): (1, 1), (9, 8, -2, 4): (1, 1), (9, 8, -2, 5): (1, 0), (9, 8, -1, -5): (-1, 1), (9, 8, -1, -4): (-1, 1), (9, 8, -1, -3): (-1, 1), (9, 8, -1, -2): (-1, 1), (9, 8, -1, -1): (1, 1), (9, 8, -1, 0): (1, 1), (9, 8, -1, 1): (1, 1), (9, 8, -1, 2): (1, 1), (9, 8, -1, 3): (1, 1), (9, 8, -1, 4): (1, 1), (9, 8, -1, 5): (1, 0), (9, 8, 0, -5): (1, 1), (9, 8, 0, -4): (1, 1), (9, 8, 0, -3): (1, 1), (9, 8, 0, -2): (1, 1), (9, 8, 0, -1): (0, 1), (9, 8, 0, 0): (0, 1), (9, 8, 0, 1): (0, 1), (9, 8, 0, 2): (0, 1), (9, 8, 0, 3): (0, 1), (9, 8, 0, 4): (0, 1), (9, 8, 0, 5): (0, 1), (9, 8, 1, -5): (0, 1), (9, 8, 1, -4): (0, 1), (9, 8, 1, -3): (0, 1), (9, 8, 1, -2): (0, 1), (9, 8, 1, -1): (0, 1), (9, 8, 1, 0): (-1, 1), (9, 8, 1, 1): (-1, 1), (9, 8, 1, 2): (-1, 1), (9, 8, 1, 3): (-1, 1), (9, 8, 1, 4): (-1, 1), (9, 8, 1, 5): (-1, 1), (9, 8, 2, -5): (0, 1), (9, 8, 2, -4): (0, 1), (9, 8, 2, -3): (0, 1), (9, 8, 2, -2): (0, 1), (9, 8, 2, -1): (0, 1), (9, 8, 2, 0): (0, 1), (9, 8, 2, 1): (0, 1), (9, 8, 2, 2): (0, 1), (9, 8, 2, 3): (0, 1), (9, 8, 2, 4): (0, 1), (9, 8, 2, 5): (0, 1), (9, 8, 3, -5): (0, 1), (9, 8, 3, -4): (0, 1), (9, 8, 3, -3): (0, 1), (9, 8, 3, -2): (0, 1), (9, 8, 3, -1): (0, 1), (9, 8, 3, 0): (0, 1), (9, 8, 3, 1): (0, 1), (9, 8, 3, 2): (0, 1), (9, 8, 3, 3): (0, 1), (9, 8, 3, 4): (0, 1), (9, 8, 3, 5): (0, 1), (9, 8, 4, -5): (0, 1), (9, 8, 4, -4): (0, 1), (9, 8, 4, -3): (0, 1), (9, 8, 4, -2): (0, 1), (9, 8, 4, -1): (0, 1), (9, 8, 4, 0): (0, 1), (9, 8, 4, 1): (0, 1), (9, 8, 4, 2): (0, 1), (9, 8, 4, 3): (0, 1), (9, 8, 4, 4): (0, 1), (9, 8, 4, 5): (0, 1), (9, 8, 5, -5): (0, 1), (9, 8, 5, -4): (0, 1), (9, 8, 5, -3): (0, 1), (9, 8, 5, -2): (0, 1), (9, 8, 5, -1): (0, 1), (9, 8, 5, 0): (0, 1), (9, 8, 5, 1): (0, 1), (9, 8, 5, 2): (0, 1), (9, 8, 5, 3): (0, 1), (9, 8, 5, 4): (0, 1), (9, 8, 5, 5): (0, 1), (9, 9, -5, -5): (0, 1), (9, 9, -5, -4): (0, 1), (9, 9, -5, -3): (0, 1), (9, 9, -5, -2): (0, 1), (9, 9, -5, -1): (0, 1), (9, 9, -5, 0): (0, 1), (9, 9, -5, 1): (0, 1), (9, 9, -5, 2): (0, 1), (9, 9, -5, 3): (0, 1), (9, 9, -5, 4): (0, 1), (9, 9, -5, 5): (0, 1), (9, 9, -4, -5): (0, 1), (9, 9, -4, -4): (0, 1), (9, 9, -4, -3): (0, 1), (9, 9, -4, -2): (0, 1), (9, 9, -4, -1): (0, 1), (9, 9, -4, 0): (0, 1), (9, 9, -4, 1): (0, 1), (9, 9, -4, 2): (0, 1), (9, 9, -4, 3): (1, 1), (9, 9, -4, 4): (1, 1), (9, 9, -4, 5): (1, 0), (9, 9, -3, -5): (-1, 1), (9, 9, -3, -4): (-1, 1), (9, 9, -3, -3): (-1, 1), (9, 9, -3, -2): (-1, 1), (9, 9, -3, -1): (-1, 1), (9, 9, -3, 0): (1, 1), (9, 9, -3, 1): (1, 1), (9, 9, -3, 2): (1, 1), (9, 9, -3, 3): (1, 1), (9, 9, -3, 4): (1, 1), (9, 9, -3, 5): (1, 0), (9, 9, -2, -5): (-1, 0), (9, 9, -2, -4): (0, 1), (9, 9, -2, -3): (0, 1), (9, 9, -2, -2): (0, 1), (9, 9, -2, -1): (1, 1), (9, 9, -2, 0): (1, 1), (9, 9, -2, 1): (1, 1), (9, 9, -2, 2): (1, 1), (9, 9, -2, 3): (1, 1), (9, 9, -2, 4): (1, 1), (9, 9, -2, 5): (1, 0), (9, 9, -1, -5): (-1, 1), (9, 9, -1, -4): (-1, 1), (9, 9, -1, -3): (-1, 1), (9, 9, -1, -2): (-1, 1), (9, 9, -1, -1): (1, 1), (9, 9, -1, 0): (1, 1), (9, 9, -1, 1): (1, 1), (9, 9, -1, 2): (1, 1), (9, 9, -1, 3): (1, 1), (9, 9, -1, 4): (1, 1), (9, 9, -1, 5): (1, 0), (9, 9, 0, -5): (1, 1), (9, 9, 0, -4): (1, 1), (9, 9, 0, -3): (1, 1), (9, 9, 0, -2): (1, 1), (9, 9, 0, -1): (0, 1), (9, 9, 0, 0): (0, 1), (9, 9, 0, 1): (0, 1), (9, 9, 0, 2): (0, 1), (9, 9, 0, 3): (0, 1), (9, 9, 0, 4): (0, 1), (9, 9, 0, 5): (0, 1), (9, 9, 1, -5): (0, 1), (9, 9, 1, -4): (0, 1), (9, 9, 1, -3): (0, 1), (9, 9, 1, -2): (0, 1), (9, 9, 1, -1): (0, 1), (9, 9, 1, 0): (-1, 1), (9, 9, 1, 1): (-1, 1), (9, 9, 1, 2): (-1, 1), (9, 9, 1, 3): (-1, 1), (9, 9, 1, 4): (-1, 1), (9, 9, 1, 5): (-1, 1), (9, 9, 2, -5): (0, 1), (9, 9, 2, -4): (0, 1), (9, 9, 2, -3): (0, 1), (9, 9, 2, -2): (0, 1), (9, 9, 2, -1): (0, 1), (9, 9, 2, 0): (0, 1), (9, 9, 2, 1): (0, 1), (9, 9, 2, 2): (0, 1), (9, 9, 2, 3): (0, 1), (9, 9, 2, 4): (0, 1), (9, 9, 2, 5): (0, 1), (9, 9, 3, -5): (0, 1), (9, 9, 3, -4): (0, 1), (9, 9, 3, -3): (0, 1), (9, 9, 3, -2): (0, 1), (9, 9, 3, -1): (0, 1), (9, 9, 3, 0): (0, 1), (9, 9, 3, 1): (0, 1), (9, 9, 3, 2): (0, 1), (9, 9, 3, 3): (0, 1), (9, 9, 3, 4): (0, 1), (9, 9, 3, 5): (0, 1), (9, 9, 4, -5): (0, 1), (9, 9, 4, -4): (0, 1), (9, 9, 4, -3): (0, 1), (9, 9, 4, -2): (0, 1), (9, 9, 4, -1): (0, 1), (9, 9, 4, 0): (0, 1), (9, 9, 4, 1): (0, 1), (9, 9, 4, 2): (0, 1), (9, 9, 4, 3): (0, 1), (9, 9, 4, 4): (0, 1), (9, 9, 4, 5): (0, 1), (9, 9, 5, -5): (0, 1), (9, 9, 5, -4): (0, 1), (9, 9, 5, -3): (0, 1), (9, 9, 5, -2): (0, 1), (9, 9, 5, -1): (0, 1), (9, 9, 5, 0): (0, 1), (9, 9, 5, 1): (0, 1), (9, 9, 5, 2): (0, 1), (9, 9, 5, 3): (0, 1), (9, 9, 5, 4): (0, 1), (9, 9, 5, 5): (0, 1), (9, 10, -5, -5): (0, 1), (9, 10, -5, -4): (0, 1), (9, 10, -5, -3): (0, 1), (9, 10, -5, -2): (0, 1), (9, 10, -5, -1): (0, 1), (9, 10, -5, 0): (0, 1), (9, 10, -5, 1): (0, 1), (9, 10, -5, 2): (0, 1), (9, 10, -5, 3): (0, 1), (9, 10, -5, 4): (0, 1), (9, 10, -5, 5): (0, 1), (9, 10, -4, -5): (0, 1), (9, 10, -4, -4): (0, 1), (9, 10, -4, -3): (0, 1), (9, 10, -4, -2): (0, 1), (9, 10, -4, -1): (0, 1), (9, 10, -4, 0): (0, 1), (9, 10, -4, 1): (0, 1), (9, 10, -4, 2): (0, 1), (9, 10, -4, 3): (1, 1), (9, 10, -4, 4): (1, 1), (9, 10, -4, 5): (1, 0), (9, 10, -3, -5): (-1, 1), (9, 10, -3, -4): (-1, 1), (9, 10, -3, -3): (-1, 1), (9, 10, -3, -2): (-1, 1), (9, 10, -3, -1): (-1, 1), (9, 10, -3, 0): (1, 1), (9, 10, -3, 1): (1, 1), (9, 10, -3, 2): (1, 1), (9, 10, -3, 3): (1, 1), (9, 10, -3, 4): (1, 1), (9, 10, -3, 5): (1, 0), (9, 10, -2, -5): (-1, 0), (9, 10, -2, -4): (0, 1), (9, 10, -2, -3): (0, 1), (9, 10, -2, -2): (0, 1), (9, 10, -2, -1): (1, 1), (9, 10, -2, 0): (1, 1), (9, 10, -2, 1): (1, 1), (9, 10, -2, 2): (1, 1), (9, 10, -2, 3): (1, 1), (9, 10, -2, 4): (1, 1), (9, 10, -2, 5): (1, 0), (9, 10, -1, -5): (-1, 1), (9, 10, -1, -4): (-1, 1), (9, 10, -1, -3): (-1, 1), (9, 10, -1, -2): (-1, 1), (9, 10, -1, -1): (1, 1), (9, 10, -1, 0): (1, 1), (9, 10, -1, 1): (1, 1), (9, 10, -1, 2): (1, 1), (9, 10, -1, 3): (1, 1), (9, 10, -1, 4): (1, 1), (9, 10, -1, 5): (1, 0), (9, 10, 0, -5): (1, 1), (9, 10, 0, -4): (1, 1), (9, 10, 0, -3): (1, 1), (9, 10, 0, -2): (1, 1), (9, 10, 0, -1): (0, 1), (9, 10, 0, 0): (0, 1), (9, 10, 0, 1): (0, 1), (9, 10, 0, 2): (0, 1), (9, 10, 0, 3): (0, 1), (9, 10, 0, 4): (0, 1), (9, 10, 0, 5): (0, 1), (9, 10, 1, -5): (0, 1), (9, 10, 1, -4): (0, 1), (9, 10, 1, -3): (0, 1), (9, 10, 1, -2): (0, 1), (9, 10, 1, -1): (0, 1), (9, 10, 1, 0): (-1, 1), (9, 10, 1, 1): (-1, 1), (9, 10, 1, 2): (-1, 1), (9, 10, 1, 3): (-1, 1), (9, 10, 1, 4): (-1, 1), (9, 10, 1, 5): (-1, 1), (9, 10, 2, -5): (0, 1), (9, 10, 2, -4): (0, 1), (9, 10, 2, -3): (0, 1), (9, 10, 2, -2): (0, 1), (9, 10, 2, -1): (0, 1), (9, 10, 2, 0): (0, 1), (9, 10, 2, 1): (0, 1), (9, 10, 2, 2): (0, 1), (9, 10, 2, 3): (0, 1), (9, 10, 2, 4): (0, 1), (9, 10, 2, 5): (0, 1), (9, 10, 3, -5): (0, 1), (9, 10, 3, -4): (0, 1), (9, 10, 3, -3): (0, 1), (9, 10, 3, -2): (0, 1), (9, 10, 3, -1): (0, 1), (9, 10, 3, 0): (0, 1), (9, 10, 3, 1): (0, 1), (9, 10, 3, 2): (0, 1), (9, 10, 3, 3): (0, 1), (9, 10, 3, 4): (0, 1), (9, 10, 3, 5): (0, 1), (9, 10, 4, -5): (0, 1), (9, 10, 4, -4): (0, 1), (9, 10, 4, -3): (0, 1), (9, 10, 4, -2): (0, 1), (9, 10, 4, -1): (0, 1), (9, 10, 4, 0): (0, 1), (9, 10, 4, 1): (0, 1), (9, 10, 4, 2): (0, 1), (9, 10, 4, 3): (0, 1), (9, 10, 4, 4): (0, 1), (9, 10, 4, 5): (0, 1), (9, 10, 5, -5): (0, 1), (9, 10, 5, -4): (0, 1), (9, 10, 5, -3): (0, 1), (9, 10, 5, -2): (0, 1), (9, 10, 5, -1): (0, 1), (9, 10, 5, 0): (0, 1), (9, 10, 5, 1): (0, 1), (9, 10, 5, 2): (0, 1), (9, 10, 5, 3): (0, 1), (9, 10, 5, 4): (0, 1), (9, 10, 5, 5): (0, 1), (9, 11, -5, -5): (0, 1), (9, 11, -5, -4): (0, 1), (9, 11, -5, -3): (0, 1), (9, 11, -5, -2): (0, 1), (9, 11, -5, -1): (0, 1), (9, 11, -5, 0): (0, 1), (9, 11, -5, 1): (0, 1), (9, 11, -5, 2): (0, 1), (9, 11, -5, 3): (0, 1), (9, 11, -5, 4): (0, 1), (9, 11, -5, 5): (0, 1), (9, 11, -4, -5): (0, 1), (9, 11, -4, -4): (0, 1), (9, 11, -4, -3): (0, 1), (9, 11, -4, -2): (0, 1), (9, 11, -4, -1): (0, 1), (9, 11, -4, 0): (0, 1), (9, 11, -4, 1): (0, 1), (9, 11, -4, 2): (0, 1), (9, 11, -4, 3): (1, 1), (9, 11, -4, 4): (1, 1), (9, 11, -4, 5): (1, 0), (9, 11, -3, -5): (-1, 1), (9, 11, -3, -4): (-1, 1), (9, 11, -3, -3): (-1, 1), (9, 11, -3, -2): (-1, 1), (9, 11, -3, -1): (-1, 1), (9, 11, -3, 0): (1, 1), (9, 11, -3, 1): (1, 1), (9, 11, -3, 2): (1, 1), (9, 11, -3, 3): (1, 1), (9, 11, -3, 4): (1, 1), (9, 11, -3, 5): (1, 0), (9, 11, -2, -5): (0, 1), (9, 11, -2, -4): (0, 1), (9, 11, -2, -3): (0, 1), (9, 11, -2, -2): (0, 1), (9, 11, -2, -1): (1, 1), (9, 11, -2, 0): (1, 1), (9, 11, -2, 1): (1, 1), (9, 11, -2, 2): (1, 1), (9, 11, -2, 3): (1, 1), (9, 11, -2, 4): (1, 1), (9, 11, -2, 5): (1, 0), (9, 11, -1, -5): (-1, 1), (9, 11, -1, -4): (-1, 1), (9, 11, -1, -3): (-1, 1), (9, 11, -1, -2): (-1, 1), (9, 11, -1, -1): (1, 1), (9, 11, -1, 0): (1, 1), (9, 11, -1, 1): (1, 1), (9, 11, -1, 2): (1, 1), (9, 11, -1, 3): (1, 1), (9, 11, -1, 4): (1, 1), (9, 11, -1, 5): (1, 0), (9, 11, 0, -5): (1, 1), (9, 11, 0, -4): (1, 1), (9, 11, 0, -3): (1, 1), (9, 11, 0, -2): (1, 1), (9, 11, 0, -1): (0, 1), (9, 11, 0, 0): (0, 1), (9, 11, 0, 1): (0, 1), (9, 11, 0, 2): (0, 1), (9, 11, 0, 3): (0, 1), (9, 11, 0, 4): (0, 1), (9, 11, 0, 5): (0, 1), (9, 11, 1, -5): (0, 1), (9, 11, 1, -4): (0, 1), (9, 11, 1, -3): (0, 1), (9, 11, 1, -2): (0, 1), (9, 11, 1, -1): (0, 1), (9, 11, 1, 0): (-1, 1), (9, 11, 1, 1): (-1, 1), (9, 11, 1, 2): (-1, 1), (9, 11, 1, 3): (-1, 1), (9, 11, 1, 4): (-1, 1), (9, 11, 1, 5): (-1, 1), (9, 11, 2, -5): (0, 1), (9, 11, 2, -4): (0, 1), (9, 11, 2, -3): (0, 1), (9, 11, 2, -2): (0, 1), (9, 11, 2, -1): (0, 1), (9, 11, 2, 0): (0, 1), (9, 11, 2, 1): (0, 1), (9, 11, 2, 2): (0, 1), (9, 11, 2, 3): (0, 1), (9, 11, 2, 4): (0, 1), (9, 11, 2, 5): (0, 1), (9, 11, 3, -5): (0, 1), (9, 11, 3, -4): (0, 1), (9, 11, 3, -3): (0, 1), (9, 11, 3, -2): (0, 1), (9, 11, 3, -1): (0, 1), (9, 11, 3, 0): (0, 1), (9, 11, 3, 1): (0, 1), (9, 11, 3, 2): (0, 1), (9, 11, 3, 3): (0, 1), (9, 11, 3, 4): (0, 1), (9, 11, 3, 5): (0, 1), (9, 11, 4, -5): (0, 1), (9, 11, 4, -4): (0, 1), (9, 11, 4, -3): (0, 1), (9, 11, 4, -2): (0, 1), (9, 11, 4, -1): (0, 1), (9, 11, 4, 0): (0, 1), (9, 11, 4, 1): (0, 1), (9, 11, 4, 2): (0, 1), (9, 11, 4, 3): (0, 1), (9, 11, 4, 4): (0, 1), (9, 11, 4, 5): (0, 1), (9, 11, 5, -5): (0, 1), (9, 11, 5, -4): (0, 1), (9, 11, 5, -3): (0, 1), (9, 11, 5, -2): (0, 1), (9, 11, 5, -1): (0, 1), (9, 11, 5, 0): (0, 1), (9, 11, 5, 1): (0, 1), (9, 11, 5, 2): (0, 1), (9, 11, 5, 3): (0, 1), (9, 11, 5, 4): (0, 1), (9, 11, 5, 5): (0, 1), (9, 12, -5, -5): (0, 1), (9, 12, -5, -4): (0, 1), (9, 12, -5, -3): (0, 1), (9, 12, -5, -2): (0, 1), (9, 12, -5, -1): (0, 1), (9, 12, -5, 0): (0, 1), (9, 12, -5, 1): (0, 1), (9, 12, -5, 2): (0, 1), (9, 12, -5, 3): (0, 1), (9, 12, -5, 4): (0, 1), (9, 12, -5, 5): (0, 1), (9, 12, -4, -5): (0, 1), (9, 12, -4, -4): (0, 1), (9, 12, -4, -3): (0, 1), (9, 12, -4, -2): (0, 1), (9, 12, -4, -1): (0, 1), (9, 12, -4, 0): (0, 1), (9, 12, -4, 1): (0, 1), (9, 12, -4, 2): (0, 1), (9, 12, -4, 3): (1, 1), (9, 12, -4, 4): (1, 1), (9, 12, -4, 5): (1, 0), (9, 12, -3, -5): (-1, 1), (9, 12, -3, -4): (-1, 1), (9, 12, -3, -3): (-1, 1), (9, 12, -3, -2): (-1, 1), (9, 12, -3, -1): (-1, 1), (9, 12, -3, 0): (-1, 1), (9, 12, -3, 1): (1, 1), (9, 12, -3, 2): (1, 1), (9, 12, -3, 3): (1, 1), (9, 12, -3, 4): (1, 1), (9, 12, -3, 5): (1, 0), (9, 12, -2, -5): (0, 1), (9, 12, -2, -4): (0, 1), (9, 12, -2, -3): (0, 1), (9, 12, -2, -2): (0, 1), (9, 12, -2, -1): (1, 1), (9, 12, -2, 0): (1, 1), (9, 12, -2, 1): (1, 1), (9, 12, -2, 2): (1, 1), (9, 12, -2, 3): (1, 1), (9, 12, -2, 4): (1, 1), (9, 12, -2, 5): (1, 0), (9, 12, -1, -5): (-1, 1), (9, 12, -1, -4): (-1, 1), (9, 12, -1, -3): (-1, 1), (9, 12, -1, -2): (-1, 1), (9, 12, -1, -1): (1, 1), (9, 12, -1, 0): (1, 1), (9, 12, -1, 1): (1, 1), (9, 12, -1, 2): (1, 1), (9, 12, -1, 3): (1, 1), (9, 12, -1, 4): (1, 1), (9, 12, -1, 5): (1, 0), (9, 12, 0, -5): (1, 1), (9, 12, 0, -4): (1, 1), (9, 12, 0, -3): (1, 1), (9, 12, 0, -2): (1, 1), (9, 12, 0, -1): (0, 1), (9, 12, 0, 0): (0, 1), (9, 12, 0, 1): (0, 1), (9, 12, 0, 2): (0, 1), (9, 12, 0, 3): (0, 1), (9, 12, 0, 4): (0, 1), (9, 12, 0, 5): (0, 1), (9, 12, 1, -5): (0, 1), (9, 12, 1, -4): (0, 1), (9, 12, 1, -3): (0, 1), (9, 12, 1, -2): (0, 1), (9, 12, 1, -1): (0, 1), (9, 12, 1, 0): (-1, 1), (9, 12, 1, 1): (-1, 1), (9, 12, 1, 2): (-1, 1), (9, 12, 1, 3): (-1, 1), (9, 12, 1, 4): (-1, 1), (9, 12, 1, 5): (-1, 1), (9, 12, 2, -5): (0, 1), (9, 12, 2, -4): (0, 1), (9, 12, 2, -3): (0, 1), (9, 12, 2, -2): (0, 1), (9, 12, 2, -1): (0, 1), (9, 12, 2, 0): (0, 1), (9, 12, 2, 1): (0, 1), (9, 12, 2, 2): (0, 1), (9, 12, 2, 3): (0, 1), (9, 12, 2, 4): (0, 1), (9, 12, 2, 5): (0, 1), (9, 12, 3, -5): (0, 1), (9, 12, 3, -4): (0, 1), (9, 12, 3, -3): (0, 1), (9, 12, 3, -2): (0, 1), (9, 12, 3, -1): (0, 1), (9, 12, 3, 0): (0, 1), (9, 12, 3, 1): (0, 1), (9, 12, 3, 2): (0, 1), (9, 12, 3, 3): (0, 1), (9, 12, 3, 4): (0, 1), (9, 12, 3, 5): (0, 1), (9, 12, 4, -5): (0, 1), (9, 12, 4, -4): (0, 1), (9, 12, 4, -3): (0, 1), (9, 12, 4, -2): (0, 1), (9, 12, 4, -1): (0, 1), (9, 12, 4, 0): (0, 1), (9, 12, 4, 1): (0, 1), (9, 12, 4, 2): (0, 1), (9, 12, 4, 3): (0, 1), (9, 12, 4, 4): (0, 1), (9, 12, 4, 5): (0, 1), (9, 12, 5, -5): (0, 1), (9, 12, 5, -4): (0, 1), (9, 12, 5, -3): (0, 1), (9, 12, 5, -2): (0, 1), (9, 12, 5, -1): (0, 1), (9, 12, 5, 0): (0, 1), (9, 12, 5, 1): (0, 1), (9, 12, 5, 2): (0, 1), (9, 12, 5, 3): (0, 1), (9, 12, 5, 4): (0, 1), (9, 12, 5, 5): (0, 1), (9, 13, -5, -5): (0, 1), (9, 13, -5, -4): (0, 1), (9, 13, -5, -3): (0, 1), (9, 13, -5, -2): (0, 1), (9, 13, -5, -1): (0, 1), (9, 13, -5, 0): (0, 1), (9, 13, -5, 1): (0, 1), (9, 13, -5, 2): (0, 1), (9, 13, -5, 3): (0, 1), (9, 13, -5, 4): (0, 1), (9, 13, -5, 5): (0, 1), (9, 13, -4, -5): (0, 1), (9, 13, -4, -4): (0, 1), (9, 13, -4, -3): (0, 1), (9, 13, -4, -2): (0, 1), (9, 13, -4, -1): (0, 1), (9, 13, -4, 0): (0, 1), (9, 13, -4, 1): (0, 1), (9, 13, -4, 2): (0, 1), (9, 13, -4, 3): (1, 1), (9, 13, -4, 4): (1, 1), (9, 13, -4, 5): (1, 0), (9, 13, -3, -5): (-1, 1), (9, 13, -3, -4): (-1, 1), (9, 13, -3, -3): (-1, 1), (9, 13, -3, -2): (-1, 1), (9, 13, -3, -1): (-1, 1), (9, 13, -3, 0): (-1, 1), (9, 13, -3, 1): (1, 1), (9, 13, -3, 2): (1, 1), (9, 13, -3, 3): (1, 1), (9, 13, -3, 4): (1, 1), (9, 13, -3, 5): (1, 0), (9, 13, -2, -5): (0, 1), (9, 13, -2, -4): (0, 1), (9, 13, -2, -3): (0, 1), (9, 13, -2, -2): (0, 1), (9, 13, -2, -1): (1, 1), (9, 13, -2, 0): (1, 1), (9, 13, -2, 1): (1, 1), (9, 13, -2, 2): (1, 1), (9, 13, -2, 3): (1, 1), (9, 13, -2, 4): (1, 1), (9, 13, -2, 5): (1, 0), (9, 13, -1, -5): (-1, 1), (9, 13, -1, -4): (-1, 1), (9, 13, -1, -3): (-1, 1), (9, 13, -1, -2): (-1, 1), (9, 13, -1, -1): (1, 1), (9, 13, -1, 0): (1, 1), (9, 13, -1, 1): (1, 1), (9, 13, -1, 2): (1, 1), (9, 13, -1, 3): (1, 1), (9, 13, -1, 4): (0, 1), (9, 13, -1, 5): (0, 1), (9, 13, 0, -5): (1, 1), (9, 13, 0, -4): (1, 1), (9, 13, 0, -3): (1, 1), (9, 13, 0, -2): (1, 1), (9, 13, 0, -1): (0, 1), (9, 13, 0, 0): (0, 1), (9, 13, 0, 1): (0, 1), (9, 13, 0, 2): (0, 1), (9, 13, 0, 3): (0, 1), (9, 13, 0, 4): (-1, 1), (9, 13, 0, 5): (-1, 1), (9, 13, 1, -5): (0, 1), (9, 13, 1, -4): (0, 1), (9, 13, 1, -3): (0, 1), (9, 13, 1, -2): (0, 1), (9, 13, 1, -1): (0, 1), (9, 13, 1, 0): (-1, 1), (9, 13, 1, 1): (-1, 1), (9, 13, 1, 2): (-1, 1), (9, 13, 1, 3): (-1, 1), (9, 13, 1, 4): (-1, 1), (9, 13, 1, 5): (-1, 1), (9, 13, 2, -5): (0, 1), (9, 13, 2, -4): (0, 1), (9, 13, 2, -3): (0, 1), (9, 13, 2, -2): (0, 1), (9, 13, 2, -1): (0, 1), (9, 13, 2, 0): (0, 1), (9, 13, 2, 1): (0, 1), (9, 13, 2, 2): (0, 1), (9, 13, 2, 3): (0, 1), (9, 13, 2, 4): (0, 1), (9, 13, 2, 5): (0, 1), (9, 13, 3, -5): (0, 1), (9, 13, 3, -4): (0, 1), (9, 13, 3, -3): (0, 1), (9, 13, 3, -2): (0, 1), (9, 13, 3, -1): (0, 1), (9, 13, 3, 0): (0, 1), (9, 13, 3, 1): (0, 1), (9, 13, 3, 2): (0, 1), (9, 13, 3, 3): (0, 1), (9, 13, 3, 4): (0, 1), (9, 13, 3, 5): (0, 1), (9, 13, 4, -5): (0, 1), (9, 13, 4, -4): (0, 1), (9, 13, 4, -3): (0, 1), (9, 13, 4, -2): (0, 1), (9, 13, 4, -1): (0, 1), (9, 13, 4, 0): (0, 1), (9, 13, 4, 1): (0, 1), (9, 13, 4, 2): (0, 1), (9, 13, 4, 3): (0, 1), (9, 13, 4, 4): (0, 1), (9, 13, 4, 5): (0, 1), (9, 13, 5, -5): (0, 1), (9, 13, 5, -4): (0, 1), (9, 13, 5, -3): (0, 1), (9, 13, 5, -2): (0, 1), (9, 13, 5, -1): (0, 1), (9, 13, 5, 0): (0, 1), (9, 13, 5, 1): (0, 1), (9, 13, 5, 2): (0, 1), (9, 13, 5, 3): (0, 1), (9, 13, 5, 4): (0, 1), (9, 13, 5, 5): (0, 1), (9, 14, -5, -5): (0, 1), (9, 14, -5, -4): (0, 1), (9, 14, -5, -3): (0, 1), (9, 14, -5, -2): (0, 1), (9, 14, -5, -1): (0, 1), (9, 14, -5, 0): (0, 1), (9, 14, -5, 1): (0, 1), (9, 14, -5, 2): (0, 1), (9, 14, -5, 3): (0, 1), (9, 14, -5, 4): (0, 0), (9, 14, -5, 5): (-1, -1), (9, 14, -4, -5): (0, 1), (9, 14, -4, -4): (0, 1), (9, 14, -4, -3): (0, 1), (9, 14, -4, -2): (0, 1), (9, 14, -4, -1): (0, 1), (9, 14, -4, 0): (0, 1), (9, 14, -4, 1): (0, 1), (9, 14, -4, 2): (0, 1), (9, 14, -4, 3): (1, 1), (9, 14, -4, 4): (1, 1), (9, 14, -4, 5): (1, 0), (9, 14, -3, -5): (-1, 1), (9, 14, -3, -4): (-1, 1), (9, 14, -3, -3): (-1, 1), (9, 14, -3, -2): (-1, 1), (9, 14, -3, -1): (-1, 1), (9, 14, -3, 0): (-1, 1), (9, 14, -3, 1): (1, 1), (9, 14, -3, 2): (1, 1), (9, 14, -3, 3): (1, 1), (9, 14, -3, 4): (1, 1), (9, 14, -3, 5): (1, 0), (9, 14, -2, -5): (0, 1), (9, 14, -2, -4): (0, 1), (9, 14, -2, -3): (0, 1), (9, 14, -2, -2): (0, 1), (9, 14, -2, -1): (1, 1), (9, 14, -2, 0): (1, 1), (9, 14, -2, 1): (1, 1), (9, 14, -2, 2): (1, 1), (9, 14, -2, 3): (1, 1), (9, 14, -2, 4): (1, 1), (9, 14, -2, 5): (1, 0), (9, 14, -1, -5): (-1, 1), (9, 14, -1, -4): (-1, 1), (9, 14, -1, -3): (-1, 1), (9, 14, -1, -2): (-1, 1), (9, 14, -1, -1): (1, 1), (9, 14, -1, 0): (1, 1), (9, 14, -1, 1): (1, 1), (9, 14, -1, 2): (1, 1), (9, 14, -1, 3): (0, 1), (9, 14, -1, 4): (0, 1), (9, 14, -1, 5): (0, 1), (9, 14, 0, -5): (1, 1), (9, 14, 0, -4): (1, 1), (9, 14, 0, -3): (1, 1), (9, 14, 0, -2): (1, 1), (9, 14, 0, -1): (0, 1), (9, 14, 0, 0): (0, 1), (9, 14, 0, 1): (0, 1), (9, 14, 0, 2): (0, 1), (9, 14, 0, 3): (-1, 1), (9, 14, 0, 4): (-1, 1), (9, 14, 0, 5): (-1, 1), (9, 14, 1, -5): (0, 1), (9, 14, 1, -4): (0, 1), (9, 14, 1, -3): (0, 1), (9, 14, 1, -2): (0, 1), (9, 14, 1, -1): (0, 1), (9, 14, 1, 0): (-1, 1), (9, 14, 1, 1): (-1, 1), (9, 14, 1, 2): (-1, 1), (9, 14, 1, 3): (-1, 1), (9, 14, 1, 4): (-1, 1), (9, 14, 1, 5): (-1, 1), (9, 14, 2, -5): (0, 1), (9, 14, 2, -4): (0, 1), (9, 14, 2, -3): (0, 1), (9, 14, 2, -2): (0, 1), (9, 14, 2, -1): (0, 1), (9, 14, 2, 0): (0, 1), (9, 14, 2, 1): (0, 1), (9, 14, 2, 2): (0, 1), (9, 14, 2, 3): (0, 1), (9, 14, 2, 4): (0, 0), (9, 14, 2, 5): (-1, -1), (9, 14, 3, -5): (0, 1), (9, 14, 3, -4): (0, 1), (9, 14, 3, -3): (0, 1), (9, 14, 3, -2): (0, 1), (9, 14, 3, -1): (0, 1), (9, 14, 3, 0): (0, 1), (9, 14, 3, 1): (0, 1), (9, 14, 3, 2): (0, 1), (9, 14, 3, 3): (0, 1), (9, 14, 3, 4): (0, 0), (9, 14, 3, 5): (-1, -1), (9, 14, 4, -5): (0, 1), (9, 14, 4, -4): (0, 1), (9, 14, 4, -3): (0, 1), (9, 14, 4, -2): (0, 1), (9, 14, 4, -1): (0, 1), (9, 14, 4, 0): (0, 1), (9, 14, 4, 1): (0, 1), (9, 14, 4, 2): (0, 1), (9, 14, 4, 3): (0, 1), (9, 14, 4, 4): (0, 0), (9, 14, 4, 5): (-1, -1), (9, 14, 5, -5): (0, 1), (9, 14, 5, -4): (0, 1), (9, 14, 5, -3): (0, 1), (9, 14, 5, -2): (0, 1), (9, 14, 5, -1): (0, 1), (9, 14, 5, 0): (0, 1), (9, 14, 5, 1): (0, 1), (9, 14, 5, 2): (0, 1), (9, 14, 5, 3): (0, 1), (9, 14, 5, 4): (0, 0), (9, 14, 5, 5): (-1, -1), (9, 15, -5, -5): (0, 1), (9, 15, -5, -4): (0, 1), (9, 15, -5, -3): (0, 1), (9, 15, -5, -2): (0, 1), (9, 15, -5, -1): (0, 1), (9, 15, -5, 0): (0, 1), (9, 15, -5, 1): (0, 1), (9, 15, -5, 2): (0, 1), (9, 15, -5, 3): (0, 0), (9, 15, -5, 4): (0, 1), (9, 15, -5, 5): (0, 1), (9, 15, -4, -5): (0, 1), (9, 15, -4, -4): (0, 1), (9, 15, -4, -3): (0, 1), (9, 15, -4, -2): (0, 1), (9, 15, -4, -1): (0, 1), (9, 15, -4, 0): (0, 1), (9, 15, -4, 1): (0, 1), (9, 15, -4, 2): (0, 1), (9, 15, -4, 3): (1, 1), (9, 15, -4, 4): (0, 1), (9, 15, -4, 5): (0, 1), (9, 15, -3, -5): (-1, 1), (9, 15, -3, -4): (-1, 1), (9, 15, -3, -3): (-1, 1), (9, 15, -3, -2): (-1, 1), (9, 15, -3, -1): (-1, 1), (9, 15, -3, 0): (-1, 1), (9, 15, -3, 1): (1, 1), (9, 15, -3, 2): (1, 1), (9, 15, -3, 3): (1, 1), (9, 15, -3, 4): (1, 1), (9, 15, -3, 5): (1, 0), (9, 15, -2, -5): (0, 1), (9, 15, -2, -4): (0, 1), (9, 15, -2, -3): (0, 1), (9, 15, -2, -2): (0, 1), (9, 15, -2, -1): (1, 1), (9, 15, -2, 0): (1, 1), (9, 15, -2, 1): (1, 1), (9, 15, -2, 2): (1, 1), (9, 15, -2, 3): (1, 1), (9, 15, -2, 4): (1, 1), (9, 15, -2, 5): (1, 0), (9, 15, -1, -5): (-1, 1), (9, 15, -1, -4): (-1, 1), (9, 15, -1, -3): (-1, 1), (9, 15, -1, -2): (-1, 1), (9, 15, -1, -1): (1, 1), (9, 15, -1, 0): (1, 1), (9, 15, -1, 1): (1, 1), (9, 15, -1, 2): (1, 1), (9, 15, -1, 3): (1, 1), (9, 15, -1, 4): (0, 1), (9, 15, -1, 5): (0, 1), (9, 15, 0, -5): (1, 1), (9, 15, 0, -4): (1, 1), (9, 15, 0, -3): (1, 1), (9, 15, 0, -2): (1, 1), (9, 15, 0, -1): (0, 1), (9, 15, 0, 0): (0, 1), (9, 15, 0, 1): (0, 1), (9, 15, 0, 2): (0, 1), (9, 15, 0, 3): (0, 1), (9, 15, 0, 4): (-1, 1), (9, 15, 0, 5): (-1, 1), (9, 15, 1, -5): (0, 1), (9, 15, 1, -4): (0, 1), (9, 15, 1, -3): (0, 1), (9, 15, 1, -2): (0, 1), (9, 15, 1, -1): (0, 1), (9, 15, 1, 0): (-1, 1), (9, 15, 1, 1): (-1, 1), (9, 15, 1, 2): (-1, 1), (9, 15, 1, 3): (-1, 1), (9, 15, 1, 4): (-1, 0), (9, 15, 1, 5): (-1, -1), (9, 15, 2, -5): (0, 1), (9, 15, 2, -4): (0, 1), (9, 15, 2, -3): (0, 1), (9, 15, 2, -2): (0, 1), (9, 15, 2, -1): (0, 1), (9, 15, 2, 0): (0, 1), (9, 15, 2, 1): (0, 1), (9, 15, 2, 2): (0, 1), (9, 15, 2, 3): (0, 0), (9, 15, 2, 4): (0, 1), (9, 15, 2, 5): (0, 1), (9, 15, 3, -5): (0, 1), (9, 15, 3, -4): (0, 1), (9, 15, 3, -3): (0, 1), (9, 15, 3, -2): (0, 1), (9, 15, 3, -1): (0, 1), (9, 15, 3, 0): (0, 1), (9, 15, 3, 1): (0, 1), (9, 15, 3, 2): (0, 1), (9, 15, 3, 3): (0, 0), (9, 15, 3, 4): (0, 1), (9, 15, 3, 5): (0, 1), (9, 15, 4, -5): (0, 1), (9, 15, 4, -4): (0, 1), (9, 15, 4, -3): (0, 1), (9, 15, 4, -2): (0, 1), (9, 15, 4, -1): (0, 1), (9, 15, 4, 0): (0, 1), (9, 15, 4, 1): (0, 1), (9, 15, 4, 2): (0, 1), (9, 15, 4, 3): (0, 0), (9, 15, 4, 4): (0, 1), (9, 15, 4, 5): (0, 1), (9, 15, 5, -5): (0, 1), (9, 15, 5, -4): (0, 1), (9, 15, 5, -3): (0, 1), (9, 15, 5, -2): (0, 1), (9, 15, 5, -1): (0, 1), (9, 15, 5, 0): (0, 1), (9, 15, 5, 1): (0, 1), (9, 15, 5, 2): (0, 1), (9, 15, 5, 3): (0, 0), (9, 15, 5, 4): (0, 1), (9, 15, 5, 5): (0, 1), (9, 16, -5, -5): (0, 1), (9, 16, -5, -4): (0, 1), (9, 16, -5, -3): (0, 1), (9, 16, -5, -2): (0, 1), (9, 16, -5, -1): (0, 1), (9, 16, -5, 0): (0, 1), (9, 16, -5, 1): (0, 1), (9, 16, -5, 2): (0, 0), (9, 16, -5, 3): (0, 1), (9, 16, -5, 4): (0, 1), (9, 16, -5, 5): (0, 1), (9, 16, -4, -5): (0, 1), (9, 16, -4, -4): (0, 1), (9, 16, -4, -3): (0, 1), (9, 16, -4, -2): (0, 1), (9, 16, -4, -1): (0, 1), (9, 16, -4, 0): (0, 1), (9, 16, -4, 1): (0, 1), (9, 16, -4, 2): (1, 1), (9, 16, -4, 3): (0, 1), (9, 16, -4, 4): (1, 1), (9, 16, -4, 5): (1, 0), (9, 16, -3, -5): (-1, 1), (9, 16, -3, -4): (-1, 1), (9, 16, -3, -3): (-1, 1), (9, 16, -3, -2): (-1, 1), (9, 16, -3, -1): (-1, 1), (9, 16, -3, 0): (-1, 1), (9, 16, -3, 1): (1, 1), (9, 16, -3, 2): (1, 1), (9, 16, -3, 3): (1, 1), (9, 16, -3, 4): (1, 1), (9, 16, -3, 5): (1, 0), (9, 16, -2, -5): (0, 1), (9, 16, -2, -4): (0, 1), (9, 16, -2, -3): (0, 1), (9, 16, -2, -2): (0, 1), (9, 16, -2, -1): (1, 1), (9, 16, -2, 0): (1, 1), (9, 16, -2, 1): (1, 1), (9, 16, -2, 2): (1, 1), (9, 16, -2, 3): (1, 1), (9, 16, -2, 4): (1, 1), (9, 16, -2, 5): (1, 0), (9, 16, -1, -5): (-1, 1), (9, 16, -1, -4): (-1, 1), (9, 16, -1, -3): (-1, 1), (9, 16, -1, -2): (-1, 1), (9, 16, -1, -1): (1, 1), (9, 16, -1, 0): (1, 1), (9, 16, -1, 1): (1, 1), (9, 16, -1, 2): (1, 1), (9, 16, -1, 3): (0, 1), (9, 16, -1, 4): (0, 1), (9, 16, -1, 5): (0, 1), (9, 16, 0, -5): (1, 1), (9, 16, 0, -4): (1, 1), (9, 16, 0, -3): (1, 1), (9, 16, 0, -2): (1, 1), (9, 16, 0, -1): (0, 1), (9, 16, 0, 0): (0, 1), (9, 16, 0, 1): (0, 1), (9, 16, 0, 2): (0, 1), (9, 16, 0, 3): (-1, 1), (9, 16, 0, 4): (-1, 1), (9, 16, 0, 5): (-1, 1), (9, 16, 1, -5): (0, 1), (9, 16, 1, -4): (0, 1), (9, 16, 1, -3): (0, 1), (9, 16, 1, -2): (0, 1), (9, 16, 1, -1): (0, 1), (9, 16, 1, 0): (-1, 1), (9, 16, 1, 1): (-1, 1), (9, 16, 1, 2): (-1, 1), (9, 16, 1, 3): (-1, 1), (9, 16, 1, 4): (-1, 0), (9, 16, 1, 5): (-1, -1), (9, 16, 2, -5): (0, 1), (9, 16, 2, -4): (0, 1), (9, 16, 2, -3): (0, 1), (9, 16, 2, -2): (0, 1), (9, 16, 2, -1): (0, 1), (9, 16, 2, 0): (0, 1), (9, 16, 2, 1): (0, 1), (9, 16, 2, 2): (0, 0), (9, 16, 2, 3): (0, 1), (9, 16, 2, 4): (0, 1), (9, 16, 2, 5): (0, 1), (9, 16, 3, -5): (0, 1), (9, 16, 3, -4): (0, 1), (9, 16, 3, -3): (0, 1), (9, 16, 3, -2): (0, 1), (9, 16, 3, -1): (0, 1), (9, 16, 3, 0): (0, 1), (9, 16, 3, 1): (0, 1), (9, 16, 3, 2): (0, 0), (9, 16, 3, 3): (0, 1), (9, 16, 3, 4): (0, 1), (9, 16, 3, 5): (0, 1), (9, 16, 4, -5): (0, 1), (9, 16, 4, -4): (0, 1), (9, 16, 4, -3): (0, 1), (9, 16, 4, -2): (0, 1), (9, 16, 4, -1): (0, 1), (9, 16, 4, 0): (0, 1), (9, 16, 4, 1): (0, 1), (9, 16, 4, 2): (0, 0), (9, 16, 4, 3): (0, 1), (9, 16, 4, 4): (0, 1), (9, 16, 4, 5): (0, 1), (9, 16, 5, -5): (0, 1), (9, 16, 5, -4): (0, 1), (9, 16, 5, -3): (0, 1), (9, 16, 5, -2): (0, 1), (9, 16, 5, -1): (0, 1), (9, 16, 5, 0): (0, 1), (9, 16, 5, 1): (0, 1), (9, 16, 5, 2): (0, 0), (9, 16, 5, 3): (0, 1), (9, 16, 5, 4): (0, 1), (9, 16, 5, 5): (0, 1), (9, 17, -5, -5): (0, 1), (9, 17, -5, -4): (0, 1), (9, 17, -5, -3): (0, 1), (9, 17, -5, -2): (0, 1), (9, 17, -5, -1): (0, 1), (9, 17, -5, 0): (0, 1), (9, 17, -5, 1): (0, 0), (9, 17, -5, 2): (0, 1), (9, 17, -5, 3): (0, 1), (9, 17, -5, 4): (0, 1), (9, 17, -5, 5): (0, 1), (9, 17, -4, -5): (0, 1), (9, 17, -4, -4): (0, 1), (9, 17, -4, -3): (0, 1), (9, 17, -4, -2): (0, 1), (9, 17, -4, -1): (0, 1), (9, 17, -4, 0): (0, 1), (9, 17, -4, 1): (0, 0), (9, 17, -4, 2): (0, 1), (9, 17, -4, 3): (1, 1), (9, 17, -4, 4): (0, 1), (9, 17, -4, 5): (0, 1), (9, 17, -3, -5): (-1, 1), (9, 17, -3, -4): (-1, 1), (9, 17, -3, -3): (-1, 1), (9, 17, -3, -2): (-1, 1), (9, 17, -3, -1): (-1, 1), (9, 17, -3, 0): (-1, 1), (9, 17, -3, 1): (1, 1), (9, 17, -3, 2): (1, 1), (9, 17, -3, 3): (1, 1), (9, 17, -3, 4): (1, 1), (9, 17, -3, 5): (1, 0), (9, 17, -2, -5): (0, 1), (9, 17, -2, -4): (0, 1), (9, 17, -2, -3): (0, 1), (9, 17, -2, -2): (0, 1), (9, 17, -2, -1): (1, 1), (9, 17, -2, 0): (1, 1), (9, 17, -2, 1): (1, 1), (9, 17, -2, 2): (1, 1), (9, 17, -2, 3): (1, 1), (9, 17, -2, 4): (1, 1), (9, 17, -2, 5): (1, 0), (9, 17, -1, -5): (-1, 1), (9, 17, -1, -4): (-1, 1), (9, 17, -1, -3): (-1, 1), (9, 17, -1, -2): (1, 1), (9, 17, -1, -1): (1, 1), (9, 17, -1, 0): (1, 1), (9, 17, -1, 1): (1, 1), (9, 17, -1, 2): (1, 1), (9, 17, -1, 3): (0, 1), (9, 17, -1, 4): (0, 1), (9, 17, -1, 5): (0, 1), (9, 17, 0, -5): (1, 1), (9, 17, 0, -4): (1, 1), (9, 17, 0, -3): (1, 1), (9, 17, 0, -2): (1, 1), (9, 17, 0, -1): (0, 1), (9, 17, 0, 0): (0, 1), (9, 17, 0, 1): (0, 1), (9, 17, 0, 2): (0, 1), (9, 17, 0, 3): (-1, 1), (9, 17, 0, 4): (-1, 1), (9, 17, 0, 5): (-1, 1), (9, 17, 1, -5): (0, 1), (9, 17, 1, -4): (0, 1), (9, 17, 1, -3): (0, 1), (9, 17, 1, -2): (0, 1), (9, 17, 1, -1): (0, 1), (9, 17, 1, 0): (-1, 1), (9, 17, 1, 1): (-1, 1), (9, 17, 1, 2): (-1, 1), (9, 17, 1, 3): (-1, 0), (9, 17, 1, 4): (-1, -1), (9, 17, 1, 5): (-1, -1), (9, 17, 2, -5): (0, 1), (9, 17, 2, -4): (0, 1), (9, 17, 2, -3): (0, 1), (9, 17, 2, -2): (0, 1), (9, 17, 2, -1): (0, 1), (9, 17, 2, 0): (0, 1), (9, 17, 2, 1): (0, 0), (9, 17, 2, 2): (0, 1), (9, 17, 2, 3): (0, 1), (9, 17, 2, 4): (0, 1), (9, 17, 2, 5): (0, 1), (9, 17, 3, -5): (0, 1), (9, 17, 3, -4): (0, 1), (9, 17, 3, -3): (0, 1), (9, 17, 3, -2): (0, 1), (9, 17, 3, -1): (0, 1), (9, 17, 3, 0): (0, 1), (9, 17, 3, 1): (0, 0), (9, 17, 3, 2): (0, 1), (9, 17, 3, 3): (0, 1), (9, 17, 3, 4): (0, 1), (9, 17, 3, 5): (0, 1), (9, 17, 4, -5): (0, 1), (9, 17, 4, -4): (0, 1), (9, 17, 4, -3): (0, 1), (9, 17, 4, -2): (0, 1), (9, 17, 4, -1): (0, 1), (9, 17, 4, 0): (0, 1), (9, 17, 4, 1): (0, 0), (9, 17, 4, 2): (0, 1), (9, 17, 4, 3): (0, 1), (9, 17, 4, 4): (0, 1), (9, 17, 4, 5): (0, 1), (9, 17, 5, -5): (0, 1), (9, 17, 5, -4): (0, 1), (9, 17, 5, -3): (0, 1), (9, 17, 5, -2): (0, 1), (9, 17, 5, -1): (0, 1), (9, 17, 5, 0): (0, 1), (9, 17, 5, 1): (0, 0), (9, 17, 5, 2): (0, 1), (9, 17, 5, 3): (0, 1), (9, 17, 5, 4): (0, 1), (9, 17, 5, 5): (0, 1), (9, 18, -5, -5): (0, 1), (9, 18, -5, -4): (0, 1), (9, 18, -5, -3): (0, 1), (9, 18, -5, -2): (0, 1), (9, 18, -5, -1): (0, 1), (9, 18, -5, 0): (0, 0), (9, 18, -5, 1): (0, 1), (9, 18, -5, 2): (0, 1), (9, 18, -5, 3): (0, 1), (9, 18, -5, 4): (0, 1), (9, 18, -5, 5): (0, 1), (9, 18, -4, -5): (0, 1), (9, 18, -4, -4): (0, 1), (9, 18, -4, -3): (0, 1), (9, 18, -4, -2): (0, 1), (9, 18, -4, -1): (0, 1), (9, 18, -4, 0): (0, 0), (9, 18, -4, 1): (0, 1), (9, 18, -4, 2): (0, 1), (9, 18, -4, 3): (0, 1), (9, 18, -4, 4): (0, 1), (9, 18, -4, 5): (0, 1), (9, 18, -3, -5): (-1, 1), (9, 18, -3, -4): (-1, 1), (9, 18, -3, -3): (-1, 1), (9, 18, -3, -2): (-1, 1), (9, 18, -3, -1): (-1, 1), (9, 18, -3, 0): (-1, 0), (9, 18, -3, 1): (1, 1), (9, 18, -3, 2): (1, 1), (9, 18, -3, 3): (1, 1), (9, 18, -3, 4): (1, 1), (9, 18, -3, 5): (1, 0), (9, 18, -2, -5): (0, 1), (9, 18, -2, -4): (0, 1), (9, 18, -2, -3): (0, 1), (9, 18, -2, -2): (0, 1), (9, 18, -2, -1): (1, 1), (9, 18, -2, 0): (1, 1), (9, 18, -2, 1): (1, 1), (9, 18, -2, 2): (1, 1), (9, 18, -2, 3): (1, 1), (9, 18, -2, 4): (1, 1), (9, 18, -2, 5): (1, 0), (9, 18, -1, -5): (-1, 1), (9, 18, -1, -4): (-1, 1), (9, 18, -1, -3): (-1, 1), (9, 18, -1, -2): (1, 1), (9, 18, -1, -1): (1, 1), (9, 18, -1, 0): (1, 1), (9, 18, -1, 1): (1, 1), (9, 18, -1, 2): (1, 1), (9, 18, -1, 3): (0, 1), (9, 18, -1, 4): (0, 1), (9, 18, -1, 5): (0, 1), (9, 18, 0, -5): (1, 1), (9, 18, 0, -4): (1, 1), (9, 18, 0, -3): (1, 1), (9, 18, 0, -2): (1, 1), (9, 18, 0, -1): (0, 1), (9, 18, 0, 0): (0, 1), (9, 18, 0, 1): (0, 1), (9, 18, 0, 2): (0, 1), (9, 18, 0, 3): (-1, 1), (9, 18, 0, 4): (-1, 1), (9, 18, 0, 5): (-1, 1), (9, 18, 1, -5): (0, 1), (9, 18, 1, -4): (0, 1), (9, 18, 1, -3): (0, 1), (9, 18, 1, -2): (0, 1), (9, 18, 1, -1): (0, 1), (9, 18, 1, 0): (-1, 1), (9, 18, 1, 1): (-1, 1), (9, 18, 1, 2): (-1, 1), (9, 18, 1, 3): (-1, 0), (9, 18, 1, 4): (-1, -1), (9, 18, 1, 5): (-1, -1), (9, 18, 2, -5): (0, 1), (9, 18, 2, -4): (0, 1), (9, 18, 2, -3): (0, 1), (9, 18, 2, -2): (0, 1), (9, 18, 2, -1): (0, 1), (9, 18, 2, 0): (0, 0), (9, 18, 2, 1): (0, 1), (9, 18, 2, 2): (0, 1), (9, 18, 2, 3): (0, 1), (9, 18, 2, 4): (0, 1), (9, 18, 2, 5): (0, 1), (9, 18, 3, -5): (0, 1), (9, 18, 3, -4): (0, 1), (9, 18, 3, -3): (0, 1), (9, 18, 3, -2): (0, 1), (9, 18, 3, -1): (0, 1), (9, 18, 3, 0): (0, 0), (9, 18, 3, 1): (0, 1), (9, 18, 3, 2): (0, 1), (9, 18, 3, 3): (0, 1), (9, 18, 3, 4): (0, 1), (9, 18, 3, 5): (0, 1), (9, 18, 4, -5): (0, 1), (9, 18, 4, -4): (0, 1), (9, 18, 4, -3): (0, 1), (9, 18, 4, -2): (0, 1), (9, 18, 4, -1): (0, 1), (9, 18, 4, 0): (0, 0), (9, 18, 4, 1): (0, 1), (9, 18, 4, 2): (0, 1), (9, 18, 4, 3): (0, 1), (9, 18, 4, 4): (0, 1), (9, 18, 4, 5): (0, 1), (9, 18, 5, -5): (0, 1), (9, 18, 5, -4): (0, 1), (9, 18, 5, -3): (0, 1), (9, 18, 5, -2): (0, 1), (9, 18, 5, -1): (0, 1), (9, 18, 5, 0): (0, 0), (9, 18, 5, 1): (0, 1), (9, 18, 5, 2): (0, 1), (9, 18, 5, 3): (0, 1), (9, 18, 5, 4): (0, 1), (9, 18, 5, 5): (0, 1), (9, 19, -5, -5): (0, 1), (9, 19, -5, -4): (0, 1), (9, 19, -5, -3): (0, 1), (9, 19, -5, -2): (0, 1), (9, 19, -5, -1): (0, 0), (9, 19, -5, 0): (0, 1), (9, 19, -5, 1): (0, 1), (9, 19, -5, 2): (0, 1), (9, 19, -5, 3): (0, 1), (9, 19, -5, 4): (0, 1), (9, 19, -5, 5): (0, 1), (9, 19, -4, -5): (0, 1), (9, 19, -4, -4): (0, 1), (9, 19, -4, -3): (0, 1), (9, 19, -4, -2): (0, 1), (9, 19, -4, -1): (0, 0), (9, 19, -4, 0): (0, 1), (9, 19, -4, 1): (0, 1), (9, 19, -4, 2): (0, 1), (9, 19, -4, 3): (0, 1), (9, 19, -4, 4): (1, 1), (9, 19, -4, 5): (1, 0), (9, 19, -3, -5): (-1, 1), (9, 19, -3, -4): (-1, 1), (9, 19, -3, -3): (-1, 1), (9, 19, -3, -2): (-1, 1), (9, 19, -3, -1): (-1, 0), (9, 19, -3, 0): (-1, 1), (9, 19, -3, 1): (1, 1), (9, 19, -3, 2): (1, 1), (9, 19, -3, 3): (1, 1), (9, 19, -3, 4): (0, 1), (9, 19, -3, 5): (0, 1), (9, 19, -2, -5): (0, 1), (9, 19, -2, -4): (0, 1), (9, 19, -2, -3): (0, 1), (9, 19, -2, -2): (0, 1), (9, 19, -2, -1): (1, 1), (9, 19, -2, 0): (1, 1), (9, 19, -2, 1): (1, 1), (9, 19, -2, 2): (1, 1), (9, 19, -2, 3): (1, 1), (9, 19, -2, 4): (-1, 1), (9, 19, -2, 5): (-1, 1), (9, 19, -1, -5): (-1, 1), (9, 19, -1, -4): (-1, 1), (9, 19, -1, -3): (-1, 1), (9, 19, -1, -2): (1, 1), (9, 19, -1, -1): (1, 1), (9, 19, -1, 0): (1, 1), (9, 19, -1, 1): (1, 1), (9, 19, -1, 2): (0, 1), (9, 19, -1, 3): (0, 1), (9, 19, -1, 4): (0, 1), (9, 19, -1, 5): (0, 1), (9, 19, 0, -5): (1, 1), (9, 19, 0, -4): (1, 1), (9, 19, 0, -3): (1, 1), (9, 19, 0, -2): (1, 1), (9, 19, 0, -1): (1, 0), (9, 19, 0, 0): (0, 1), (9, 19, 0, 1): (0, 1), (9, 19, 0, 2): (-1, 1), (9, 19, 0, 3): (-1, 1), (9, 19, 0, 4): (-1, 1), (9, 19, 0, 5): (-1, 1), (9, 19, 1, -5): (0, 1), (9, 19, 1, -4): (0, 1), (9, 19, 1, -3): (0, 1), (9, 19, 1, -2): (0, 1), (9, 19, 1, -1): (0, 0), (9, 19, 1, 0): (-1, 1), (9, 19, 1, 1): (-1, 1), (9, 19, 1, 2): (-1, 0), (9, 19, 1, 3): (-1, -1), (9, 19, 1, 4): (-1, -1), (9, 19, 1, 5): (-1, -1), (9, 19, 2, -5): (0, 1), (9, 19, 2, -4): (0, 1), (9, 19, 2, -3): (0, 1), (9, 19, 2, -2): (0, 1), (9, 19, 2, -1): (0, 0), (9, 19, 2, 0): (0, 1), (9, 19, 2, 1): (0, 1), (9, 19, 2, 2): (0, 1), (9, 19, 2, 3): (0, 1), (9, 19, 2, 4): (0, 1), (9, 19, 2, 5): (0, 1), (9, 19, 3, -5): (0, 1), (9, 19, 3, -4): (0, 1), (9, 19, 3, -3): (0, 1), (9, 19, 3, -2): (0, 1), (9, 19, 3, -1): (0, 0), (9, 19, 3, 0): (0, 1), (9, 19, 3, 1): (0, 1), (9, 19, 3, 2): (0, 1), (9, 19, 3, 3): (0, 1), (9, 19, 3, 4): (0, 1), (9, 19, 3, 5): (0, 1), (9, 19, 4, -5): (0, 1), (9, 19, 4, -4): (0, 1), (9, 19, 4, -3): (0, 1), (9, 19, 4, -2): (0, 1), (9, 19, 4, -1): (0, 0), (9, 19, 4, 0): (0, 1), (9, 19, 4, 1): (0, 1), (9, 19, 4, 2): (0, 1), (9, 19, 4, 3): (0, 1), (9, 19, 4, 4): (0, 1), (9, 19, 4, 5): (0, 1), (9, 19, 5, -5): (0, 1), (9, 19, 5, -4): (0, 1), (9, 19, 5, -3): (0, 1), (9, 19, 5, -2): (0, 1), (9, 19, 5, -1): (0, 0), (9, 19, 5, 0): (0, 1), (9, 19, 5, 1): (0, 1), (9, 19, 5, 2): (0, 1), (9, 19, 5, 3): (0, 1), (9, 19, 5, 4): (0, 1), (9, 19, 5, 5): (0, 1), (9, 20, -5, -5): (0, 1), (9, 20, -5, -4): (0, 1), (9, 20, -5, -3): (0, 1), (9, 20, -5, -2): (0, 0), (9, 20, -5, -1): (0, 1), (9, 20, -5, 0): (0, 1), (9, 20, -5, 1): (0, 1), (9, 20, -5, 2): (0, 1), (9, 20, -5, 3): (0, 1), (9, 20, -5, 4): (0, 1), (9, 20, -5, 5): (0, 1), (9, 20, -4, -5): (0, 1), (9, 20, -4, -4): (0, 1), (9, 20, -4, -3): (0, 1), (9, 20, -4, -2): (0, 0), (9, 20, -4, -1): (0, 1), (9, 20, -4, 0): (0, 1), (9, 20, -4, 1): (0, 1), (9, 20, -4, 2): (0, 1), (9, 20, -4, 3): (1, 1), (9, 20, -4, 4): (1, 1), (9, 20, -4, 5): (1, 0), (9, 20, -3, -5): (-1, 1), (9, 20, -3, -4): (-1, 1), (9, 20, -3, -3): (-1, 1), (9, 20, -3, -2): (-1, 0), (9, 20, -3, -1): (-1, 1), (9, 20, -3, 0): (1, 1), (9, 20, -3, 1): (1, 1), (9, 20, -3, 2): (1, 1), (9, 20, -3, 3): (0, 1), (9, 20, -3, 4): (0, 1), (9, 20, -3, 5): (0, 1), (9, 20, -2, -5): (0, 1), (9, 20, -2, -4): (0, 1), (9, 20, -2, -3): (0, 1), (9, 20, -2, -2): (0, 1), (9, 20, -2, -1): (1, 1), (9, 20, -2, 0): (1, 1), (9, 20, -2, 1): (1, 1), (9, 20, -2, 2): (1, 1), (9, 20, -2, 3): (-1, 1), (9, 20, -2, 4): (-1, 1), (9, 20, -2, 5): (-1, 1), (9, 20, -1, -5): (-1, 1), (9, 20, -1, -4): (-1, 1), (9, 20, -1, -3): (-1, 1), (9, 20, -1, -2): (1, 1), (9, 20, -1, -1): (1, 1), (9, 20, -1, 0): (1, 1), (9, 20, -1, 1): (1, 1), (9, 20, -1, 2): (0, 1), (9, 20, -1, 3): (0, 1), (9, 20, -1, 4): (0, 0), (9, 20, -1, 5): (0, -1), (9, 20, 0, -5): (1, 1), (9, 20, 0, -4): (1, 1), (9, 20, 0, -3): (1, 1), (9, 20, 0, -2): (1, 0), (9, 20, 0, -1): (0, 1), (9, 20, 0, 0): (0, 1), (9, 20, 0, 1): (0, 1), (9, 20, 0, 2): (-1, 1), (9, 20, 0, 3): (-1, 1), (9, 20, 0, 4): (-1, 0), (9, 20, 0, 5): (-1, -1), (9, 20, 1, -5): (0, 1), (9, 20, 1, -4): (0, 1), (9, 20, 1, -3): (0, 1), (9, 20, 1, -2): (0, 0), (9, 20, 1, -1): (0, 1), (9, 20, 1, 0): (-1, 1), (9, 20, 1, 1): (-1, 1), (9, 20, 1, 2): (-1, 1), (9, 20, 1, 3): (-1, 0), (9, 20, 1, 4): (-1, -1), (9, 20, 1, 5): (-1, -1), (9, 20, 2, -5): (0, 1), (9, 20, 2, -4): (0, 1), (9, 20, 2, -3): (0, 1), (9, 20, 2, -2): (0, 0), (9, 20, 2, -1): (0, 1), (9, 20, 2, 0): (0, 1), (9, 20, 2, 1): (0, 1), (9, 20, 2, 2): (0, 1), (9, 20, 2, 3): (0, 1), (9, 20, 2, 4): (0, 1), (9, 20, 2, 5): (0, 1), (9, 20, 3, -5): (0, 1), (9, 20, 3, -4): (0, 1), (9, 20, 3, -3): (0, 1), (9, 20, 3, -2): (0, 0), (9, 20, 3, -1): (0, 1), (9, 20, 3, 0): (0, 1), (9, 20, 3, 1): (0, 1), (9, 20, 3, 2): (0, 1), (9, 20, 3, 3): (0, 1), (9, 20, 3, 4): (0, 1), (9, 20, 3, 5): (0, 1), (9, 20, 4, -5): (0, 1), (9, 20, 4, -4): (0, 1), (9, 20, 4, -3): (0, 1), (9, 20, 4, -2): (0, 0), (9, 20, 4, -1): (0, 1), (9, 20, 4, 0): (0, 1), (9, 20, 4, 1): (0, 1), (9, 20, 4, 2): (0, 1), (9, 20, 4, 3): (0, 1), (9, 20, 4, 4): (0, 1), (9, 20, 4, 5): (0, 1), (9, 20, 5, -5): (0, 1), (9, 20, 5, -4): (0, 1), (9, 20, 5, -3): (0, 1), (9, 20, 5, -2): (0, 0), (9, 20, 5, -1): (0, 1), (9, 20, 5, 0): (0, 1), (9, 20, 5, 1): (0, 1), (9, 20, 5, 2): (0, 1), (9, 20, 5, 3): (0, 1), (9, 20, 5, 4): (0, 1), (9, 20, 5, 5): (0, 1), (9, 21, -5, -5): (0, 1), (9, 21, -5, -4): (0, 1), (9, 21, -5, -3): (0, 0), (9, 21, -5, -2): (0, 1), (9, 21, -5, -1): (0, 1), (9, 21, -5, 0): (0, 1), (9, 21, -5, 1): (0, 1), (9, 21, -5, 2): (0, 1), (9, 21, -5, 3): (0, 1), (9, 21, -5, 4): (0, 1), (9, 21, -5, 5): (0, 1), (9, 21, -4, -5): (0, 1), (9, 21, -4, -4): (0, 1), (9, 21, -4, -3): (0, 0), (9, 21, -4, -2): (0, 1), (9, 21, -4, -1): (0, 1), (9, 21, -4, 0): (0, 1), (9, 21, -4, 1): (0, 1), (9, 21, -4, 2): (0, 1), (9, 21, -4, 3): (1, 1), (9, 21, -4, 4): (1, 1), (9, 21, -4, 5): (1, 0), (9, 21, -3, -5): (-1, 1), (9, 21, -3, -4): (-1, 1), (9, 21, -3, -3): (-1, 0), (9, 21, -3, -2): (-1, 1), (9, 21, -3, -1): (-1, 1), (9, 21, -3, 0): (-1, 1), (9, 21, -3, 1): (1, 1), (9, 21, -3, 2): (1, 1), (9, 21, -3, 3): (0, 1), (9, 21, -3, 4): (0, 1), (9, 21, -3, 5): (0, 1), (9, 21, -2, -5): (0, 1), (9, 21, -2, -4): (0, 1), (9, 21, -2, -3): (0, 1), (9, 21, -2, -2): (0, 1), (9, 21, -2, -1): (1, 1), (9, 21, -2, 0): (1, 1), (9, 21, -2, 1): (1, 1), (9, 21, -2, 2): (1, 1), (9, 21, -2, 3): (-1, 1), (9, 21, -2, 4): (-1, 1), (9, 21, -2, 5): (-1, 1), (9, 21, -1, -5): (-1, 1), (9, 21, -1, -4): (-1, 1), (9, 21, -1, -3): (-1, 1), (9, 21, -1, -2): (-1, 1), (9, 21, -1, -1): (1, 1), (9, 21, -1, 0): (1, 1), (9, 21, -1, 1): (0, 1), (9, 21, -1, 2): (0, 1), (9, 21, -1, 3): (0, 0), (9, 21, -1, 4): (0, -1), (9, 21, -1, 5): (0, -1), (9, 21, 0, -5): (1, 1), (9, 21, 0, -4): (1, 1), (9, 21, 0, -3): (1, 0), (9, 21, 0, -2): (1, 1), (9, 21, 0, -1): (0, 1), (9, 21, 0, 0): (0, 1), (9, 21, 0, 1): (-1, 1), (9, 21, 0, 2): (-1, 1), (9, 21, 0, 3): (-1, 0), (9, 21, 0, 4): (-1, -1), (9, 21, 0, 5): (-1, -1), (9, 21, 1, -5): (0, 1), (9, 21, 1, -4): (0, 1), (9, 21, 1, -3): (0, 0), (9, 21, 1, -2): (0, 1), (9, 21, 1, -1): (0, 1), (9, 21, 1, 0): (-1, 1), (9, 21, 1, 1): (-1, 1), (9, 21, 1, 2): (-1, 1), (9, 21, 1, 3): (-1, 0), (9, 21, 1, 4): (-1, -1), (9, 21, 1, 5): (-1, -1), (9, 21, 2, -5): (0, 1), (9, 21, 2, -4): (0, 1), (9, 21, 2, -3): (0, 0), (9, 21, 2, -2): (0, 1), (9, 21, 2, -1): (0, 1), (9, 21, 2, 0): (0, 1), (9, 21, 2, 1): (0, 1), (9, 21, 2, 2): (0, 1), (9, 21, 2, 3): (0, 1), (9, 21, 2, 4): (0, 1), (9, 21, 2, 5): (0, 1), (9, 21, 3, -5): (0, 1), (9, 21, 3, -4): (0, 1), (9, 21, 3, -3): (0, 0), (9, 21, 3, -2): (0, 1), (9, 21, 3, -1): (0, 1), (9, 21, 3, 0): (0, 1), (9, 21, 3, 1): (0, 1), (9, 21, 3, 2): (0, 1), (9, 21, 3, 3): (0, 1), (9, 21, 3, 4): (0, 1), (9, 21, 3, 5): (0, 1), (9, 21, 4, -5): (0, 1), (9, 21, 4, -4): (0, 1), (9, 21, 4, -3): (0, 0), (9, 21, 4, -2): (0, 1), (9, 21, 4, -1): (0, 1), (9, 21, 4, 0): (0, 1), (9, 21, 4, 1): (0, 1), (9, 21, 4, 2): (0, 1), (9, 21, 4, 3): (0, 1), (9, 21, 4, 4): (0, 1), (9, 21, 4, 5): (0, 1), (9, 21, 5, -5): (0, 1), (9, 21, 5, -4): (0, 1), (9, 21, 5, -3): (0, 0), (9, 21, 5, -2): (0, 1), (9, 21, 5, -1): (0, 1), (9, 21, 5, 0): (0, 1), (9, 21, 5, 1): (0, 1), (9, 21, 5, 2): (0, 1), (9, 21, 5, 3): (0, 1), (9, 21, 5, 4): (0, 1), (9, 21, 5, 5): (0, 1), (9, 22, -5, -5): (0, 1), (9, 22, -5, -4): (0, 0), (9, 22, -5, -3): (0, 1), (9, 22, -5, -2): (0, 1), (9, 22, -5, -1): (0, 1), (9, 22, -5, 0): (0, 1), (9, 22, -5, 1): (0, 1), (9, 22, -5, 2): (0, 1), (9, 22, -5, 3): (0, 1), (9, 22, -5, 4): (0, 1), (9, 22, -5, 5): (0, 1), (9, 22, -4, -5): (0, 1), (9, 22, -4, -4): (0, 0), (9, 22, -4, -3): (0, 1), (9, 22, -4, -2): (0, 1), (9, 22, -4, -1): (0, 1), (9, 22, -4, 0): (0, 1), (9, 22, -4, 1): (0, 1), (9, 22, -4, 2): (1, 1), (9, 22, -4, 3): (1, 1), (9, 22, -4, 4): (1, 1), (9, 22, -4, 5): (1, 0), (9, 22, -3, -5): (-1, 1), (9, 22, -3, -4): (-1, 0), (9, 22, -3, -3): (-1, 1), (9, 22, -3, -2): (-1, 1), (9, 22, -3, -1): (-1, 1), (9, 22, -3, 0): (-1, 1), (9, 22, -3, 1): (1, 1), (9, 22, -3, 2): (0, 1), (9, 22, -3, 3): (0, 1), (9, 22, -3, 4): (0, 1), (9, 22, -3, 5): (0, 1), (9, 22, -2, -5): (0, 1), (9, 22, -2, -4): (0, 1), (9, 22, -2, -3): (0, 1), (9, 22, -2, -2): (0, 1), (9, 22, -2, -1): (1, 1), (9, 22, -2, 0): (1, 1), (9, 22, -2, 1): (1, 1), (9, 22, -2, 2): (-1, 1), (9, 22, -2, 3): (-1, 1), (9, 22, -2, 4): (-1, 1), (9, 22, -2, 5): (-1, 1), (9, 22, -1, -5): (-1, 1), (9, 22, -1, -4): (-1, 1), (9, 22, -1, -3): (-1, 1), (9, 22, -1, -2): (1, 1), (9, 22, -1, -1): (1, 1), (9, 22, -1, 0): (1, 1), (9, 22, -1, 1): (0, 1), (9, 22, -1, 2): (0, 1), (9, 22, -1, 3): (0, 1), (9, 22, -1, 4): (-1, 1), (9, 22, -1, 5): (-1, 1), (9, 22, 0, -5): (1, 1), (9, 22, 0, -4): (1, 0), (9, 22, 0, -3): (1, 1), (9, 22, 0, -2): (1, 1), (9, 22, 0, -1): (0, 1), (9, 22, 0, 0): (0, 1), (9, 22, 0, 1): (-1, 1), (9, 22, 0, 2): (-1, 1), (9, 22, 0, 3): (-1, 1), (9, 22, 0, 4): (-1, 0), (9, 22, 0, 5): (-1, -1), (9, 22, 1, -5): (0, 1), (9, 22, 1, -4): (0, 0), (9, 22, 1, -3): (0, 1), (9, 22, 1, -2): (0, 1), (9, 22, 1, -1): (0, 1), (9, 22, 1, 0): (-1, 1), (9, 22, 1, 1): (-1, 1), (9, 22, 1, 2): (-1, 0), (9, 22, 1, 3): (-1, -1), (9, 22, 1, 4): (-1, -1), (9, 22, 1, 5): (0, 1), (9, 22, 2, -5): (0, 1), (9, 22, 2, -4): (0, 0), (9, 22, 2, -3): (0, 1), (9, 22, 2, -2): (0, 1), (9, 22, 2, -1): (0, 1), (9, 22, 2, 0): (0, 1), (9, 22, 2, 1): (0, 1), (9, 22, 2, 2): (0, 1), (9, 22, 2, 3): (0, 1), (9, 22, 2, 4): (0, 1), (9, 22, 2, 5): (0, 1), (9, 22, 3, -5): (0, 1), (9, 22, 3, -4): (0, 0), (9, 22, 3, -3): (0, 1), (9, 22, 3, -2): (0, 1), (9, 22, 3, -1): (0, 1), (9, 22, 3, 0): (0, 1), (9, 22, 3, 1): (0, 1), (9, 22, 3, 2): (0, 1), (9, 22, 3, 3): (0, 1), (9, 22, 3, 4): (0, 1), (9, 22, 3, 5): (0, 1), (9, 22, 4, -5): (0, 1), (9, 22, 4, -4): (0, 0), (9, 22, 4, -3): (0, 1), (9, 22, 4, -2): (0, 1), (9, 22, 4, -1): (0, 1), (9, 22, 4, 0): (0, 1), (9, 22, 4, 1): (0, 1), (9, 22, 4, 2): (0, 1), (9, 22, 4, 3): (0, 1), (9, 22, 4, 4): (0, 1), (9, 22, 4, 5): (0, 1), (9, 22, 5, -5): (0, 1), (9, 22, 5, -4): (0, 0), (9, 22, 5, -3): (0, 1), (9, 22, 5, -2): (0, 1), (9, 22, 5, -1): (0, 1), (9, 22, 5, 0): (0, 1), (9, 22, 5, 1): (0, 1), (9, 22, 5, 2): (0, 1), (9, 22, 5, 3): (0, 1), (9, 22, 5, 4): (0, 1), (9, 22, 5, 5): (0, 1), (9, 23, -5, -5): (0, 0), (9, 23, -5, -4): (0, 1), (9, 23, -5, -3): (0, 1), (9, 23, -5, -2): (0, 1), (9, 23, -5, -1): (0, 1), (9, 23, -5, 0): (0, 1), (9, 23, -5, 1): (0, 1), (9, 23, -5, 2): (0, 1), (9, 23, -5, 3): (0, 1), (9, 23, -5, 4): (0, 1), (9, 23, -5, 5): (0, 1), (9, 23, -4, -5): (0, 0), (9, 23, -4, -4): (0, 1), (9, 23, -4, -3): (0, 1), (9, 23, -4, -2): (0, 1), (9, 23, -4, -1): (0, 1), (9, 23, -4, 0): (0, 1), (9, 23, -4, 1): (0, 1), (9, 23, -4, 2): (1, 1), (9, 23, -4, 3): (1, 1), (9, 23, -4, 4): (1, 1), (9, 23, -4, 5): (1, 0), (9, 23, -3, -5): (-1, 0), (9, 23, -3, -4): (-1, 1), (9, 23, -3, -3): (-1, 1), (9, 23, -3, -2): (-1, 1), (9, 23, -3, -1): (-1, 1), (9, 23, -3, 0): (1, 1), (9, 23, -3, 1): (1, 1), (9, 23, -3, 2): (0, 1), (9, 23, -3, 3): (0, 1), (9, 23, -3, 4): (0, 1), (9, 23, -3, 5): (0, 1), (9, 23, -2, -5): (0, 1), (9, 23, -2, -4): (0, 1), (9, 23, -2, -3): (0, 1), (9, 23, -2, -2): (0, 1), (9, 23, -2, -1): (1, 1), (9, 23, -2, 0): (1, 1), (9, 23, -2, 1): (1, 1), (9, 23, -2, 2): (-1, 1), (9, 23, -2, 3): (-1, 1), (9, 23, -2, 4): (-1, 1), (9, 23, -2, 5): (-1, 1), (9, 23, -1, -5): (-1, 1), (9, 23, -1, -4): (-1, 1), (9, 23, -1, -3): (-1, 1), (9, 23, -1, -2): (1, 1), (9, 23, -1, -1): (1, 1), (9, 23, -1, 0): (1, 1), (9, 23, -1, 1): (0, 1), (9, 23, -1, 2): (0, 1), (9, 23, -1, 3): (0, 0), (9, 23, -1, 4): (-1, 1), (9, 23, -1, 5): (-1, 1), (9, 23, 0, -5): (1, 0), (9, 23, 0, -4): (1, 1), (9, 23, 0, -3): (1, 1), (9, 23, 0, -2): (1, 1), (9, 23, 0, -1): (0, 1), (9, 23, 0, 0): (0, 1), (9, 23, 0, 1): (-1, 1), (9, 23, 0, 2): (-1, 1), (9, 23, 0, 3): (-1, 0), (9, 23, 0, 4): (-1, -1), (9, 23, 0, 5): (-1, -1), (9, 23, 1, -5): (0, 0), (9, 23, 1, -4): (0, 1), (9, 23, 1, -3): (0, 1), (9, 23, 1, -2): (0, 1), (9, 23, 1, -1): (0, 1), (9, 23, 1, 0): (-1, 1), (9, 23, 1, 1): (-1, 1), (9, 23, 1, 2): (-1, 1), (9, 23, 1, 3): (-1, 0), (9, 23, 1, 4): (-1, -1), (9, 23, 1, 5): (0, 1), (9, 23, 2, -5): (0, 0), (9, 23, 2, -4): (0, 1), (9, 23, 2, -3): (0, 1), (9, 23, 2, -2): (0, 1), (9, 23, 2, -1): (0, 1), (9, 23, 2, 0): (0, 1), (9, 23, 2, 1): (0, 1), (9, 23, 2, 2): (0, 1), (9, 23, 2, 3): (0, 1), (9, 23, 2, 4): (0, 1), (9, 23, 2, 5): (0, 1), (9, 23, 3, -5): (0, 0), (9, 23, 3, -4): (0, 1), (9, 23, 3, -3): (0, 1), (9, 23, 3, -2): (0, 1), (9, 23, 3, -1): (0, 1), (9, 23, 3, 0): (0, 1), (9, 23, 3, 1): (0, 1), (9, 23, 3, 2): (0, 1), (9, 23, 3, 3): (0, 1), (9, 23, 3, 4): (0, 1), (9, 23, 3, 5): (0, 1), (9, 23, 4, -5): (0, 0), (9, 23, 4, -4): (0, 1), (9, 23, 4, -3): (0, 1), (9, 23, 4, -2): (0, 1), (9, 23, 4, -1): (0, 1), (9, 23, 4, 0): (0, 1), (9, 23, 4, 1): (0, 1), (9, 23, 4, 2): (0, 1), (9, 23, 4, 3): (0, 1), (9, 23, 4, 4): (0, 1), (9, 23, 4, 5): (0, 1), (9, 23, 5, -5): (0, 0), (9, 23, 5, -4): (0, 1), (9, 23, 5, -3): (0, 1), (9, 23, 5, -2): (0, 1), (9, 23, 5, -1): (0, 1), (9, 23, 5, 0): (0, 1), (9, 23, 5, 1): (0, 1), (9, 23, 5, 2): (0, 1), (9, 23, 5, 3): (0, 1), (9, 23, 5, 4): (0, 1), (9, 23, 5, 5): (0, 1), (9, 24, -5, -5): (0, 1), (9, 24, -5, -4): (0, 1), (9, 24, -5, -3): (0, 1), (9, 24, -5, -2): (0, 1), (9, 24, -5, -1): (0, 1), (9, 24, -5, 0): (0, 1), (9, 24, -5, 1): (0, 1), (9, 24, -5, 2): (0, 1), (9, 24, -5, 3): (0, 1), (9, 24, -5, 4): (0, 1), (9, 24, -5, 5): (0, 1), (9, 24, -4, -5): (0, 1), (9, 24, -4, -4): (0, 1), (9, 24, -4, -3): (0, 1), (9, 24, -4, -2): (0, 1), (9, 24, -4, -1): (0, 1), (9, 24, -4, 0): (0, 1), (9, 24, -4, 1): (1, 1), (9, 24, -4, 2): (1, 1), (9, 24, -4, 3): (1, 1), (9, 24, -4, 4): (1, 0), (9, 24, -4, 5): (1, -1), (9, 24, -3, -5): (-1, 1), (9, 24, -3, -4): (-1, 1), (9, 24, -3, -3): (-1, 1), (9, 24, -3, -2): (-1, 1), (9, 24, -3, -1): (-1, 1), (9, 24, -3, 0): (1, 1), (9, 24, -3, 1): (0, 1), (9, 24, -3, 2): (0, 1), (9, 24, -3, 3): (0, 1), (9, 24, -3, 4): (0, 0), (9, 24, -3, 5): (0, -1), (9, 24, -2, -5): (0, 1), (9, 24, -2, -4): (0, 1), (9, 24, -2, -3): (0, 1), (9, 24, -2, -2): (0, 1), (9, 24, -2, -1): (1, 1), (9, 24, -2, 0): (1, 1), (9, 24, -2, 1): (-1, 1), (9, 24, -2, 2): (-1, 1), (9, 24, -2, 3): (-1, 1), (9, 24, -2, 4): (-1, 0), (9, 24, -2, 5): (-1, -1), (9, 24, -1, -5): (-1, 1), (9, 24, -1, -4): (-1, 1), (9, 24, -1, -3): (1, 1), (9, 24, -1, -2): (1, 1), (9, 24, -1, -1): (1, 1), (9, 24, -1, 0): (1, 1), (9, 24, -1, 1): (0, 1), (9, 24, -1, 2): (0, 1), (9, 24, -1, 3): (-1, 1), (9, 24, -1, 4): (-1, 0), (9, 24, -1, 5): (-1, -1), (9, 24, 0, -5): (1, 1), (9, 24, 0, -4): (1, 1), (9, 24, 0, -3): (1, 1), (9, 24, 0, -2): (1, 1), (9, 24, 0, -1): (0, 1), (9, 24, 0, 0): (0, 1), (9, 24, 0, 1): (-1, 1), (9, 24, 0, 2): (-1, 1), (9, 24, 0, 3): (-1, 0), (9, 24, 0, 4): (-1, -1), (9, 24, 0, 5): (-1, -1), (9, 24, 1, -5): (0, 1), (9, 24, 1, -4): (0, 1), (9, 24, 1, -3): (0, 1), (9, 24, 1, -2): (0, 1), (9, 24, 1, -1): (0, 1), (9, 24, 1, 0): (-1, 1), (9, 24, 1, 1): (-1, 1), (9, 24, 1, 2): (-1, 0), (9, 24, 1, 3): (-1, -1), (9, 24, 1, 4): (0, 1), (9, 24, 1, 5): (0, 1), (9, 24, 2, -5): (0, 1), (9, 24, 2, -4): (0, 1), (9, 24, 2, -3): (0, 1), (9, 24, 2, -2): (0, 1), (9, 24, 2, -1): (0, 1), (9, 24, 2, 0): (0, 1), (9, 24, 2, 1): (0, 1), (9, 24, 2, 2): (0, 1), (9, 24, 2, 3): (0, 1), (9, 24, 2, 4): (0, 1), (9, 24, 2, 5): (0, 1), (9, 24, 3, -5): (0, 1), (9, 24, 3, -4): (0, 1), (9, 24, 3, -3): (0, 1), (9, 24, 3, -2): (0, 1), (9, 24, 3, -1): (0, 1), (9, 24, 3, 0): (0, 1), (9, 24, 3, 1): (0, 1), (9, 24, 3, 2): (0, 1), (9, 24, 3, 3): (0, 1), (9, 24, 3, 4): (0, 1), (9, 24, 3, 5): (0, 1), (9, 24, 4, -5): (0, 1), (9, 24, 4, -4): (0, 1), (9, 24, 4, -3): (0, 1), (9, 24, 4, -2): (0, 1), (9, 24, 4, -1): (0, 1), (9, 24, 4, 0): (0, 1), (9, 24, 4, 1): (0, 1), (9, 24, 4, 2): (0, 1), (9, 24, 4, 3): (0, 1), (9, 24, 4, 4): (0, 1), (9, 24, 4, 5): (0, 1), (9, 24, 5, -5): (0, 1), (9, 24, 5, -4): (0, 1), (9, 24, 5, -3): (0, 1), (9, 24, 5, -2): (0, 1), (9, 24, 5, -1): (0, 1), (9, 24, 5, 0): (0, 1), (9, 24, 5, 1): (0, 1), (9, 24, 5, 2): (0, 1), (9, 24, 5, 3): (0, 1), (9, 24, 5, 4): (0, 1), (9, 24, 5, 5): (0, 1), (9, 25, -5, -5): (0, 1), (9, 25, -5, -4): (0, 1), (9, 25, -5, -3): (0, 1), (9, 25, -5, -2): (0, 1), (9, 25, -5, -1): (0, 1), (9, 25, -5, 0): (0, 1), (9, 25, -5, 1): (0, 1), (9, 25, -5, 2): (0, 1), (9, 25, -5, 3): (0, 1), (9, 25, -5, 4): (0, 1), (9, 25, -5, 5): (0, 1), (9, 25, -4, -5): (0, 1), (9, 25, -4, -4): (0, 1), (9, 25, -4, -3): (0, 1), (9, 25, -4, -2): (0, 1), (9, 25, -4, -1): (0, 1), (9, 25, -4, 0): (0, 1), (9, 25, -4, 1): (1, 1), (9, 25, -4, 2): (1, 1), (9, 25, -4, 3): (1, 1), (9, 25, -4, 4): (1, 0), (9, 25, -4, 5): (1, -1), (9, 25, -3, -5): (-1, 1), (9, 25, -3, -4): (-1, 1), (9, 25, -3, -3): (-1, 1), (9, 25, -3, -2): (-1, 1), (9, 25, -3, -1): (-1, 1), (9, 25, -3, 0): (1, 1), (9, 25, -3, 1): (0, 1), (9, 25, -3, 2): (0, 1), (9, 25, -3, 3): (0, 1), (9, 25, -3, 4): (0, 0), (9, 25, -3, 5): (0, -1), (9, 25, -2, -5): (0, 1), (9, 25, -2, -4): (0, 1), (9, 25, -2, -3): (0, 1), (9, 25, -2, -2): (1, 1), (9, 25, -2, -1): (1, 1), (9, 25, -2, 0): (1, 1), (9, 25, -2, 1): (-1, 1), (9, 25, -2, 2): (-1, 1), (9, 25, -2, 3): (-1, 1), (9, 25, -2, 4): (-1, 0), (9, 25, -2, 5): (-1, -1), (9, 25, -1, -5): (-1, 1), (9, 25, -1, -4): (-1, 1), (9, 25, -1, -3): (1, 1), (9, 25, -1, -2): (1, 1), (9, 25, -1, -1): (1, 1), (9, 25, -1, 0): (0, 1), (9, 25, -1, 1): (0, 1), (9, 25, -1, 2): (-1, 1), (9, 25, -1, 3): (-1, 1), (9, 25, -1, 4): (-1, 0), (9, 25, -1, 5): (-1, -1), (9, 25, 0, -5): (1, 1), (9, 25, 0, -4): (1, 1), (9, 25, 0, -3): (1, 1), (9, 25, 0, -2): (1, 1), (9, 25, 0, -1): (0, 1), (9, 25, 0, 0): (-1, 1), (9, 25, 0, 1): (-1, 1), (9, 25, 0, 2): (-1, 0), (9, 25, 0, 3): (-1, -1), (9, 25, 0, 4): (-1, -1), (9, 25, 0, 5): (-1, -1), (9, 25, 1, -5): (0, 1), (9, 25, 1, -4): (0, 1), (9, 25, 1, -3): (0, 1), (9, 25, 1, -2): (0, 1), (9, 25, 1, -1): (0, 1), (9, 25, 1, 0): (-1, 1), (9, 25, 1, 1): (-1, 0), (9, 25, 1, 2): (-1, -1), (9, 25, 1, 3): (0, 1), (9, 25, 1, 4): (0, 0), (9, 25, 1, 5): (0, -1), (9, 25, 2, -5): (0, 1), (9, 25, 2, -4): (0, 1), (9, 25, 2, -3): (0, 1), (9, 25, 2, -2): (0, 1), (9, 25, 2, -1): (0, 1), (9, 25, 2, 0): (0, 1), (9, 25, 2, 1): (0, 1), (9, 25, 2, 2): (0, 1), (9, 25, 2, 3): (0, 1), (9, 25, 2, 4): (0, 0), (9, 25, 2, 5): (-1, -1), (9, 25, 3, -5): (0, 1), (9, 25, 3, -4): (0, 1), (9, 25, 3, -3): (0, 1), (9, 25, 3, -2): (0, 1), (9, 25, 3, -1): (0, 1), (9, 25, 3, 0): (0, 1), (9, 25, 3, 1): (0, 1), (9, 25, 3, 2): (0, 1), (9, 25, 3, 3): (0, 1), (9, 25, 3, 4): (0, 0), (9, 25, 3, 5): (-1, -1), (9, 25, 4, -5): (0, 1), (9, 25, 4, -4): (0, 1), (9, 25, 4, -3): (0, 1), (9, 25, 4, -2): (0, 1), (9, 25, 4, -1): (0, 1), (9, 25, 4, 0): (0, 1), (9, 25, 4, 1): (0, 1), (9, 25, 4, 2): (0, 1), (9, 25, 4, 3): (0, 1), (9, 25, 4, 4): (0, 0), (9, 25, 4, 5): (-1, -1), (9, 25, 5, -5): (0, 1), (9, 25, 5, -4): (0, 1), (9, 25, 5, -3): (0, 1), (9, 25, 5, -2): (0, 1), (9, 25, 5, -1): (0, 1), (9, 25, 5, 0): (0, 1), (9, 25, 5, 1): (0, 1), (9, 25, 5, 2): (0, 1), (9, 25, 5, 3): (0, 1), (9, 25, 5, 4): (0, 0), (9, 25, 5, 5): (-1, -1), (9, 26, -5, -5): (0, 1), (9, 26, -5, -4): (0, 1), (9, 26, -5, -3): (0, 1), (9, 26, -5, -2): (0, 1), (9, 26, -5, -1): (0, 1), (9, 26, -5, 0): (0, 1), (9, 26, -5, 1): (0, 1), (9, 26, -5, 2): (0, 1), (9, 26, -5, 3): (0, 1), (9, 26, -5, 4): (0, 1), (9, 26, -5, 5): (0, 1), (9, 26, -4, -5): (0, 1), (9, 26, -4, -4): (0, 1), (9, 26, -4, -3): (0, 1), (9, 26, -4, -2): (0, 1), (9, 26, -4, -1): (0, 1), (9, 26, -4, 0): (1, 1), (9, 26, -4, 1): (1, 1), (9, 26, -4, 2): (1, 1), (9, 26, -4, 3): (1, 0), (9, 26, -4, 4): (1, -1), (9, 26, -4, 5): (1, -1), (9, 26, -3, -5): (-1, 1), (9, 26, -3, -4): (-1, 1), (9, 26, -3, -3): (-1, 1), (9, 26, -3, -2): (-1, 1), (9, 26, -3, -1): (-1, 1), (9, 26, -3, 0): (0, 1), (9, 26, -3, 1): (0, 1), (9, 26, -3, 2): (0, 1), (9, 26, -3, 3): (0, 0), (9, 26, -3, 4): (0, -1), (9, 26, -3, 5): (0, -1), (9, 26, -2, -5): (0, 1), (9, 26, -2, -4): (0, 1), (9, 26, -2, -3): (0, 1), (9, 26, -2, -2): (1, 1), (9, 26, -2, -1): (1, 1), (9, 26, -2, 0): (-1, 1), (9, 26, -2, 1): (-1, 1), (9, 26, -2, 2): (-1, 1), (9, 26, -2, 3): (-1, 0), (9, 26, -2, 4): (-1, -1), (9, 26, -2, 5): (-1, -1), (9, 26, -1, -5): (-1, 1), (9, 26, -1, -4): (-1, 1), (9, 26, -1, -3): (1, 1), (9, 26, -1, -2): (1, 1), (9, 26, -1, -1): (1, 1), (9, 26, -1, 0): (0, 1), (9, 26, -1, 1): (0, 1), (9, 26, -1, 2): (-1, 1), (9, 26, -1, 3): (-1, 0), (9, 26, -1, 4): (-1, -1), (9, 26, -1, 5): (-1, -1), (9, 26, 0, -5): (1, 1), (9, 26, 0, -4): (1, 1), (9, 26, 0, -3): (1, 1), (9, 26, 0, -2): (1, 1), (9, 26, 0, -1): (0, 1), (9, 26, 0, 0): (-1, 1), (9, 26, 0, 1): (-1, 1), (9, 26, 0, 2): (-1, 0), (9, 26, 0, 3): (-1, -1), (9, 26, 0, 4): (-1, -1), (9, 26, 0, 5): (-1, 1), (9, 26, 1, -5): (0, 1), (9, 26, 1, -4): (0, 1), (9, 26, 1, -3): (0, 1), (9, 26, 1, -2): (0, 1), (9, 26, 1, -1): (0, 1), (9, 26, 1, 0): (-1, 1), (9, 26, 1, 1): (-1, 1), (9, 26, 1, 2): (0, 1), (9, 26, 1, 3): (0, 0), (9, 26, 1, 4): (0, -1), (9, 26, 1, 5): (0, -1), (9, 26, 2, -5): (0, 1), (9, 26, 2, -4): (0, 1), (9, 26, 2, -3): (0, 1), (9, 26, 2, -2): (0, 1), (9, 26, 2, -1): (0, 1), (9, 26, 2, 0): (0, 1), (9, 26, 2, 1): (0, 1), (9, 26, 2, 2): (0, 1), (9, 26, 2, 3): (0, 0), (9, 26, 2, 4): (-1, -1), (9, 26, 2, 5): (-1, -1), (9, 26, 3, -5): (0, 1), (9, 26, 3, -4): (0, 1), (9, 26, 3, -3): (0, 1), (9, 26, 3, -2): (0, 1), (9, 26, 3, -1): (0, 1), (9, 26, 3, 0): (0, 1), (9, 26, 3, 1): (0, 1), (9, 26, 3, 2): (0, 1), (9, 26, 3, 3): (0, 0), (9, 26, 3, 4): (-1, -1), (9, 26, 3, 5): (-1, -1), (9, 26, 4, -5): (0, 1), (9, 26, 4, -4): (0, 1), (9, 26, 4, -3): (0, 1), (9, 26, 4, -2): (0, 1), (9, 26, 4, -1): (0, 1), (9, 26, 4, 0): (0, 1), (9, 26, 4, 1): (0, 1), (9, 26, 4, 2): (0, 1), (9, 26, 4, 3): (0, 0), (9, 26, 4, 4): (-1, -1), (9, 26, 4, 5): (-1, -1), (9, 26, 5, -5): (0, 1), (9, 26, 5, -4): (0, 1), (9, 26, 5, -3): (0, 1), (9, 26, 5, -2): (0, 1), (9, 26, 5, -1): (0, 1), (9, 26, 5, 0): (0, 1), (9, 26, 5, 1): (0, 1), (9, 26, 5, 2): (0, 1), (9, 26, 5, 3): (0, 0), (9, 26, 5, 4): (-1, -1), (9, 26, 5, 5): (-1, -1), (9, 27, -5, -5): (0, 1), (9, 27, -5, -4): (0, 1), (9, 27, -5, -3): (0, 1), (9, 27, -5, -2): (0, 1), (9, 27, -5, -1): (0, 1), (9, 27, -5, 0): (0, 1), (9, 27, -5, 1): (0, 1), (9, 27, -5, 2): (0, 1), (9, 27, -5, 3): (0, 1), (9, 27, -5, 4): (0, 1), (9, 27, -5, 5): (0, 1), (9, 27, -4, -5): (0, 1), (9, 27, -4, -4): (0, 1), (9, 27, -4, -3): (0, 1), (9, 27, -4, -2): (0, 1), (9, 27, -4, -1): (0, 1), (9, 27, -4, 0): (1, 1), (9, 27, -4, 1): (1, 1), (9, 27, -4, 2): (1, 1), (9, 27, -4, 3): (1, 0), (9, 27, -4, 4): (1, -1), (9, 27, -4, 5): (0, 1), (9, 27, -3, -5): (-1, 1), (9, 27, -3, -4): (-1, 1), (9, 27, -3, -3): (-1, 1), (9, 27, -3, -2): (-1, 1), (9, 27, -3, -1): (-1, 1), (9, 27, -3, 0): (0, 1), (9, 27, -3, 1): (0, 1), (9, 27, -3, 2): (0, 1), (9, 27, -3, 3): (0, 0), (9, 27, -3, 4): (0, -1), (9, 27, -3, 5): (-1, 1), (9, 27, -2, -5): (0, 1), (9, 27, -2, -4): (0, 1), (9, 27, -2, -3): (0, 1), (9, 27, -2, -2): (1, 1), (9, 27, -2, -1): (1, 1), (9, 27, -2, 0): (-1, 1), (9, 27, -2, 1): (-1, 1), (9, 27, -2, 2): (-1, 1), (9, 27, -2, 3): (-1, 0), (9, 27, -2, 4): (-1, -1), (9, 27, -2, 5): (-1, -1), (9, 27, -1, -5): (-1, 1), (9, 27, -1, -4): (1, 1), (9, 27, -1, -3): (1, 1), (9, 27, -1, -2): (1, 1), (9, 27, -1, -1): (1, 1), (9, 27, -1, 0): (0, 1), (9, 27, -1, 1): (-1, 1), (9, 27, -1, 2): (-1, 1), (9, 27, -1, 3): (-1, 0), (9, 27, -1, 4): (-1, -1), (9, 27, -1, 5): (-1, -1), (9, 27, 0, -5): (1, 1), (9, 27, 0, -4): (1, 1), (9, 27, 0, -3): (1, 1), (9, 27, 0, -2): (1, 1), (9, 27, 0, -1): (0, 1), (9, 27, 0, 0): (-1, 1), (9, 27, 0, 1): (-1, 1), (9, 27, 0, 2): (-1, 0), (9, 27, 0, 3): (-1, -1), (9, 27, 0, 4): (-1, -1), (9, 27, 0, 5): (-1, 1), (9, 27, 1, -5): (0, 1), (9, 27, 1, -4): (0, 1), (9, 27, 1, -3): (0, 1), (9, 27, 1, -2): (0, 1), (9, 27, 1, -1): (0, 1), (9, 27, 1, 0): (-1, 1), (9, 27, 1, 1): (0, 1), (9, 27, 1, 2): (0, 0), (9, 27, 1, 3): (0, -1), (9, 27, 1, 4): (0, 1), (9, 27, 1, 5): (0, 1), (9, 27, 2, -5): (0, 1), (9, 27, 2, -4): (0, 1), (9, 27, 2, -3): (0, 1), (9, 27, 2, -2): (0, 1), (9, 27, 2, -1): (0, 1), (9, 27, 2, 0): (0, 1), (9, 27, 2, 1): (0, 1), (9, 27, 2, 2): (0, 0), (9, 27, 2, 3): (-1, -1), (9, 27, 2, 4): (0, 1), (9, 27, 2, 5): (0, 1), (9, 27, 3, -5): (0, 1), (9, 27, 3, -4): (0, 1), (9, 27, 3, -3): (0, 1), (9, 27, 3, -2): (0, 1), (9, 27, 3, -1): (0, 1), (9, 27, 3, 0): (0, 1), (9, 27, 3, 1): (0, 1), (9, 27, 3, 2): (0, 0), (9, 27, 3, 3): (-1, -1), (9, 27, 3, 4): (0, 1), (9, 27, 3, 5): (0, 1), (9, 27, 4, -5): (0, 1), (9, 27, 4, -4): (0, 1), (9, 27, 4, -3): (0, 1), (9, 27, 4, -2): (0, 1), (9, 27, 4, -1): (0, 1), (9, 27, 4, 0): (0, 1), (9, 27, 4, 1): (0, 1), (9, 27, 4, 2): (0, 0), (9, 27, 4, 3): (-1, -1), (9, 27, 4, 4): (0, 1), (9, 27, 4, 5): (0, 1), (9, 27, 5, -5): (0, 1), (9, 27, 5, -4): (0, 1), (9, 27, 5, -3): (0, 1), (9, 27, 5, -2): (0, 1), (9, 27, 5, -1): (0, 1), (9, 27, 5, 0): (0, 1), (9, 27, 5, 1): (0, 1), (9, 27, 5, 2): (0, 0), (9, 27, 5, 3): (-1, -1), (9, 27, 5, 4): (0, 1), (9, 27, 5, 5): (0, 1), (9, 28, -5, -5): (0, 1), (9, 28, -5, -4): (0, 1), (9, 28, -5, -3): (0, 1), (9, 28, -5, -2): (0, 1), (9, 28, -5, -1): (0, 1), (9, 28, -5, 0): (0, 1), (9, 28, -5, 1): (0, 1), (9, 28, -5, 2): (0, 1), (9, 28, -5, 3): (0, 1), (9, 28, -5, 4): (0, 0), (9, 28, -5, 5): (-1, -1), (9, 28, -4, -5): (0, 1), (9, 28, -4, -4): (0, 1), (9, 28, -4, -3): (0, 1), (9, 28, -4, -2): (0, 1), (9, 28, -4, -1): (1, 1), (9, 28, -4, 0): (1, 1), (9, 28, -4, 1): (1, 1), (9, 28, -4, 2): (1, 0), (9, 28, -4, 3): (0, 1), (9, 28, -4, 4): (0, 0), (9, 28, -4, 5): (-1, -1), (9, 28, -3, -5): (-1, 1), (9, 28, -3, -4): (-1, 1), (9, 28, -3, -3): (-1, 1), (9, 28, -3, -2): (-1, 1), (9, 28, -3, -1): (0, 1), (9, 28, -3, 0): (0, 1), (9, 28, -3, 1): (0, 1), (9, 28, -3, 2): (0, 0), (9, 28, -3, 3): (-1, 1), (9, 28, -3, 4): (-1, 0), (9, 28, -3, 5): (-1, -1), (9, 28, -2, -5): (0, 1), (9, 28, -2, -4): (0, 1), (9, 28, -2, -3): (0, 1), (9, 28, -2, -2): (1, 1), (9, 28, -2, -1): (-1, 1), (9, 28, -2, 0): (-1, 1), (9, 28, -2, 1): (-1, 1), (9, 28, -2, 2): (-1, 0), (9, 28, -2, 3): (-1, -1), (9, 28, -2, 4): (-1, -1), (9, 28, -2, 5): (-1, 1), (9, 28, -1, -5): (-1, 1), (9, 28, -1, -4): (1, 1), (9, 28, -1, -3): (1, 1), (9, 28, -1, -2): (1, 1), (9, 28, -1, -1): (1, 1), (9, 28, -1, 0): (0, 1), (9, 28, -1, 1): (-1, 1), (9, 28, -1, 2): (-1, 0), (9, 28, -1, 3): (-1, -1), (9, 28, -1, 4): (-1, -1), (9, 28, -1, 5): (-1, -1), (9, 28, 0, -5): (1, 1), (9, 28, 0, -4): (1, 1), (9, 28, 0, -3): (1, 1), (9, 28, 0, -2): (1, 1), (9, 28, 0, -1): (0, 1), (9, 28, 0, 0): (-1, 1), (9, 28, 0, 1): (-1, 1), (9, 28, 0, 2): (-1, 0), (9, 28, 0, 3): (-1, -1), (9, 28, 0, 4): (-1, -1), (9, 28, 0, 5): (-1, -1), (9, 28, 1, -5): (0, 1), (9, 28, 1, -4): (0, 1), (9, 28, 1, -3): (0, 1), (9, 28, 1, -2): (0, 1), (9, 28, 1, -1): (0, 1), (9, 28, 1, 0): (0, 1), (9, 28, 1, 1): (0, 0), (9, 28, 1, 2): (0, -1), (9, 28, 1, 3): (0, 1), (9, 28, 1, 4): (0, 1), (9, 28, 1, 5): (0, 1), (9, 28, 2, -5): (0, 1), (9, 28, 2, -4): (0, 1), (9, 28, 2, -3): (0, 1), (9, 28, 2, -2): (0, 1), (9, 28, 2, -1): (0, 1), (9, 28, 2, 0): (0, 1), (9, 28, 2, 1): (0, 0), (9, 28, 2, 2): (-1, -1), (9, 28, 2, 3): (0, 1), (9, 28, 2, 4): (0, 1), (9, 28, 2, 5): (0, 1), (9, 28, 3, -5): (0, 1), (9, 28, 3, -4): (0, 1), (9, 28, 3, -3): (0, 1), (9, 28, 3, -2): (0, 1), (9, 28, 3, -1): (0, 1), (9, 28, 3, 0): (0, 1), (9, 28, 3, 1): (0, 0), (9, 28, 3, 2): (-1, -1), (9, 28, 3, 3): (0, 1), (9, 28, 3, 4): (0, 1), (9, 28, 3, 5): (0, 1), (9, 28, 4, -5): (0, 1), (9, 28, 4, -4): (0, 1), (9, 28, 4, -3): (0, 1), (9, 28, 4, -2): (0, 1), (9, 28, 4, -1): (0, 1), (9, 28, 4, 0): (0, 1), (9, 28, 4, 1): (0, 0), (9, 28, 4, 2): (-1, -1), (9, 28, 4, 3): (0, 1), (9, 28, 4, 4): (0, 1), (9, 28, 4, 5): (0, 1), (9, 28, 5, -5): (0, 1), (9, 28, 5, -4): (0, 1), (9, 28, 5, -3): (0, 1), (9, 28, 5, -2): (0, 1), (9, 28, 5, -1): (0, 1), (9, 28, 5, 0): (0, 1), (9, 28, 5, 1): (0, 0), (9, 28, 5, 2): (-1, -1), (9, 28, 5, 3): (0, 1), (9, 28, 5, 4): (0, 1), (9, 28, 5, 5): (0, 1), (9, 29, -5, -5): (0, 1), (9, 29, -5, -4): (0, 1), (9, 29, -5, -3): (0, 1), (9, 29, -5, -2): (0, 1), (9, 29, -5, -1): (0, 1), (9, 29, -5, 0): (0, 1), (9, 29, -5, 1): (0, 1), (9, 29, -5, 2): (0, 1), (9, 29, -5, 3): (0, 0), (9, 29, -5, 4): (-1, -1), (9, 29, -5, 5): (0, 1), (9, 29, -4, -5): (0, 1), (9, 29, -4, -4): (0, 1), (9, 29, -4, -3): (0, 1), (9, 29, -4, -2): (0, 1), (9, 29, -4, -1): (1, 1), (9, 29, -4, 0): (1, 1), (9, 29, -4, 1): (1, 1), (9, 29, -4, 2): (0, 1), (9, 29, -4, 3): (0, 0), (9, 29, -4, 4): (-1, -1), (9, 29, -4, 5): (0, 1), (9, 29, -3, -5): (-1, 1), (9, 29, -3, -4): (-1, 1), (9, 29, -3, -3): (-1, 1), (9, 29, -3, -2): (-1, 1), (9, 29, -3, -1): (0, 1), (9, 29, -3, 0): (0, 1), (9, 29, -3, 1): (0, 1), (9, 29, -3, 2): (-1, 1), (9, 29, -3, 3): (-1, 0), (9, 29, -3, 4): (-1, -1), (9, 29, -3, 5): (-1, 1), (9, 29, -2, -5): (0, 1), (9, 29, -2, -4): (0, 1), (9, 29, -2, -3): (0, 1), (9, 29, -2, -2): (1, 1), (9, 29, -2, -1): (-1, 1), (9, 29, -2, 0): (-1, 1), (9, 29, -2, 1): (-1, 1), (9, 29, -2, 2): (-1, 0), (9, 29, -2, 3): (-1, -1), (9, 29, -2, 4): (-1, -1), (9, 29, -2, 5): (-1, 1), (9, 29, -1, -5): (1, 1), (9, 29, -1, -4): (1, 1), (9, 29, -1, -3): (1, 1), (9, 29, -1, -2): (1, 1), (9, 29, -1, -1): (0, 1), (9, 29, -1, 0): (-1, 1), (9, 29, -1, 1): (-1, 1), (9, 29, -1, 2): (-1, 0), (9, 29, -1, 3): (-1, -1), (9, 29, -1, 4): (-1, -1), (9, 29, -1, 5): (-1, 1), (9, 29, 0, -5): (1, 1), (9, 29, 0, -4): (1, 1), (9, 29, 0, -3): (1, 1), (9, 29, 0, -2): (1, 1), (9, 29, 0, -1): (-1, 1), (9, 29, 0, 0): (-1, 1), (9, 29, 0, 1): (-1, 0), (9, 29, 0, 2): (-1, -1), (9, 29, 0, 3): (-1, -1), (9, 29, 0, 4): (-1, -1), (9, 29, 0, 5): (-1, 1), (9, 29, 1, -5): (0, 1), (9, 29, 1, -4): (0, 1), (9, 29, 1, -3): (0, 1), (9, 29, 1, -2): (0, 1), (9, 29, 1, -1): (0, 1), (9, 29, 1, 0): (0, 0), (9, 29, 1, 1): (-1, -1), (9, 29, 1, 2): (0, 1), (9, 29, 1, 3): (0, 1), (9, 29, 1, 4): (0, 1), (9, 29, 1, 5): (0, 1), (9, 29, 2, -5): (0, 1), (9, 29, 2, -4): (0, 1), (9, 29, 2, -3): (0, 1), (9, 29, 2, -2): (0, 1), (9, 29, 2, -1): (0, 1), (9, 29, 2, 0): (0, 0), (9, 29, 2, 1): (-1, -1), (9, 29, 2, 2): (0, 1), (9, 29, 2, 3): (0, 1), (9, 29, 2, 4): (0, 1), (9, 29, 2, 5): (0, 1), (9, 29, 3, -5): (0, 1), (9, 29, 3, -4): (0, 1), (9, 29, 3, -3): (0, 1), (9, 29, 3, -2): (0, 1), (9, 29, 3, -1): (0, 1), (9, 29, 3, 0): (0, 0), (9, 29, 3, 1): (-1, -1), (9, 29, 3, 2): (0, 1), (9, 29, 3, 3): (0, 1), (9, 29, 3, 4): (0, 1), (9, 29, 3, 5): (0, 1), (9, 29, 4, -5): (0, 1), (9, 29, 4, -4): (0, 1), (9, 29, 4, -3): (0, 1), (9, 29, 4, -2): (0, 1), (9, 29, 4, -1): (0, 1), (9, 29, 4, 0): (0, 0), (9, 29, 4, 1): (-1, -1), (9, 29, 4, 2): (0, 1), (9, 29, 4, 3): (0, 1), (9, 29, 4, 4): (0, 1), (9, 29, 4, 5): (0, 1), (9, 29, 5, -5): (0, 1), (9, 29, 5, -4): (0, 1), (9, 29, 5, -3): (0, 1), (9, 29, 5, -2): (0, 1), (9, 29, 5, -1): (0, 1), (9, 29, 5, 0): (0, 0), (9, 29, 5, 1): (-1, -1), (9, 29, 5, 2): (0, 1), (9, 29, 5, 3): (0, 1), (9, 29, 5, 4): (0, 1), (9, 29, 5, 5): (0, 1), (9, 30, -5, -5): (0, 1), (9, 30, -5, -4): (0, 1), (9, 30, -5, -3): (0, 1), (9, 30, -5, -2): (0, 1), (9, 30, -5, -1): (0, 1), (9, 30, -5, 0): (0, 1), (9, 30, -5, 1): (0, 1), (9, 30, -5, 2): (0, 0), (9, 30, -5, 3): (-1, -1), (9, 30, -5, 4): (-1, -1), (9, 30, -5, 5): (0, 1), (9, 30, -4, -5): (0, 1), (9, 30, -4, -4): (0, 1), (9, 30, -4, -3): (0, 1), (9, 30, -4, -2): (1, 1), (9, 30, -4, -1): (1, 1), (9, 30, -4, 0): (1, 1), (9, 30, -4, 1): (0, 1), (9, 30, -4, 2): (0, 0), (9, 30, -4, 3): (-1, -1), (9, 30, -4, 4): (-1, -1), (9, 30, -4, 5): (0, 1), (9, 30, -3, -5): (-1, 1), (9, 30, -3, -4): (-1, 1), (9, 30, -3, -3): (-1, 1), (9, 30, -3, -2): (0, 1), (9, 30, -3, -1): (0, 1), (9, 30, -3, 0): (0, 1), (9, 30, -3, 1): (-1, 1), (9, 30, -3, 2): (-1, 0), (9, 30, -3, 3): (-1, -1), (9, 30, -3, 4): (-1, -1), (9, 30, -3, 5): (-1, 1), (9, 30, -2, -5): (0, 1), (9, 30, -2, -4): (0, 1), (9, 30, -2, -3): (0, 1), (9, 30, -2, -2): (-1, 1), (9, 30, -2, -1): (-1, 1), (9, 30, -2, 0): (-1, 1), (9, 30, -2, 1): (-1, 0), (9, 30, -2, 2): (-1, -1), (9, 30, -2, 3): (-1, -1), (9, 30, -2, 4): (-1, 1), (9, 30, -2, 5): (-1, 1), (9, 30, -1, -5): (-1, 1), (9, 30, -1, -4): (1, 1), (9, 30, -1, -3): (1, 1), (9, 30, -1, -2): (1, 1), (9, 30, -1, -1): (0, 1), (9, 30, -1, 0): (-1, 1), (9, 30, -1, 1): (-1, 0), (9, 30, -1, 2): (-1, -1), (9, 30, -1, 3): (-1, -1), (9, 30, -1, 4): (-1, -1), (9, 30, -1, 5): (-1, 1), (9, 30, 0, -5): (1, 1), (9, 30, 0, -4): (1, 1), (9, 30, 0, -3): (1, 1), (9, 30, 0, -2): (1, 1), (9, 30, 0, -1): (-1, 1), (9, 30, 0, 0): (-1, 1), (9, 30, 0, 1): (-1, 0), (9, 30, 0, 2): (-1, -1), (9, 30, 0, 3): (-1, -1), (9, 30, 0, 4): (-1, -1), (9, 30, 0, 5): (-1, 1), (9, 30, 1, -5): (0, 1), (9, 30, 1, -4): (0, 1), (9, 30, 1, -3): (0, 1), (9, 30, 1, -2): (0, 1), (9, 30, 1, -1): (0, 0), (9, 30, 1, 0): (0, -1), (9, 30, 1, 1): (0, 1), (9, 30, 1, 2): (0, 1), (9, 30, 1, 3): (0, 1), (9, 30, 1, 4): (0, 1), (9, 30, 1, 5): (0, 1), (9, 30, 2, -5): (0, 1), (9, 30, 2, -4): (0, 1), (9, 30, 2, -3): (0, 1), (9, 30, 2, -2): (0, 1), (9, 30, 2, -1): (0, 0), (9, 30, 2, 0): (-1, -1), (9, 30, 2, 1): (0, 1), (9, 30, 2, 2): (0, 1), (9, 30, 2, 3): (0, 1), (9, 30, 2, 4): (0, 1), (9, 30, 2, 5): (0, 1), (9, 30, 3, -5): (0, 1), (9, 30, 3, -4): (0, 1), (9, 30, 3, -3): (0, 1), (9, 30, 3, -2): (0, 1), (9, 30, 3, -1): (0, 0), (9, 30, 3, 0): (-1, -1), (9, 30, 3, 1): (0, 1), (9, 30, 3, 2): (0, 1), (9, 30, 3, 3): (0, 1), (9, 30, 3, 4): (0, 1), (9, 30, 3, 5): (0, 1), (9, 30, 4, -5): (0, 1), (9, 30, 4, -4): (0, 1), (9, 30, 4, -3): (0, 1), (9, 30, 4, -2): (0, 1), (9, 30, 4, -1): (0, 0), (9, 30, 4, 0): (-1, -1), (9, 30, 4, 1): (0, 1), (9, 30, 4, 2): (0, 1), (9, 30, 4, 3): (0, 1), (9, 30, 4, 4): (0, 1), (9, 30, 4, 5): (0, 1), (9, 30, 5, -5): (0, 1), (9, 30, 5, -4): (0, 1), (9, 30, 5, -3): (0, 1), (9, 30, 5, -2): (0, 1), (9, 30, 5, -1): (0, 0), (9, 30, 5, 0): (-1, -1), (9, 30, 5, 1): (0, 1), (9, 30, 5, 2): (0, 1), (9, 30, 5, 3): (0, 1), (9, 30, 5, 4): (0, 1), (9, 30, 5, 5): (0, 1), (9, 31, -5, -5): (0, 1), (9, 31, -5, -4): (0, 1), (9, 31, -5, -3): (0, 1), (9, 31, -5, -2): (0, 1), (9, 31, -5, -1): (0, 1), (9, 31, -5, 0): (0, 1), (9, 31, -5, 1): (0, 1), (9, 31, -5, 2): (0, 0), (9, 31, -5, 3): (-1, -1), (9, 31, -5, 4): (0, 0), (9, 31, -5, 5): (-1, -1), (9, 31, -4, -5): (0, 1), (9, 31, -4, -4): (0, 1), (9, 31, -4, -3): (0, 1), (9, 31, -4, -2): (1, 1), (9, 31, -4, -1): (1, 1), (9, 31, -4, 0): (0, 1), (9, 31, -4, 1): (0, 1), (9, 31, -4, 2): (0, 0), (9, 31, -4, 3): (-1, -1), (9, 31, -4, 4): (0, 0), (9, 31, -4, 5): (-1, -1), (9, 31, -3, -5): (-1, 1), (9, 31, -3, -4): (-1, 1), (9, 31, -3, -3): (-1, 1), (9, 31, -3, -2): (0, 1), (9, 31, -3, -1): (0, 1), (9, 31, -3, 0): (-1, 1), (9, 31, -3, 1): (-1, 1), (9, 31, -3, 2): (-1, 0), (9, 31, -3, 3): (-1, -1), (9, 31, -3, 4): (-1, 0), (9, 31, -3, 5): (-1, -1), (9, 31, -2, -5): (0, 1), (9, 31, -2, -4): (0, 1), (9, 31, -2, -3): (0, 1), (9, 31, -2, -2): (-1, 1), (9, 31, -2, -1): (-1, 1), (9, 31, -2, 0): (-1, 1), (9, 31, -2, 1): (-1, 0), (9, 31, -2, 2): (-1, -1), (9, 31, -2, 3): (-1, -1), (9, 31, -2, 4): (-1, 0), (9, 31, -2, 5): (-1, -1), (9, 31, -1, -5): (-1, 1), (9, 31, -1, -4): (1, 1), (9, 31, -1, -3): (1, 1), (9, 31, -1, -2): (1, 1), (9, 31, -1, -1): (-1, 1), (9, 31, -1, 0): (-1, 1), (9, 31, -1, 1): (-1, 0), (9, 31, -1, 2): (-1, -1), (9, 31, -1, 3): (-1, -1), (9, 31, -1, 4): (-1, 0), (9, 31, -1, 5): (-1, -1), (9, 31, 0, -5): (1, 1), (9, 31, 0, -4): (1, 1), (9, 31, 0, -3): (1, 1), (9, 31, 0, -2): (1, 0), (9, 31, 0, -1): (-1, 1), (9, 31, 0, 0): (-1, 1), (9, 31, 0, 1): (-1, 0), (9, 31, 0, 2): (-1, -1), (9, 31, 0, 3): (-1, -1), (9, 31, 0, 4): (-1, 1), (9, 31, 0, 5): (-1, 1), (9, 31, 1, -5): (0, 1), (9, 31, 1, -4): (0, 1), (9, 31, 1, -3): (0, 1), (9, 31, 1, -2): (0, 0), (9, 31, 1, -1): (0, -1), (9, 31, 1, 0): (0, 1), (9, 31, 1, 1): (0, 1), (9, 31, 1, 2): (0, 1), (9, 31, 1, 3): (0, 1), (9, 31, 1, 4): (0, 1), (9, 31, 1, 5): (0, 1), (9, 31, 2, -5): (0, 1), (9, 31, 2, -4): (0, 1), (9, 31, 2, -3): (0, 1), (9, 31, 2, -2): (0, 0), (9, 31, 2, -1): (-1, -1), (9, 31, 2, 0): (0, 1), (9, 31, 2, 1): (0, 1), (9, 31, 2, 2): (0, 1), (9, 31, 2, 3): (0, 1), (9, 31, 2, 4): (0, 1), (9, 31, 2, 5): (0, 1), (9, 31, 3, -5): (0, 1), (9, 31, 3, -4): (0, 1), (9, 31, 3, -3): (0, 1), (9, 31, 3, -2): (0, 0), (9, 31, 3, -1): (-1, -1), (9, 31, 3, 0): (0, 1), (9, 31, 3, 1): (0, 1), (9, 31, 3, 2): (0, 1), (9, 31, 3, 3): (0, 1), (9, 31, 3, 4): (0, 1), (9, 31, 3, 5): (0, 1), (9, 31, 4, -5): (0, 1), (9, 31, 4, -4): (0, 1), (9, 31, 4, -3): (0, 1), (9, 31, 4, -2): (0, 0), (9, 31, 4, -1): (-1, -1), (9, 31, 4, 0): (0, 1), (9, 31, 4, 1): (0, 1), (9, 31, 4, 2): (0, 1), (9, 31, 4, 3): (0, 1), (9, 31, 4, 4): (0, 1), (9, 31, 4, 5): (0, 1), (9, 31, 5, -5): (0, 1), (9, 31, 5, -4): (0, 1), (9, 31, 5, -3): (0, 1), (9, 31, 5, -2): (0, 0), (9, 31, 5, -1): (-1, -1), (9, 31, 5, 0): (0, 1), (9, 31, 5, 1): (0, 1), (9, 31, 5, 2): (0, 1), (9, 31, 5, 3): (0, 1), (9, 31, 5, 4): (0, 1), (9, 31, 5, 5): (0, 1), (9, 32, -5, -5): (0, 1), (9, 32, -5, -4): (0, 1), (9, 32, -5, -3): (0, 1), (9, 32, -5, -2): (0, 1), (9, 32, -5, -1): (0, 1), (9, 32, -5, 0): (0, 1), (9, 32, -5, 1): (0, 0), (9, 32, -5, 2): (-1, -1), (9, 32, -5, 3): (-1, -1), (9, 32, -5, 4): (-1, -1), (9, 32, -5, 5): (0, 1), (9, 32, -4, -5): (0, 1), (9, 32, -4, -4): (0, 1), (9, 32, -4, -3): (1, 1), (9, 32, -4, -2): (-1, 1), (9, 32, -4, -1): (0, 1), (9, 32, -4, 0): (0, 1), (9, 32, -4, 1): (0, 0), (9, 32, -4, 2): (-1, -1), (9, 32, -4, 3): (-1, -1), (9, 32, -4, 4): (-1, -1), (9, 32, -4, 5): (-1, 1), (9, 32, -3, -5): (-1, 1), (9, 32, -3, -4): (-1, 1), (9, 32, -3, -3): (0, 1), (9, 32, -3, -2): (0, 1), (9, 32, -3, -1): (-1, 1), (9, 32, -3, 0): (-1, 1), (9, 32, -3, 1): (-1, 0), (9, 32, -3, 2): (-1, -1), (9, 32, -3, 3): (-1, -1), (9, 32, -3, 4): (-1, -1), (9, 32, -3, 5): (-1, 1), (9, 32, -2, -5): (0, 1), (9, 32, -2, -4): (0, 1), (9, 32, -2, -3): (-1, 1), (9, 32, -2, -2): (-1, 1), (9, 32, -2, -1): (-1, 1), (9, 32, -2, 0): (-1, 1), (9, 32, -2, 1): (-1, 0), (9, 32, -2, 2): (-1, -1), (9, 32, -2, 3): (-1, 0), (9, 32, -2, 4): (-1, -1), (9, 32, -2, 5): (-1, 1), (9, 32, -1, -5): (1, 1), (9, 32, -1, -4): (1, 1), (9, 32, -1, -3): (1, 1), (9, 32, -1, -2): (-1, 1), (9, 32, -1, -1): (-1, 1), (9, 32, -1, 0): (-1, 0), (9, 32, -1, 1): (-1, -1), (9, 32, -1, 2): (-1, -1), (9, 32, -1, 3): (-1, -1), (9, 32, -1, 4): (-1, -1), (9, 32, -1, 5): (-1, 1), (9, 32, 0, -5): (1, 1), (9, 32, 0, -4): (1, 1), (9, 32, 0, -3): (1, 0), (9, 32, 0, -2): (-1, 1), (9, 32, 0, -1): (-1, 1), (9, 32, 0, 0): (-1, 0), (9, 32, 0, 1): (-1, -1), (9, 32, 0, 2): (-1, -1), (9, 32, 0, 3): (-1, -1), (9, 32, 0, 4): (-1, 1), (9, 32, 0, 5): (-1, 1), (9, 32, 1, -5): (0, 1), (9, 32, 1, -4): (0, 1), (9, 32, 1, -3): (0, 0), (9, 32, 1, -2): (0, -1), (9, 32, 1, -1): (0, 1), (9, 32, 1, 0): (0, 1), (9, 32, 1, 1): (0, 1), (9, 32, 1, 2): (0, 1), (9, 32, 1, 3): (0, 1), (9, 32, 1, 4): (0, 1), (9, 32, 1, 5): (0, 1), (9, 32, 2, -5): (0, 1), (9, 32, 2, -4): (0, 1), (9, 32, 2, -3): (0, 0), (9, 32, 2, -2): (-1, -1), (9, 32, 2, -1): (0, 1), (9, 32, 2, 0): (0, 1), (9, 32, 2, 1): (0, 1), (9, 32, 2, 2): (0, 1), (9, 32, 2, 3): (0, 1), (9, 32, 2, 4): (0, 1), (9, 32, 2, 5): (0, 1), (9, 32, 3, -5): (0, 1), (9, 32, 3, -4): (0, 1), (9, 32, 3, -3): (0, 0), (9, 32, 3, -2): (-1, -1), (9, 32, 3, -1): (0, 1), (9, 32, 3, 0): (0, 1), (9, 32, 3, 1): (0, 1), (9, 32, 3, 2): (0, 1), (9, 32, 3, 3): (0, 1), (9, 32, 3, 4): (0, 1), (9, 32, 3, 5): (0, 1), (9, 32, 4, -5): (0, 1), (9, 32, 4, -4): (0, 1), (9, 32, 4, -3): (0, 0), (9, 32, 4, -2): (-1, -1), (9, 32, 4, -1): (0, 1), (9, 32, 4, 0): (0, 1), (9, 32, 4, 1): (0, 1), (9, 32, 4, 2): (0, 1), (9, 32, 4, 3): (0, 1), (9, 32, 4, 4): (0, 1), (9, 32, 4, 5): (0, 1), (9, 32, 5, -5): (0, 1), (9, 32, 5, -4): (0, 1), (9, 32, 5, -3): (0, 0), (9, 32, 5, -2): (-1, -1), (9, 32, 5, -1): (0, 1), (9, 32, 5, 0): (0, 1), (9, 32, 5, 1): (0, 1), (9, 32, 5, 2): (0, 1), (9, 32, 5, 3): (0, 1), (9, 32, 5, 4): (0, 1), (9, 32, 5, 5): (0, 1), (9, 33, -5, -5): (0, 1), (9, 33, -5, -4): (0, 1), (9, 33, -5, -3): (0, 1), (9, 33, -5, -2): (0, 1), (9, 33, -5, -1): (0, 1), (9, 33, -5, 0): (0, 1), (9, 33, -5, 1): (0, 0), (9, 33, -5, 2): (-1, -1), (9, 33, -5, 3): (-1, -1), (9, 33, -5, 4): (0, 1), (9, 33, -5, 5): (0, 1), (9, 33, -4, -5): (0, 1), (9, 33, -4, -4): (0, 1), (9, 33, -4, -3): (-1, 1), (9, 33, -4, -2): (0, 1), (9, 33, -4, -1): (0, 1), (9, 33, -4, 0): (0, 1), (9, 33, -4, 1): (0, 0), (9, 33, -4, 2): (-1, -1), (9, 33, -4, 3): (-1, -1), (9, 33, -4, 4): (-1, 1), (9, 33, -4, 5): (-1, 1), (9, 33, -3, -5): (-1, 1), (9, 33, -3, -4): (-1, 1), (9, 33, -3, -3): (0, 1), (9, 33, -3, -2): (-1, 1), (9, 33, -3, -1): (-1, 1), (9, 33, -3, 0): (-1, 1), (9, 33, -3, 1): (-1, 0), (9, 33, -3, 2): (-1, -1), (9, 33, -3, 3): (-1, -1), (9, 33, -3, 4): (-1, 1), (9, 33, -3, 5): (-1, 1), (9, 33, -2, -5): (0, 1), (9, 33, -2, -4): (0, 1), (9, 33, -2, -3): (-1, 1), (9, 33, -2, -2): (-1, 1), (9, 33, -2, -1): (-1, 1), (9, 33, -2, 0): (-1, 0), (9, 33, -2, 1): (-1, -1), (9, 33, -2, 2): (-1, -1), (9, 33, -2, 3): (-1, -1), (9, 33, -2, 4): (-1, 1), (9, 33, -2, 5): (-1, 1), (9, 33, -1, -5): (1, 1), (9, 33, -1, -4): (1, 1), (9, 33, -1, -3): (0, 1), (9, 33, -1, -2): (-1, 1), (9, 33, -1, -1): (-1, 1), (9, 33, -1, 0): (-1, 0), (9, 33, -1, 1): (-1, -1), (9, 33, -1, 2): (-1, -1), (9, 33, -1, 3): (-1, -1), (9, 33, -1, 4): (-1, 1), (9, 33, -1, 5): (-1, 1), (9, 33, 0, -5): (1, 1), (9, 33, 0, -4): (1, 0), (9, 33, 0, -3): (1, -1), (9, 33, 0, -2): (-1, 1), (9, 33, 0, -1): (-1, 1), (9, 33, 0, 0): (-1, 0), (9, 33, 0, 1): (-1, -1), (9, 33, 0, 2): (-1, -1), (9, 33, 0, 3): (-1, 1), (9, 33, 0, 4): (-1, 1), (9, 33, 0, 5): (-1, 1), (9, 33, 1, -5): (0, 1), (9, 33, 1, -4): (0, 0), (9, 33, 1, -3): (0, -1), (9, 33, 1, -2): (0, 1), (9, 33, 1, -1): (0, 1), (9, 33, 1, 0): (0, 1), (9, 33, 1, 1): (0, 1), (9, 33, 1, 2): (0, 1), (9, 33, 1, 3): (0, 1), (9, 33, 1, 4): (0, 1), (9, 33, 1, 5): (0, 1), (9, 33, 2, -5): (0, 1), (9, 33, 2, -4): (0, 0), (9, 33, 2, -3): (-1, -1), (9, 33, 2, -2): (0, 1), (9, 33, 2, -1): (0, 1), (9, 33, 2, 0): (0, 1), (9, 33, 2, 1): (0, 1), (9, 33, 2, 2): (0, 1), (9, 33, 2, 3): (0, 1), (9, 33, 2, 4): (0, 1), (9, 33, 2, 5): (0, 1), (9, 33, 3, -5): (0, 1), (9, 33, 3, -4): (0, 0), (9, 33, 3, -3): (-1, -1), (9, 33, 3, -2): (0, 1), (9, 33, 3, -1): (0, 1), (9, 33, 3, 0): (0, 1), (9, 33, 3, 1): (0, 1), (9, 33, 3, 2): (0, 1), (9, 33, 3, 3): (0, 1), (9, 33, 3, 4): (0, 1), (9, 33, 3, 5): (0, 1), (9, 33, 4, -5): (0, 1), (9, 33, 4, -4): (0, 0), (9, 33, 4, -3): (-1, -1), (9, 33, 4, -2): (0, 1), (9, 33, 4, -1): (0, 1), (9, 33, 4, 0): (0, 1), (9, 33, 4, 1): (0, 1), (9, 33, 4, 2): (0, 1), (9, 33, 4, 3): (0, 1), (9, 33, 4, 4): (0, 1), (9, 33, 4, 5): (0, 1), (9, 33, 5, -5): (0, 1), (9, 33, 5, -4): (0, 0), (9, 33, 5, -3): (-1, -1), (9, 33, 5, -2): (0, 1), (9, 33, 5, -1): (0, 1), (9, 33, 5, 0): (0, 1), (9, 33, 5, 1): (0, 1), (9, 33, 5, 2): (0, 1), (9, 33, 5, 3): (0, 1), (9, 33, 5, 4): (0, 1), (9, 33, 5, 5): (0, 1), (9, 34, -5, -5): (0, 1), (9, 34, -5, -4): (0, 1), (9, 34, -5, -3): (0, 1), (9, 34, -5, -2): (0, 1), (9, 34, -5, -1): (0, 1), (9, 34, -5, 0): (0, 0), (9, 34, -5, 1): (-1, -1), (9, 34, -5, 2): (-1, -1), (9, 34, -5, 3): (0, 1), (9, 34, -5, 4): (0, 1), (9, 34, -5, 5): (0, 1), (9, 34, -4, -5): (0, 1), (9, 34, -4, -4): (-1, 1), (9, 34, -4, -3): (-1, 1), (9, 34, -4, -2): (0, 1), (9, 34, -4, -1): (0, 1), (9, 34, -4, 0): (0, 0), (9, 34, -4, 1): (-1, -1), (9, 34, -4, 2): (-1, -1), (9, 34, -4, 3): (-1, 1), (9, 34, -4, 4): (-1, 1), (9, 34, -4, 5): (-1, 1), (9, 34, -3, -5): (-1, 1), (9, 34, -3, -4): (0, 1), (9, 34, -3, -3): (0, 1), (9, 34, -3, -2): (-1, 1), (9, 34, -3, -1): (-1, 1), (9, 34, -3, 0): (-1, 0), (9, 34, -3, 1): (-1, -1), (9, 34, -3, 2): (-1, -1), (9, 34, -3, 3): (-1, 1), (9, 34, -3, 4): (-1, 1), (9, 34, -3, 5): (-1, 1), (9, 34, -2, -5): (0, 1), (9, 34, -2, -4): (-1, 1), (9, 34, -2, -3): (-1, 1), (9, 34, -2, -2): (-1, 1), (9, 34, -2, -1): (-1, 1), (9, 34, -2, 0): (-1, 0), (9, 34, -2, 1): (-1, -1), (9, 34, -2, 2): (-1, -1), (9, 34, -2, 3): (-1, 1), (9, 34, -2, 4): (-1, 1), (9, 34, -2, 5): (-1, 1), (9, 34, -1, -5): (1, 1), (9, 34, -1, -4): (1, 1), (9, 34, -1, -3): (-1, 1), (9, 34, -1, -2): (-1, 1), (9, 34, -1, -1): (-1, 1), (9, 34, -1, 0): (-1, 0), (9, 34, -1, 1): (-1, -1), (9, 34, -1, 2): (-1, -1), (9, 34, -1, 3): (-1, 1), (9, 34, -1, 4): (-1, 1), (9, 34, -1, 5): (-1, 1), (9, 34, 0, -5): (1, 0), (9, 34, 0, -4): (1, -1), (9, 34, 0, -3): (1, 1), (9, 34, 0, -2): (-1, 1), (9, 34, 0, -1): (-1, 1), (9, 34, 0, 0): (-1, 0), (9, 34, 0, 1): (-1, -1), (9, 34, 0, 2): (-1, -1), (9, 34, 0, 3): (-1, 1), (9, 34, 0, 4): (-1, 1), (9, 34, 0, 5): (-1, 1), (9, 34, 1, -5): (0, 0), (9, 34, 1, -4): (0, -1), (9, 34, 1, -3): (0, 1), (9, 34, 1, -2): (0, 1), (9, 34, 1, -1): (0, 1), (9, 34, 1, 0): (0, 1), (9, 34, 1, 1): (0, 1), (9, 34, 1, 2): (0, 1), (9, 34, 1, 3): (0, 1), (9, 34, 1, 4): (0, 1), (9, 34, 1, 5): (0, 1), (9, 34, 2, -5): (0, 0), (9, 34, 2, -4): (-1, -1), (9, 34, 2, -3): (0, 1), (9, 34, 2, -2): (0, 1), (9, 34, 2, -1): (0, 1), (9, 34, 2, 0): (0, 1), (9, 34, 2, 1): (0, 1), (9, 34, 2, 2): (0, 1), (9, 34, 2, 3): (0, 1), (9, 34, 2, 4): (0, 1), (9, 34, 2, 5): (0, 1), (9, 34, 3, -5): (0, 0), (9, 34, 3, -4): (-1, -1), (9, 34, 3, -3): (0, 1), (9, 34, 3, -2): (0, 1), (9, 34, 3, -1): (0, 1), (9, 34, 3, 0): (0, 1), (9, 34, 3, 1): (0, 1), (9, 34, 3, 2): (0, 1), (9, 34, 3, 3): (0, 1), (9, 34, 3, 4): (0, 1), (9, 34, 3, 5): (0, 1), (9, 34, 4, -5): (0, 0), (9, 34, 4, -4): (-1, -1), (9, 34, 4, -3): (0, 1), (9, 34, 4, -2): (0, 1), (9, 34, 4, -1): (0, 1), (9, 34, 4, 0): (0, 1), (9, 34, 4, 1): (0, 1), (9, 34, 4, 2): (0, 1), (9, 34, 4, 3): (0, 1), (9, 34, 4, 4): (0, 1), (9, 34, 4, 5): (0, 1), (9, 34, 5, -5): (0, 0), (9, 34, 5, -4): (-1, -1), (9, 34, 5, -3): (0, 1), (9, 34, 5, -2): (0, 1), (9, 34, 5, -1): (0, 1), (9, 34, 5, 0): (0, 1), (9, 34, 5, 1): (0, 1), (9, 34, 5, 2): (0, 1), (9, 34, 5, 3): (0, 1), (9, 34, 5, 4): (0, 1), (9, 34, 5, 5): (0, 1), (9, 35, -5, -5): (0, 1), (9, 35, -5, -4): (0, 1), (9, 35, -5, -3): (0, 1), (9, 35, -5, -2): (0, 1), (9, 35, -5, -1): (0, 1), (9, 35, -5, 0): (0, 0), (9, 35, -5, 1): (-1, -1), (9, 35, -5, 2): (0, 1), (9, 35, -5, 3): (0, 1), (9, 35, -5, 4): (0, 1), (9, 35, -5, 5): (0, 1), (9, 35, -4, -5): (-1, 1), (9, 35, -4, -4): (-1, 1), (9, 35, -4, -3): (0, 1), (9, 35, -4, -2): (0, 1), (9, 35, -4, -1): (0, 1), (9, 35, -4, 0): (0, 0), (9, 35, -4, 1): (-1, -1), (9, 35, -4, 2): (-1, 1), (9, 35, -4, 3): (-1, 1), (9, 35, -4, 4): (-1, 1), (9, 35, -4, 5): (-1, 1), (9, 35, -3, -5): (-1, 1), (9, 35, -3, -4): (-1, 1), (9, 35, -3, -3): (-1, 1), (9, 35, -3, -2): (-1, 1), (9, 35, -3, -1): (-1, 1), (9, 35, -3, 0): (-1, 0), (9, 35, -3, 1): (-1, -1), (9, 35, -3, 2): (-1, 1), (9, 35, -3, 3): (-1, 1), (9, 35, -3, 4): (-1, 1), (9, 35, -3, 5): (-1, 1), (9, 35, -2, -5): (0, 1), (9, 35, -2, -4): (-1, 1), (9, 35, -2, -3): (-1, 1), (9, 35, -2, -2): (-1, 1), (9, 35, -2, -1): (-1, 1), (9, 35, -2, 0): (-1, 0), (9, 35, -2, 1): (-1, -1), (9, 35, -2, 2): (-1, 1), (9, 35, -2, 3): (-1, 1), (9, 35, -2, 4): (-1, 1), (9, 35, -2, 5): (-1, 1), (9, 35, -1, -5): (1, 1), (9, 35, -1, -4): (-1, 1), (9, 35, -1, -3): (-1, 1), (9, 35, -1, -2): (-1, 1), (9, 35, -1, -1): (-1, 1), (9, 35, -1, 0): (-1, 0), (9, 35, -1, 1): (-1, -1), (9, 35, -1, 2): (-1, 1), (9, 35, -1, 3): (-1, 1), (9, 35, -1, 4): (-1, 1), (9, 35, -1, 5): (-1, 1), (9, 35, 0, -5): (1, 0), (9, 35, 0, -4): (1, 1), (9, 35, 0, -3): (-1, 1), (9, 35, 0, -2): (-1, 1), (9, 35, 0, -1): (-1, 1), (9, 35, 0, 0): (-1, 0), (9, 35, 0, 1): (-1, -1), (9, 35, 0, 2): (-1, 1), (9, 35, 0, 3): (-1, 1), (9, 35, 0, 4): (-1, 1), (9, 35, 0, 5): (-1, 1), (9, 35, 1, -5): (0, 0), (9, 35, 1, -4): (0, 1), (9, 35, 1, -3): (0, 1), (9, 35, 1, -2): (0, 1), (9, 35, 1, -1): (0, 1), (9, 35, 1, 0): (0, 1), (9, 35, 1, 1): (0, 1), (9, 35, 1, 2): (0, 1), (9, 35, 1, 3): (0, 1), (9, 35, 1, 4): (0, 1), (9, 35, 1, 5): (0, 1), (9, 35, 2, -5): (0, 0), (9, 35, 2, -4): (0, 1), (9, 35, 2, -3): (0, 1), (9, 35, 2, -2): (0, 1), (9, 35, 2, -1): (0, 1), (9, 35, 2, 0): (0, 1), (9, 35, 2, 1): (0, 1), (9, 35, 2, 2): (0, 1), (9, 35, 2, 3): (0, 1), (9, 35, 2, 4): (0, 1), (9, 35, 2, 5): (0, 1), (9, 35, 3, -5): (0, 0), (9, 35, 3, -4): (0, 1), (9, 35, 3, -3): (0, 1), (9, 35, 3, -2): (0, 1), (9, 35, 3, -1): (0, 1), (9, 35, 3, 0): (0, 1), (9, 35, 3, 1): (0, 1), (9, 35, 3, 2): (0, 1), (9, 35, 3, 3): (0, 1), (9, 35, 3, 4): (0, 1), (9, 35, 3, 5): (0, 1), (9, 35, 4, -5): (0, 0), (9, 35, 4, -4): (0, 1), (9, 35, 4, -3): (0, 1), (9, 35, 4, -2): (0, 1), (9, 35, 4, -1): (0, 1), (9, 35, 4, 0): (0, 1), (9, 35, 4, 1): (0, 1), (9, 35, 4, 2): (0, 1), (9, 35, 4, 3): (0, 1), (9, 35, 4, 4): (0, 1), (9, 35, 4, 5): (0, 1), (9, 35, 5, -5): (0, 0), (9, 35, 5, -4): (0, 1), (9, 35, 5, -3): (0, 1), (9, 35, 5, -2): (0, 1), (9, 35, 5, -1): (0, 1), (9, 35, 5, 0): (0, 1), (9, 35, 5, 1): (0, 1), (9, 35, 5, 2): (0, 1), (9, 35, 5, 3): (0, 1), (9, 35, 5, 4): (0, 1), (9, 35, 5, 5): (0, 1)} game = Game('tracks/L-track.txt', success_chance=.8) vi = ValueIteration(game) # num_steps_taken = vi.execute_policy(x) # print(num_steps_taken) avg_num_steps = 0 for itter in range(100): num_steps = vi.execute_policy(x) avg_num_steps += num_steps avg_num_steps /= 100.0 print(avg_num_steps)
MaxRobinson/CS449
project7/extra.py
Python
apache-2.0
494,316
# Copyright (c) 2016 Ansible, Inc. # All Rights Reserved. # Python import json # Django from django.db import models # Tower from awx.main.models.base import CreatedModifiedModel, prevent_search from awx.main.fields import JSONField from awx.main.utils import encrypt_field from awx.conf import settings_registry __all__ = ['Setting'] class Setting(CreatedModifiedModel): key = models.CharField( max_length=255, ) value = JSONField( null=True, ) user = prevent_search(models.ForeignKey( 'auth.User', related_name='settings', default=None, null=True, editable=False, on_delete=models.CASCADE, )) def __str__(self): try: json_value = json.dumps(self.value) except ValueError: # In the rare case the DB value is invalid JSON. json_value = u'<Invalid JSON>' if self.user: return u'{} ({}) = {}'.format(self.key, self.user, json_value) else: return u'{} = {}'.format(self.key, json_value) def save(self, *args, **kwargs): encrypted = settings_registry.is_setting_encrypted(self.key) new_instance = not bool(self.pk) # If update_fields has been specified, add our field names to it, # if it hasn't been specified, then we're just doing a normal save. update_fields = kwargs.get('update_fields', []) # When first saving to the database, don't store any encrypted field # value, but instead save it until after the instance is created. # Otherwise, store encrypted value to the database. if encrypted: if new_instance: self._saved_value = self.value self.value = '' else: self.value = encrypt_field(self, 'value') if 'value' not in update_fields: update_fields.append('value') super(Setting, self).save(*args, **kwargs) # After saving a new instance for the first time, set the encrypted # field and save again. if encrypted and new_instance: from awx.main.signals import disable_activity_stream with disable_activity_stream(): self.value = self._saved_value self.save(update_fields=['value']) @classmethod def get_cache_key(self, key): return key @classmethod def get_cache_id_key(self, key): return '{}_ID'.format(key) def display_value(self): if self.key == 'LICENSE' and 'license_key' in self.value: # don't log the license key in activity stream value = self.value.copy() value['license_key'] = '********' return value return self.value import awx.conf.signals # noqa from awx.main.registrar import activity_stream_registrar # noqa activity_stream_registrar.connect(Setting) import awx.conf.access # noqa
GoogleCloudPlatform/sap-deployment-automation
third_party/github.com/ansible/awx/awx/conf/models.py
Python
apache-2.0
2,977
# -*- coding: utf-8 -*- # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from typing import ( Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator, ) from google.cloud.compute_v1.types import compute class AggregatedListPager: """A pager for iterating through ``aggregated_list`` requests. This class thinly wraps an initial :class:`google.cloud.compute_v1.types.CommitmentAggregatedList` object, and provides an ``__iter__`` method to iterate through its ``items`` field. If there are more pages, the ``__iter__`` method will make additional ``AggregatedList`` requests and continue to iterate through the ``items`` field on the corresponding responses. All the usual :class:`google.cloud.compute_v1.types.CommitmentAggregatedList` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ def __init__( self, method: Callable[..., compute.CommitmentAggregatedList], request: compute.AggregatedListRegionCommitmentsRequest, response: compute.CommitmentAggregatedList, *, metadata: Sequence[Tuple[str, str]] = () ): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.compute_v1.types.AggregatedListRegionCommitmentsRequest): The initial request object. response (google.cloud.compute_v1.types.CommitmentAggregatedList): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ self._method = method self._request = compute.AggregatedListRegionCommitmentsRequest(request) self._response = response self._metadata = metadata def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property def pages(self) -> Iterator[compute.CommitmentAggregatedList]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response def __iter__(self) -> Iterator[Tuple[str, compute.CommitmentsScopedList]]: for page in self.pages: yield from page.items.items() def get(self, key: str) -> Optional[compute.CommitmentsScopedList]: return self._response.items.get(key) def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) class ListPager: """A pager for iterating through ``list`` requests. This class thinly wraps an initial :class:`google.cloud.compute_v1.types.CommitmentList` object, and provides an ``__iter__`` method to iterate through its ``items`` field. If there are more pages, the ``__iter__`` method will make additional ``List`` requests and continue to iterate through the ``items`` field on the corresponding responses. All the usual :class:`google.cloud.compute_v1.types.CommitmentList` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ def __init__( self, method: Callable[..., compute.CommitmentList], request: compute.ListRegionCommitmentsRequest, response: compute.CommitmentList, *, metadata: Sequence[Tuple[str, str]] = () ): """Instantiate the pager. Args: method (Callable): The method that was originally called, and which instantiated this pager. request (google.cloud.compute_v1.types.ListRegionCommitmentsRequest): The initial request object. response (google.cloud.compute_v1.types.CommitmentList): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. """ self._method = method self._request = compute.ListRegionCommitmentsRequest(request) self._response = response self._metadata = metadata def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property def pages(self) -> Iterator[compute.CommitmentList]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response def __iter__(self) -> Iterator[compute.Commitment]: for page in self.pages: yield from page.items def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response)
googleapis/python-compute
google/cloud/compute_v1/services/region_commitments/pagers.py
Python
apache-2.0
5,692