code
stringlengths 3
1.05M
| repo_name
stringlengths 5
104
| path
stringlengths 4
251
| language
stringclasses 1
value | license
stringclasses 15
values | size
int64 3
1.05M
|
---|---|---|---|---|---|
# Support Python 2 and 3
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import print_function
import sys, os
from collections import OrderedDict
if sys.version_info < (3,):
import odpslides.ElementTree_27OD as ET
else:
import odpslides.ElementTree_34OD as ET
from odpslides.find_obj import find_elem_w_attrib, NS_attrib, NS
from odpslides.namespace import XMLNS_STR, force_to_short, force_to_tag
from odpslides.namespace import python_param_from_tag, python_def_from_tag
func_quick_lookupD = {} # index=display name, value=function name
layout_name_lookupD = {} # index=display-name "Title Only", value=layout name "Master1-PPL6"
display_name_lookupD = {} # index=layout name "Master1-PPL6", display-name "Title Only"
def fix_utf8( s ):
cL = []
#s = s.encode('utf-8')
for c in s:
if ord(c) >= 128:
cL.append( '\\x%X'%ord(c) )
else:
cL.append( c )
return ''.join(cL)
def make_function_from_root( root, tmplt_obj, suffix='' ):
"""build python source to make the Elements from scratch"""
suffix = suffix.replace(',','_')
if suffix in func_quick_lookupD:
n = 2
while '%s_%i'%(suffix, n) in func_quick_lookupD:
n += 1
suffix = '%s_%i'%(suffix, n)
func_name = python_def_from_tag(root.tag)
if suffix:
func_name = func_name + '_%s'%python_def_from_tag(suffix)
# Used after code is generated
func_quick_lookupD[suffix] = func_name
dname = root.get( force_to_tag('style:display-name'), '' )
lname = root.get( force_to_tag('style:name'), '' )
if dname and lname:
layout_name_lookupD[dname] = lname
display_name_lookupD[lname] = dname
keyL = sorted( root.keys() )
sL = ['def %s():'%(func_name, )]
sL.append( ' ' )
doc_str = 'Build Element %s'%force_to_short(root.tag)
if suffix:
doc_str = doc_str + ' for %s'%suffix
sL.append( ''' """%s """'''%doc_str )
sL.append( ' ' )
sOut = tmplt_obj.elem_tostring(root, include_ns=False, use_linebreaks=True )
sOut = fix_utf8( sOut )
sL.append( ''' elem = build_element( """%s""" )'''%sOut )
sL.append( ' ' )
sL.append( ' return elem\n\n' )
return '\n'.join(sL)
if __name__ == "__main__":
from odpslides.odp_file import ODPFile
here = os.path.abspath(os.path.dirname(__file__))
for suffix in ['image', 'grad', 'plain', 'solidbg']:
#for suffix in ['plain']:
func_quick_lookupD.clear() # need to empty dict
layout_name_lookupD.clear()
display_name_lookupD.clear()
fname = r'D:\py_proj_2015\ODPSlides\odpslides\templates\ppt_all_layouts_%s.odp'%suffix
odp = ODPFile( fname )
py_file = os.path.join(here, suffix, 'page_layouts.py')
print('Opening:',py_file)
fOut = open( py_file, 'w' )
fOut.write( '''
# Python 2 and 3
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import print_function
"""Code Generated to build style:presentation-page-layout objects for odp files"""
import sys, os
from collections import OrderedDict
from odpslides.template_xml_file import TemplateXML_File
from odpslides.namespace import XMLNS_STR
def build_element( s ):
"""Add namespace to string and use TemplateXML_File to make Element"""
s = s.replace(' ',' %s '%XMLNS_STR, 1) # First space ONLY
return TemplateXML_File( s ).root
''' )
fOut.write('\n\n# Use func_quick_lookupD for access to function calls')
fOut.write( '\n\nfunc_quick_lookupD = {} # index=display name, value=function name\n' )
fOut.write( 'layout_name_lookupD = {}\n' )
fOut.write( 'display_name_lookupD = {}\n' )
fOut.write('\n\n')
# do style:presentation-page-layout
page_layoutL = odp.office_styles_elem.findall( force_to_tag('style:presentation-page-layout') )
for layout in page_layoutL:
fOut.write( make_function_from_root( layout, odp.styles_xml_obj,
suffix=layout.get( force_to_tag('style:display-name') ) ) )
# do style:default-style
page_layoutL = odp.office_styles_elem.findall( force_to_tag('style:default-style') )
for layout in page_layoutL:
fOut.write( make_function_from_root( layout, odp.styles_xml_obj,
suffix=layout.get( force_to_tag('style:family') ) ) )
# do draw:gradient
page_styleL = odp.office_styles_elem.findall( force_to_tag('draw:gradient') )
for style in page_styleL:
fOut.write( make_function_from_root( style, odp.styles_xml_obj, suffix='' ) )
break # only do one
# do draw:fill-image
page_styleL = odp.office_styles_elem.findall( force_to_tag('draw:fill-image') )
for style in page_styleL:
fOut.write( make_function_from_root( style, odp.styles_xml_obj, suffix='' ) )
break # only do one
fOut.write('\n\n# Set values in func_quick_lookupD\n')
keyL = sorted( func_quick_lookupD.keys() )
for key in keyL:
fOut.write( 'func_quick_lookupD["%s"] = %s\n'%(key, func_quick_lookupD[key]) )
fOut.write('\n\n')
fOut.write('\n\n# Set values in layout_name_lookupD\n')
keyL = sorted( layout_name_lookupD.keys() )
for key in keyL:
fOut.write( 'layout_name_lookupD["%s"] = "%s"\n'%(key, layout_name_lookupD[key]) )
fOut.write('\n\n')
fOut.write('\n\n# Set values in display_name_lookupD\n')
keyL = sorted( display_name_lookupD.keys() )
for key in keyL:
fOut.write( 'display_name_lookupD["%s"] = "%s"\n'%(key, display_name_lookupD[key]) )
fOut.write('\n\n')
fOut.write('''
if __name__ == "__main__":
print( func_quick_lookupD["Title Only"]() )
''')
| sonofeft/ODPSlides | odpslides/code_gen/make_page_layouts.py | Python | lgpl-3.0 | 6,050 |
#!/usr/bin/env python
import os,sys,re
from collections import defaultdict
from gzip import GzipFile
import numpy as np
from numpy import chararray as carray
from numpy import fromstring,byte
import mmap
import logging
import pysam
import optparse
import traceback
__version__ = "1.99"
__author__ = "Marvin Jens"
__credits__ = ["Marvin Jens","Marcel Schilling","Petar Glazar","Nikolaus Rajewsky"]
__status__ = "beta"
__licence__ = "GPL"
__email__ = "marvin.jens@mdc-berlin.de"
COMPLEMENT = {
'a' : 't',
't' : 'a',
'c' : 'g',
'g' : 'c',
'k' : 'm',
'm' : 'k',
'r' : 'y',
'y' : 'r',
's' : 's',
'w' : 'w',
'b' : 'v',
'v' : 'b',
'h' : 'd',
'd' : 'h',
'n' : 'n',
'A' : 'T',
'T' : 'A',
'C' : 'G',
'G' : 'C',
'K' : 'M',
'M' : 'K',
'R' : 'Y',
'Y' : 'R',
'S' : 'S',
'W' : 'W',
'B' : 'V',
'V' : 'B',
'H' : 'D',
'D' : 'H',
'N' : 'N',
}
def complement(s):
return "".join([COMPLEMENT[x] for x in s])
def rev_comp(seq):
return complement(seq)[::-1]
def k_mers(k,alphabet=['A','C','G','T',]):
if k == 1:
prefix = [""]
else:
prefix = k_mers(k-1,alphabet)
for pre in prefix:
for a in alphabet:
yield pre+a
# precompute RC of all possible 4-mers for fast
# splice signal check later on.
fast_4mer_RC = {}
for mer in k_mers(4,alphabet=['A','C','G','T','N']):
fast_4mer_RC[mer] = rev_comp(mer)
class mmap_fasta(object):
def __init__(self,fname):
f = file(fname)
header = f.readline()
row = f.readline()
self.ofs = len(header)
self.lline = len(row)
self.ldata = len(row.strip())
self.skip = self.lline-self.ldata
self.skip_char = row[self.ldata:]
self.mmap = mmap.mmap(f.fileno(),0,prot=mmap.PROT_READ)
def __getslice__(self,start,end):
l_start = start / self.ldata
l_end = end / self.ldata
ofs_start = l_start * self.skip + start + self.ofs
ofs_end = l_end * self.skip + end + self.ofs
s = self.mmap[ofs_start:ofs_end].replace(self.skip_char,"")
L = end-start
if len(s) == L:
return s
else:
return s+"N"*(L-len(s))
return
class indexed_fasta(object):
def __init__(self,fname,split_chrom="",**kwargs):
self.logger = logging.getLogger("indexed_fasta")
self.fname = fname
self.chrom_stats = {}
self.split_chrom = split_chrom
# try to load index
ipath = fname + '.byo_index'
if os.access(ipath,os.R_OK):
self.load_index(ipath)
else:
self.index()
self.store_index(ipath)
f = file(fname)
self.mmap = mmap.mmap(f.fileno(),0,prot=mmap.PROT_READ)
def index(self):
self.logger.info("# indexed_fasta.index('%s')" % self.fname)
ofs = 0
f = file(self.fname)
chrom = "undef"
chrom_ofs = 0
size = 0
nl_char = 0
for line in f:
ofs += len(line)
if line.startswith('>'):
# store size of previous sequence
if size: self.chrom_stats[chrom].append(size)
chrom = line[1:].split()[0].strip()
if self.split_chrom:
# use this to strip garbage from chrom/contig name like chr1:new
# ->split_chrom=':' -> chrom=chr1
chrom = chrom.split(self.split_chrom)[0]
chrom_ofs = ofs
else:
if not chrom in self.chrom_stats:
# this is the first line of the new chrom
size = 0
lline = len(line)
ldata = len(line.strip())
nl_char = lline - ldata
self.chrom_stats[chrom] = [chrom_ofs,ldata,nl_char,line[ldata:]]
size += len(line.strip())
# store size of previous sequence
if size: self.chrom_stats[chrom].append(size)
f.close()
def store_index(self,ipath):
self.logger.info("# indexed_fasta.store_index('%s')" % ipath)
# write to tmp-file first and in the end rename in order to have this atomic
# otherwise parallel building of the same index may screw it up.
import tempfile
tmp = tempfile.NamedTemporaryFile(mode="w",dir = os.path.dirname(ipath),delete=False)
for chrom in sorted(self.chrom_stats.keys()):
ofs,ldata,skip,skipchar,size = self.chrom_stats[chrom]
tmp.write("%s\t%d\t%d\t%d\t%r\t%d\n" % (chrom,ofs,ldata,skip,skipchar,size))
# make sure everything is on disk
os.fsync(tmp)
tmp.close()
# make it accessible to everyone
import stat
os.chmod(tmp.name, stat.S_IROTH | stat.S_IRGRP | stat.S_IRUSR)
# this is atomic on POSIX as we have created tmp in the same directory,
# therefore same filesystem
os.rename(tmp.name,ipath)
def load_index(self,ipath):
self.logger.info("# indexed_fasta.load_index('%s')" % ipath)
self.chrom_stats = {}
for line in file(ipath):
chrom,ofs,ldata,skip,skipchar,size = line.rstrip().split('\t')
self.chrom_stats[chrom] = (int(ofs),int(ldata),int(skip),skipchar[1:-1].decode('string_escape'),int(size))
def get_data(self,chrom,start,end,sense):
if not self.chrom_stats:
self.index()
ofs,ldata,skip,skip_char,size = self.chrom_stats[chrom]
pad_start = 0
pad_end = 0
if start < 0:
pad_start = -start
start = 0
if end > size:
pad_end = end - size
end = size
l_start = start / ldata
l_end = end / ldata
ofs_start = l_start * skip + start + ofs
ofs_end = l_end * skip + end + ofs
s = self.mmap[ofs_start:ofs_end].replace(skip_char,"")
if pad_start or pad_end:
s = "N"*pad_start + s + "N"*pad_end
if sense == "-":
s = rev_comp(s)
return s
class Accessor(object):
supports_write = False
def __init__(self,path,chrom,sense,sense_specific=False,**kwargs):
if sense_specific:
self.covered_strands = [chrom+sense]
else:
self.covered_strands = [chrom+'+',chrom+'-']
def get_data(self,chrom,start,end,sense,**kwargs):
return []
def get_oriented(self,chrom,start,end,sense,**kwargs):
data = self.get_data(chrom,start,end,sense,**kwargs)
if sense == "-": # self.sense_specific and
return data[::-1]
else:
return data
def get_sum(self,chrom,start,end,sense,**kwargs):
return self.get_data(chrom,start,end,sense,**kwargs).sum()
def flush(self):
pass
class Track(object):
"""
Abstraction of chromosome-wide adressable data like sequences, coverage, scores etc.
Actual access to the data is delegated to accessor objects which are instantiated on-the-fly for
each chromosome (strand) upon first access and then cached.
Use of mmap for the accessors is recommended and implemented for sequences and numpy (C-type)
arrays.
See io/track_accessors.py for more examples.
"""
def __init__(self,path,accessor,sense_specific=True,description="unlabeled track",system="hg18",dim=1,auto_flush=False,mode="r",**kwargs):
self.path = path
self.mode = mode
self.acc_cache = {}
self.accessor = accessor
self.kwargs = kwargs
self.sense_specific = sense_specific
self.dim = int(dim)
self.description = description
self.auto_flush = auto_flush
self.last_chrom = ""
self.logger = logging.getLogger("Track('%s')" % path)
self.system = system
self.logger.debug("Track(auto_flush=%s)" % (str(auto_flush)))
kwargs['sense_specific'] = self.sense_specific
kwargs['mode'] = self.mode
kwargs['system'] = self.system
kwargs['description'] = self.description
kwargs['dim'] = self.dim
def load(self,chrom,sense):
# automatically flush buffers whenever a new chromosome is seen. reduces memory-footprint for sorted input data
if self.auto_flush and chrom != self.last_chrom:
self.logger.debug("Seen new chromosome %s. Flushing accessor caches." % chrom)
self.flush_all()
self.last_chrom = chrom
ID = chrom+sense
if not ID in self.acc_cache:
self.logger.debug("Cache miss for %s%s. creating new accessor" % (chrom,sense))
acc = self.accessor(self.path,chrom,sense,**(self.kwargs))
# register the accessor for as many chromosomes/strands/contigs as it feels responsible for.
self.logger.debug("Accessor covers strands '%s'" % str(sorted(set(acc.covered_strands))))
if acc.covered_strands == '*':
# hint that this accessors covers the complete genome
self.logger.debug("disabling auto_flush and registering accessor for everything")
self.acc_cache = DummyCache(acc)
self.auto_flush = False
else:
for ID in acc.covered_strands:
self.acc_cache[ID] = acc
return self.acc_cache[ID]
def flush(self,chrom,sense):
ID = self.get_identifier(chrom,sense)
if ID in self.acc_cache:
self.logger.warning("Flushing %s%s" % (chrom,sense))
del self.acc_cache[ID]
def flush_all(self):
for a in self.acc_cache.values():
a.flush()
self.acc_cache = {}
def get(self,chrom,start,end,sense,**kwargs):
acc = self.load(chrom,sense)
return acc.get_data(chrom,start,end,sense,**kwargs)
def get_oriented(self,chrom,start,end,sense,**kwargs):
acc = self.load(chrom,sense)
return acc.get_oriented(chrom,start,end,sense,**kwargs)
def get_sum(self,chrom,start,end,sense):
#print "TRACK.GETSUM"
acc = self.load(chrom,sense)
return acc.get_sum(chrom,start,end,sense)
def get_identifier(self,chrom,sense):
if self.sense_specific:
return chrom+sense
else:
return chrom
class GenomeAccessor(Accessor):
def __init__(self,path,chrom,sense,system='hg19',**kwargs):
super(GenomeAccessor,self).__init__(path,chrom,sense,system=system,**kwargs)
self.logger = logging.getLogger("GenomeAccessor")
self.logger.info("# mmap: Loading genomic sequence for chromosome %s from '%s'" % (chrom,path))
self.system = system
self.data = None
fname = os.path.join(path)
try:
self.data = indexed_fasta(fname)
except IOError:
self.logger.warning("Could not access '%s'. Switching to dummy mode (only Ns)" % fname)
self.get_data = self.get_dummy
self.get_oriented = self.get_dummy
self.covered_strands = [chrom+'+',chrom+'-']
else:
# register for all chroms/strands
self.covered_strands = [chrom+'+' for chrom in self.data.chrom_stats.keys()] + [chrom+'-' for chrom in self.data.chrom_stats.keys()]
# TODO: maybe remove this if not needed
self.get = self.get_oriented
def load_indexed(self,path):
ipath = path+'.index'
if not os.access(ipath,os.R_OK):
index = self.build_index(path,ipath)
else:
index = self.load_index(ipath)
self.chrom_ofs = index.chrom_ofs
def get_data(self,chrom,start,end,sense):
seq = self.data.get_data(chrom,start,end,"+")
if sense == "-":
seq = complement(seq)
return seq
def get_dummy(self,chrom,start,end,sense):
return "N"*int(end-start)
usage = """
bwa mem -t<threads> [-p] -A2 -B10 -k 15 -T 1 $GENOME_INDEX reads.fastq.gz | %prog [options]
OR:
%prog [options] <bwa_mem_genome_alignments.bam>
"""
parser = optparse.OptionParser(usage=usage)
parser.add_option("-v","--version",dest="version",action="store_true",default=False,help="get version information")
parser.add_option("-S","--system",dest="system",type=str,default="",help="model system database (optional! Requires byo library.)")
parser.add_option("-G","--genome",dest="genome",type=str,default="",help="path to genome (either a folder with chr*.fa or one multichromosome FASTA file)")
parser.add_option("","--known-circ",dest="known_circ",type=str,default="",help="file with known circRNA junctions (BED6)")
parser.add_option("","--known-lin",dest="known_lin",type=str,default="",help="file with known linear splice junctions (BED6)")
parser.add_option("-o","--output",dest="output",default="find_circ_run",help="where to store output")
parser.add_option("-q","--silent",dest="silent",default=False,action="store_true",help="suppress any normal output to stdout. Automatically switched on when using --stdout redirection")
parser.add_option("","--stdout",dest="stdout",default=None,choices=['circs','lins','reads','multi','test'],help="use to direct chosen type of output (circs, lins, reads, multi) to stdout instead of file")
parser.add_option("-n","--name",dest="name",default="unknown",help="tissue/sample name to use (default='unknown')")
parser.add_option("","--min-uniq-qual",dest="min_uniq_qual",type=int,default=2,help="minimal uniqness for anchor alignments to consider (default=2)")
parser.add_option("-a","--anchor",dest="asize",type=int,default=15,help="anchor size (default=15)")
parser.add_option("-m","--margin",dest="margin",type=int,default=2,help="maximum nts the BP is allowed to reside within a segment (default=2)")
parser.add_option("-d","--max-mismatch",dest="maxdist",type=int,default=2,help="maximum mismatches (no indels) allowed in segment extensions (default=2)")
parser.add_option("","--short-threshold",dest="short_threshold",type=int,default=100,help="minimal genomic span [nt] of a circRNA before it is labeled SHORT (default=100)")
parser.add_option("","--huge-threshold",dest="huge_threshold",type=int,default=100000,help="maximal genomic span [nt] of a circRNA before it is labeled HUGE (default=100000)")
parser.add_option("","--debug",dest="debug",default=False,action="store_true",help="Activate LOTS of debug output")
parser.add_option("","--profile",dest="profile",default=False,action="store_true",help="Activate performance profiling")
parser.add_option("","--non-canonical",dest="noncanonical",default=False,action="store_true",help="relax the GU/AG constraint (will produce many more ambiguous counts)")
parser.add_option("","--all-hits",dest="allhits",default=False,action="store_true",help="in case of ambiguities, report each hit")
parser.add_option("","--stranded",dest="stranded",default=False,action="store_true",help="use if the reads are stranded. By default it will be used as control only, use with --strand-pref for breakpoint disambiguation.")
parser.add_option("","--strand-pref",dest="strandpref",default=False,action="store_true",help="prefer splice sites that match annotated direction of transcription")
parser.add_option("","--half-unique",dest="halfunique",default=False,action="store_true",help="also report junctions where only one anchor aligns uniquely (less likely to be true)")
parser.add_option("","--report-nobridges",dest="report_nobridges",default=False,action="store_true",help="also report junctions lacking at least a single read where both anchors, jointly align uniquely (not recommended. Much less likely to be true.)")
parser.add_option("-B","--bam",dest="bam",default=False,action="store_true",help="store anchor alignments that were recorded as linear or circular junction candidates")
parser.add_option("-t","--throughput",dest="throughput",default=False,action="store_true",help="print information on throughput to stderr (useful for benchmarking)")
parser.add_option("","--chunk-size",dest="chunksize",type=int,default=100000,help="number of reads to be processed in one chunk (default=100000)")
parser.add_option("","--noop",dest="noop",default=False,action="store_true",help="Do not search for any junctions. Only process the alignment stream (useful for benchmarking)")
parser.add_option("","--test",dest="test",default=False,action="store_true",help="Test mode: parse read splicing from read name and compare to reconstructed splicing. Use with specially prepared test reads only! (useful for automated regression testing)")
parser.add_option("","--no-linear",dest="nolinear",default=False,action="store_true",help="Do not investigate linear junctions, unless associated with another backsplice event (saves some time)")
parser.add_option("","--no-multi",dest="multi_events",default=True,action="store_false",help="Do not record multi-events (saves some time)")
options,args = parser.parse_args()
if options.version:
print """find_circ.py version {0}\n\n(c) Marvin Jens 2012-2016.\nCheck http://www.circbase.org for more information.""".format(__version__)
sys.exit(0)
# prepare output directory
if not os.path.isdir(options.output):
os.makedirs(options.output)
# prepare logging system
FORMAT = '%(asctime)-20s\t%(levelname)s\t%(name)s\t%(message)s'
logging.basicConfig(level=logging.INFO,format=FORMAT,filename=os.path.join(options.output,"run.log"),filemode='w')
logger = logging.getLogger('find_circ')
logger.info("find_circ {0} invoked as '{1}'".format(__version__," ".join(sys.argv)))
if options.system:
import importlib
system = importlib.import_module("byo.systems.{options.system}".format(**locals()))
genome = system.genome
if options.genome:
genome = Track(options.genome,accessor=GenomeAccessor)
if not (options.genome or options.system):
print "need to specify either model system database (-S) or genome FASTA file (-G)."
sys.exit(1)
# prepare output files
circs_file = file(os.path.join(options.output,"circ_splice_sites.bed"),"w")
lins_file = file(os.path.join(options.output,"lin_splice_sites.bed"),"w")
reads_file = GzipFile(os.path.join(options.output,"spliced_reads.fastq.gz"),"w")
multi_file = file(os.path.join(options.output,"multi_events.tsv"),"w")
if options.test:
test_file = file(os.path.join(options.output,"test_results.tsv"),"w")
else:
test_file = None
# redirect output to stdout, if requested
if options.stdout:
varname = "{0}_file".format(options.stdout)
out_file = globals()[varname]
out_file.write('# redirected to stdout\n')
logger.info('redirected {0} to stdout'.format(options.stdout))
globals()[varname] = sys.stdout
if args:
logger.info('reading from {0}'.format(args[0]))
if args[0].endswith('sam'):
sam_input = pysam.Samfile(args[0],'r')
else:
sam_input = pysam.Samfile(args[0],'rb')
else:
logger.info('reading from stdin')
sam_input = pysam.Samfile('-','r')
tid_cache = {}
def fast_chrom_lookup(read):
tid = read.tid
if not tid in tid_cache:
tid_cache[tid] = sam_input.getrname(tid)
return tid_cache[tid]
if options.bam:
bam_filename = os.path.join(options.output,"spliced_alignments.bam")
bam_out = pysam.Samfile(bam_filename,'wb',template=sam_input)
else:
bam_out = None
class Hit(object):
def __init__(self,name,splice):
self.name = name
self.reads = []
self.readnames = []
self.uniq = set()
self.mapquals_A = []
self.mapquals_B = []
self.n_weighted = 0.
self.n_spanned = 0
self.n_uniq_bridges = 0.
self.edits = []
self.overlaps = []
self.n_hits = []
self.signal = "NNNN"
self.strand_plus = 0
self.strand_minus = 0
self.strandmatch = 'NA'
self.flags = defaultdict(int)
self.read_flags = defaultdict(set)
self.tissues = defaultdict(float)
self.coord = splice.coord
self.add(splice)
def add_flag(self,flag,frag_name):
self.flags[flag] += 1
self.read_flags[frag_name].add(flag)
def get_flags_counts(self):
if not self.flags:
return ["N/A"],[0]
flags = sorted(self.flags)
counts = [self.flags[f] for f in flags]
return flags,counts
def add(self,splice):
#print self.name,self.coord,splice.junc_span,self.weighted_counts
self.signal = splice.gtag
# TODO: this belongs to output, not here!
self.strandmatch = 'N/A'
if options.stranded:
if splice.strandmatch:
self.strandmatch = "MATCH"
else:
self.strandmatch = "MISMATCH"
self.edits.append(splice.dist)
self.overlaps.append(splice.ov)
self.n_hits.append(splice.n_hits)
if splice.junc_span:
self.n_spanned += 1
self.n_weighted += splice.junc_span.weight
# TODO: Move this logic into JunctionSpan, bc it is closer to the underlying alignments
# by convention have A precede B in the genome.
A = splice.junc_span.align_A
B = splice.junc_span.align_B
read = splice.junc_span.primary.seq
weight = splice.junc_span.weight
if splice.is_backsplice:
A,B = B,A
# Alignment Score - Secondbest hit score
aopt = dict(A.tags)
bopt = dict(B.tags)
qA = aopt.get('AS') - aopt.get('XS',0)
qB = bopt.get('AS') - bopt.get('XS',0)
if qA and qB:
# both anchors from the *same read* align uniquely
self.n_uniq_bridges += weight
self.mapquals_A.append(qA)
self.mapquals_B.append(qB)
self.readnames.append(splice.junc_span.primary.qname)
# record the spliced read sequence as it was before mapping
if A.is_reverse:
self.strand_minus += weight
self.reads.append(rev_comp(read))
else:
self.strand_plus += weight
self.reads.append(read)
sample_name = options.name
self.tissues[sample_name] += weight
self.uniq.add((read,sample_name))
self.uniq.add((rev_comp(read),sample_name))
@property
def n_frags(self):
return len(set(self.readnames))
@property
def n_uniq(self):
return len(self.uniq) / 2 # forward and rev_comp sequences
def get_best_anchor_quals(self):
return sorted(self.mapquals_A,reverse=True)[0], sorted(self.mapquals_B,reverse=True)[0]
def get_tissue_names_counts(self):
tissues = sorted(self.tissues.keys())
tiss_counts = [str(self.tissues[k]) for k in tissues]
return tissues, tiss_counts
@property
def categories(self):
categories = []
if self.signal != "GTAG":
categories.append("NON_CANONICAL")
#if strandmatch == "MATCH":
#categories.append("STRANDMATCH")
best_qual_A, best_qual_B = self.get_best_anchor_quals()
if best_qual_A == 0 or best_qual_B == 0:
categories.append("WARN_NON_UNIQUE_ANCHOR")
if self.n_uniq_bridges == 0:
categories.append("WARN_NO_UNIQ_BRIDGES")
if min(self.n_hits) > 1:
categories.append("WARN_AMBIGUOUS_BP")
min_anchor_ov = min(self.overlaps)
min_edit = min(self.edits)
if min_anchor_ov == 0 and min_edit == 0:
pass
elif min_anchor_ov < 2 and min_edit < 2:
categories.append("WARN_EXT_1MM")
elif min_anchor_ov >= 2 or min_edit >= 2:
categories.append("WARN_EXT_2MM+")
chrom,start,end,sense = self.coord
if end-start < options.short_threshold:
categories.append("SHORT")
elif end-start > options.huge_threshold:
categories.append("HUGE")
unbroken_circread = 0
unwarned_circread = 0
total = 0.
for frag_name in self.read_flags.keys():
total += 1.
if not 'BROKEN_SEGMENTS' in self.read_flags[frag_name]:
unbroken_circread += 1
for w in self.read_flags[frag_name]:
if not w.startswith('WARN'):
unwarned_circread += 1
if total:
warn_ratio = 1. - unwarned_circread / total
broken_ratio = 1. - unbroken_circread / total
if not unbroken_circread:
categories.append('WARN_ALWAYS_BROKEN')
if not unwarned_circread:
categories.append('WARN_ALWAYS_WARN')
return categories
class SpliceSiteStorage(object):
def __init__(self, prefix, known):
self.prefix = prefix
self.sites = {}
self.novel_count = 0
if known:
self.load_known_sites(known)
def load_known_sites(self,fname):
n = 0
for line in file(fname):
if line.startswith('#'):
continue
parts = line.rstrip().split('\t')
chrom,start,end,name,score,sense = parts[:6] # BED6
start = int(start)
end = int(end)
coord = (chrom,start,end,sense)
self.sites[coord] = Hit(name,Splice(None,chrom,start,end,sense,10,10,'NNNN'))
n += 1
logger.info("loaded {0} known splice sites from '{1}'".format(n,fname))
def add(self,splice):
coord = splice.coord
if not coord in self.sites:
self.novel_count += 1
name = "{0}_{1}_{2:06d}".format(options.name,self.prefix,self.novel_count)
self.sites[coord] = Hit(name,splice)
else:
self.sites[coord].add(splice)
return self.sites[coord]
def __getitem__(self,coord):
return self.sites[coord]
def store_list(self,output):
output.write("#" + "\t".join(['chrom','start','end','name','n_frags','strand','n_weight','n_spanned','n_uniq','uniq_bridges','best_qual_left','best_qual_right','tissues','tiss_counts','edits','anchor_overlap','breakpoints','signal','strandmatch','category','flags','flag_counts']) + "\n")
for (chrom,start,end,sense),hit in self.sites.items():
if not hit.reads:
continue # a known splice site that was not recovered here
#n_spanned,n_weight,n_uniq,best_qual_A,best_qual_B,uniq_bridges,tissues,tiss_counts,min_edit,min_anchor_ov,n_hits,signal,strandmatch = hit.scores()
#n_spanned,self.weighted_counts,n_uniq,self.best_qual_A,self.best_qual_B,self.uniq_bridges,tissues,tiss_counts,min(self.edits),min(self.overlaps),min(self.n_hits),self.signal,self.strandmatch
best_qual_A, best_qual_B = hit.get_best_anchor_quals()
if options.halfunique:
if (best_qual_A < options.min_uniq_qual) and (best_qual_B < options.min_uniq_qual):
N['anchor_not_uniq'] += 1
continue
else:
if (best_qual_A < options.min_uniq_qual) or (best_qual_B < options.min_uniq_qual):
N['anchor_not_uniq'] += 1
continue
if (hit.n_uniq_bridges == 0) and not options.report_nobridges:
N['no_uniq_bridges'] += 1
continue
tissues, tiss_counts = hit.get_tissue_names_counts()
flags, flag_counts = hit.get_flags_counts()
bed = [
chrom, start, end, hit.name, hit.n_frags, sense, # BED6 compatible
hit.n_weighted, hit.n_spanned, hit.n_uniq, hit.n_uniq_bridges, # read counts
best_qual_A, best_qual_B, # mapping reliability
",".join(tissues), ",".join(tiss_counts), # sample association
min(hit.edits), min(hit.overlaps), min(hit.n_hits), hit.signal, hit.strandmatch, ",".join(sorted(hit.categories) ), # splice site detection reliability
",".join(flags), ",".join([str(c) for c in flag_counts]), # internal structure support from fragment evidence (BWA MEM)
]
output.write("\t".join([str(b) for b in bed]) + "\n")
class MultiEventRecorder(object):
def __init__(self):
multi_file.write("#" + "\t".join(['chrom','start','end','name','score','strand','fragment_name','lin_cons','lin_incons','unspliced_cons','unspliced_incons']) + "\n")
def record(self,frag_name,circ_hit,lin_cons,lin_incons,unspliced_cons,unspliced_incons):
score = len(lin_cons) - 10 * len(lin_incons) + len(unspliced_cons) - 10 * len(unspliced_incons)
circ_chrom,circ_start,circ_end,circ_sense = circ_hit.coord
cols = [circ_chrom, str(circ_start), str(circ_end), "ME:"+circ_hit.name, str(score), circ_sense, frag_name]
if not lin_cons:
cols.append("NO_LIN_CONS")
else:
cols.append(",".join([ "{0:d}-{1:d}".format(start,end) for chrom,start,end,sense in lin_cons]))
if not lin_incons:
cols.append("NO_LIN_INCONS")
else:
cols.append(",".join([ "[{0:s}:{1:d}-{2:d}]".format(chrom,start,end) for chrom,start,end,sense in lin_incons]))
if not unspliced_cons:
cols.append("NO_UNSPLICED_CONS")
else:
cols.append(",".join([ "{0:d}-{1:d}".format(start,end) for chrom,start,end,sense in unspliced_cons]))
if not unspliced_incons:
cols.append("NO_UNSPLICED_INCONS")
else:
cols.append(",".join([ "[{0:s}:{1:d}-{2:d}]".format(chrom,start,end) for chrom,start,end,sense in unspliced_incons]))
multi_file.write('\t'.join(cols) + '\n')
class Splice(object):
def __init__(self,junc_span,chrom,start,end,strand,dist,ov,gtag):
self.junc_span = junc_span
self.chrom = chrom
self.start = start
self.end = end
self.strand = strand
self.dist = dist
self.ov = ov
self.gtag = gtag
self.n_hits = 1 # if necessary, this is changed by JunctionSpan.find_breakpoints() after breaking ties
@property
def is_canonical(self):
return self.gtag == 'GTAG'
@property
def is_backsplice(self):
# the underlying alignment segment pair knows
return self.junc_span.is_backsplice
def __str__(self):
"python magic to make nice debug output"
return "Splice({self.chrom}:{self.start}-{self.end}:{self.strand} edits={self.dist} ov={self.ov} score={self.score} backsplice={self.is_backsplice})".format(**locals())
@property
def score(self):
"Used to rank different possible splices. higher is better"
# canonical beats low extension mismatches, beats low anchor overlap
s = self.is_canonical*20 - self.dist * 10 - self.ov
if options.strandpref:
s += 100 * (self.strand == self.junc_span.strand)
return s
@property
def coord(self):
if self.start < self.end:
return (self.chrom,self.start,self.end,self.strand)
else:
return (self.chrom,self.end,self.start,self.strand)
def uniqness(align):
"""
Difference between reported alignment score (AS) and
the next best hit's score (XS).
"""
u = align.get_tag('AS')
if align.has_tag('XS'):
u -= align.get_tag('XS')
return u
class JunctionSpan(object):
def __init__(self,align_A,align_B,primary,q_start,q_end,weight):
self.primary = primary
self.align_A = align_A
self.align_B = align_B
self.q_start = q_start
self.q_end = q_end
self.weight = weight
self.uniq_A = uniqness(align_A)
self.uniq_B = uniqness(align_B)
self.uniq = min(self.uniq_A, self.uniq_B)
# TODO: fix, depending on mate orientation!
if primary.is_reverse:
self.strand = '-'
else:
self.strand = '+'
# segments are ordered by occurence in the reqd query.
# if this order is the same in the genome it is a linear (normal)
# splice site. If reversed, it is a backsplice.
self.dist = align_B.pos - align_A.aend
full_read = primary.seq
self.read_part = full_read[q_start:q_end]
@property
def is_uniq(self):
return self.uniq >= options.min_uniq_qual
@property
def is_backsplice(self):
return self.dist < 0
def find_breakpoints(self):
"""
Extends distal parts of two segment alignments such that the intervening
read sequence is completely aligned and that the endpoints of this extension,
corresponding to the breakpoint inside the read, are flanked by splice signal
dinucleotides.
"""
def mismatches(a,b):
a,b = fromstring(a,dtype=byte), fromstring(b,dtype=byte)
return (a != b).sum()
def simple_match(a,b):
return (a != b)
if options.maxdist == 0:
# faster match function if no mismatches are allowed anyway!
mismatches = simple_match
# short hands
L = len(self.read_part)
A = self.align_A
B = self.align_B
read = self.read_part
margin = options.margin
maxdist = options.maxdist
is_backsplice = self.is_backsplice
# effective anchor size is reduced by allowing the breakpoint to reside
# options.margin nt's inside the anchor
eff_a = options.asize-options.margin
# record all possible breakpoints
hits = []
if options.debug:
print "readlen",L,"q_start/end",self.q_start, self.q_end
print " "*2+read
print " "*2+A.query[:-options.margin]
print " "*(2+L-eff_a)+B.query[options.margin:]
print " "*2+A.seq[:eff_a]
print " "*(2+L-eff_a)+A.seq[-eff_a:]
# intervening sequence that needs to be exactly explained by the splicing
internal = read[eff_a:-eff_a].upper()
# this much needs to be retrieved from the genome
chrom = fast_chrom_lookup(A)
flank = L - 2*eff_a + 2
A_flank = genome.get(chrom,A.pos + eff_a,A.pos + eff_a + flank,'+').upper()
B_flank = genome.get(chrom,B.aend - eff_a - flank,B.aend - eff_a,'+').upper()
l = L - 2*eff_a
# all possible breakpoints
for x in range(l+1):
spliced = A_flank[:x] + B_flank[x+2:]
dist = mismatches(spliced,internal)
if options.debug:
bla = A_flank[:x].lower() + B_flank[x+2:]
if options.debug:
print " "*(eff_a+2)+bla,dist
if dist <= maxdist:
# is the tested breakpoint inside an anchor?
ov = 0
if margin:
if x < margin:
ov = margin-x
if l-x < margin:
ov = margin-(l-x)
gt = A_flank[x:x+2]
ag = B_flank[x:x+2]
gtag = gt+ag
rc_gtag = fast_4mer_RC[gtag]
start,end = B.aend-eff_a-l+x,A.pos+eff_a+x+1
start,end = min(start,end),max(start,end)
strand = "*"
# get strand cues from read if strand-specific sequencing was used.
# TODO: skip if gtag does not match strand!
if options.stranded:
if A.is_reverse:
strand = '-'
else:
strand = '+'
if is_backsplice:
# small correction when projecting back to genome
end -= 1
else:
start -= 1
if options.noncanonical:
hits.append( Splice(self,chrom,start,end,'+',dist,ov,gtag,) )
hits.append( Splice(self,chrom,start,end,'-',dist,ov,rc_gtag) )
else:
if gtag == 'GTAG':
hits.append( Splice(self,chrom,start,end,'+',dist,ov,gtag) )
elif gtag == 'CTAC':
hits.append( Splice(self,chrom,start,end,'-',dist,ov,rc_gtag) )
if options.debug:
print ">find_breakpoints() results:"
for splice in hits:
print splice
if len(hits) < 2:
# unambiguous, return right away
return hits
# Hits are sorted, with low edit distance beating low anchor overlap
hits = sorted(hits,key=lambda x : x.score, reverse = True)
best_score = hits[0].score
ties = [h for h in hits if (h.score == best_score)]
n_hits = len(ties)
for h in hits:
h.n_hits = n_hits
return ties
class MateSegments(object):
def __init__(self,primary):
N['total_mates'] += 1
self.primary = primary
self.full_seq = primary.seq
self.proper_segs = [primary]
self.other_chrom_segs = []
self.other_strand_segs = []
self.seg_flags = {}
@property
def matenum(self):
if self.primary.is_read2:
return 2
else:
# this also catches unpaired reads
return 1
@property
def strand(self):
if self.primary.is_reverse:
return '-'
else:
return '+'
def __str__(self):
"Python magic to make nice debug output possible"
buf = []
chrom = fast_chrom_lookup(self.primary)
buf.append("MateSegments({self.primary.qname} mate={self.matenum})".format(**locals()))
buf.append("\tprimary={chrom}:{self.primary.pos}-{self.primary.aend}:{self.strand}".format(**locals()))
n_proper = len(self.proper_segs)
n_oc = len(self.other_chrom_segs)
n_os = len(self.other_strand_segs)
flags = ",".join(sorted(self.seg_flags.values()))
buf.append("\t{n_proper} proper_segs {n_oc} other_chrom {n_os} other_strand. Flags={flags}".format(**locals()) )
for seg in self.proper_segs:
buf.append("proper >>> %s" % seg)
for seg in self.other_chrom_segs:
buf.append("other chrom >>> %s" % seg)
for seg in self.other_strand_segs:
buf.append("other strand >>> %s" % seg)
return "\n".join(buf)
def is_segment(self,align):
"tests if align is supplementary to the primary"
if (align.is_read1 == self.primary.is_read1) and (align.qname == self.primary.qname):
return True
else:
return False
def is_other_mate(self,align):
"tests if align is the other mate of the primary alignment."
if (align.is_read1 != self.primary.is_read1) and (align.qname == self.primary.qname):
return True
else:
return False
def add_segment(self,align):
"records align as a new supplementary alignment"
if align.tid != self.primary.tid:
# secondary hit is on another chromosome
self.other_chrom_segs.append(align)
#self.seg_flags[align] = "SEG_OTHER_CHROM"
#N['seg_other_chrom'] += 1
elif align.is_reverse != self.primary.is_reverse:
# secondary hit is on other strand
self.other_strand_segs.append(align)
#self.seg_flags[align] = "SEG_OTHER_STRAND"
#N['seg_other_strand'] += 1
else:
# same chrom, same strand. could be useful
self.proper_segs.append(align)
#N['seg_proper'] += 1
def adjacent_segment_pairs(self):
"""
This generator yields pairs of adjacent segments (meaning adjacent in
the reads query sequence) to be processed by the known logic for splice
junction determination.
Input is the recorded list of proper segments as reported by BWA MEM.
In the simplest case these are two alignments to two exons, with the
parts belonging to the respective other exon clipped.
However, for longer reads these may also be split into three or
more segments.
"""
if options.debug:
print ">adjacent_segment_pairs() starting"
if len(self.proper_segs) < 2:
# unspliced read. Nothing to do
return
# the primary reported alignment for a read always contains the
# full, original read sequence
full_read = self.primary.seq
# weight to assign to each splice. Now that a read can contain multiple
# splices (or a circRNA read even the same splice multiple times), we
# do not want to overcount.
weight = 1./(len(self.proper_segs)-1.)
def aligned_start_from_cigar(seg):
"""
Determines the internal start position of this segment,
relative to the full read sequence.
"""
start = 0
for op,count in seg.cigar:
if op in [4,5]: # soft or hard clip
start += count
elif op == 0: # match: aligned part begins
break
return start
# TODO: perhaps this can be optimized by making lists in the same order and (i)zipping
internal_starts = dict([( seg,aligned_start_from_cigar(seg) ) for seg in self.proper_segs])
internal_ends = dict([( seg,internal_starts[seg] + len(seg.query) ) for seg in self.proper_segs])
if options.debug:
print "internal_starts", internal_starts
# sort by internal start position
seg_by_seq = sorted(self.proper_segs, key = lambda seg: internal_starts[seg])
# iterate over consecutive pairs of segments to find the
# splices between them
# [A,B,C,D] -> (A,B),(B,C),(C,D)
for seg_a,seg_b in zip(seg_by_seq, seg_by_seq[1:]):
if options.debug:
print ">adjacent_segment_pairs() iteration"
print "A",seg_a
print "B",seg_b
start_a = internal_starts[seg_a]
end_a = internal_ends[seg_a]
len_a = end_a - start_a
start_b = internal_starts[seg_b]
end_b = internal_ends[seg_b]
len_b = end_b - start_b
if len_a < options.asize or len_b < options.asize:
# segment length is below required anchor length
N['seg_too_short_skip'] += 1
continue
r_start = min(start_a, start_b)
r_end = max(end_a, end_b)
## anchor pairs that make it up to here are interesting
if bam_out:
bam_out.write(seg_a)
yield JunctionSpan(seg_a, seg_b, self.primary, r_start, r_end, weight)
if bam_out:
bam_out.write(seg_b)
circ_splices = SpliceSiteStorage("circ",options.known_circ)
linear_splices = SpliceSiteStorage("lin",options.known_lin)
multi_events = MultiEventRecorder()
N = defaultdict(float)
def parse_test_read(align_str, fix_marcel=False):
chrom = None
strand = None
start = None
end = None
lin_juncs = set()
circ_juncs = set()
unspliced = set()
for mate_str in align_str.split('|'):
spliced = False
for code in mate_str.split(';'):
parts = code.split(':')
op = parts[0]
if op == 'O':
chrom, start, strand = parts[1:]
start = int(start)
end = start
elif op == 'M':
end += int(parts[1])
elif op == 'LS':
left, right = int(parts[1])+start, int(parts[2])+start
lin_juncs.add( (chrom, left, right, strand) )
spliced = True
end = right
elif op == 'CS':
left, right = int(parts[1])+start, int(parts[2])+start
circ_juncs.add( (chrom, left, right, strand) )
spliced = True
end = left
else:
pass
if not spliced and chrom:
if options.stranded:
unspliced.add( (chrom, start, end, strand) )
else:
unspliced.add( (chrom, start, end, "*") )
return lin_juncs, circ_juncs, unspliced
def validate_hits_for_test_fragment(frag_name, lin_coords, circ_coords, unspliced_coords, seg_broken):
"""
Parse the fragment structure from the read identifier and compare to reconstructed junctions.
"""
# O:testbed_plus:140:+;M:20;LS:160:240;M:80;LS:320:400;M:20
unspliced_coords = set(unspliced_coords)
if not '___' in frag_name:
out = [frag_name, "N/A", "N/A", "N/A","N/A"]
test_file.write('{0}\n'.format("\t".join(out)))
return
lin_ref, circ_ref, unspliced_ref = parse_test_read(frag_name.split("___")[-1])
if options.debug:
print "STR",frag_name.split("___")[-1]
print "LIN_REF",sorted(lin_ref)
print "CIRC_REF",sorted(circ_ref)
print "UNSPLICED_REF",sorted(unspliced_ref)
print "lin_junctions",sorted(lin_coords)
print "circ_junctions",sorted(circ_coords)
print "unspliced_mates",sorted(unspliced_coords)
lin_flags = set()
if lin_ref - lin_coords:
missed = ','.join([str(j) for j in sorted(lin_ref - lin_coords)])
lin_flags.add( 'MISSED_LINEAR_JUNCTIONS:{0}'.format(missed) )
if lin_coords - lin_ref:
spur = ','.join([str(j) for j in sorted(lin_coords - lin_ref)])
lin_flags.add( 'SPURIOUS_LINEAR_JUNCTIONS:{0}'.format(spur) )
circ_flags = set()
if circ_ref - circ_coords:
missed = ','.join([str(j) for j in sorted(circ_ref - circ_coords)])
circ_flags.add( 'MISSED_CIRCULAR_JUNCTIONS:{0}'.format(missed) )
if circ_coords - circ_ref:
spur = ','.join([str(j) for j in sorted(circ_coords - circ_ref)])
circ_flags.add( 'SPURIOUS_CIRCULAR_JUNCTIONS:{0}'.format(spur) )
unspliced_flags = set()
if unspliced_ref - unspliced_coords:
missed = ','.join([str(j) for j in sorted(unspliced_ref - unspliced_coords)])
unspliced_flags.add( 'MISSED_UNSPLICED:{0}'.format(missed) )
if unspliced_coords - unspliced_ref:
spur = ','.join([str(j) for j in sorted(unspliced_coords - unspliced_ref)])
unspliced_flags.add( 'SPURIOUS_UNSPLICED:{0}'.format(spur) )
if lin_flags:
lin_str = ";".join(sorted(lin_flags))
elif lin_ref:
lin_str = "LIN_OK"
else:
lin_str = "N/A"
if circ_flags:
circ_str = ";".join(sorted(circ_flags))
elif circ_ref:
circ_str = "CIRC_OK"
else:
circ_str = "N/A"
if unspliced_flags:
unspliced_str = ";".join(sorted(unspliced_flags))
elif unspliced_ref:
unspliced_str = "UNSPLICED_OK"
else:
unspliced_str = "N/A"
if seg_broken:
broken = ";".join([str(b) for b in sorted(seg_broken)])
broken_str = 'BROKEN_SEGMENTS:{0}'.format(broken)
else:
broken_str = "N/A"
out = [frag_name, lin_str, circ_str, unspliced_str, broken_str]
test_file.write('{0}\n'.format("\t".join(out)))
def record_hits(frag_name, circ_junc_spans, linear_junc_spans, unspliced_mates, seg_broken):
"""
This function processes the observed splicing events from a single
sequenced fragment (mate pair, or single end read). Long reads, or
mate pairs can span more than one junction, thus revealing information
on the internal structure of a circRNA.
record_hits() extracts and reports this information.
"""
global circ_splices, linear_splices
warns = set()
junctions = set()
if options.debug:
print ">record_hits({0}) #circ_junc_spans={1} #lin_junc_spans={2} #unspliced_mates={3} #seg_broken={4}".format(
frag_name, len(circ_junc_spans), len(linear_junc_spans), len(unspliced_mates), len(seg_broken) )
# record all observed backsplice events
circ_coords = set()
for junc_span in circ_junc_spans:
if options.debug:
print "> checking for circ-juncs"
if not junc_span.is_uniq:
N['circ_junc_not_unique'] += 1
continue
splices = junc_span.find_breakpoints()
w = junc_span.weight
if not splices:
N['circ_no_bp'] += 1
warns.add('WARN_UNRESOLVED_EXTRA_BACKSPLICE')
continue
N['circ_spliced'] += 1
for splice in splices:
circ = circ_splices.add(splice)
circ_coords.add(circ.coord)
junctions.add(circ)
if not options.allhits:
break
if len(circ_coords) > 1:
for coord in circ_coords:
warns.add('WARN_MULTI_BACKSPLICE')
circ = circ_splices[coord]
circ.add_flag('WARN_MULTI_BACKSPLICE',frag_name)
junctions.add(circ)
return junctions, warns
if not circ_coords and options.nolinear:
return junctions, warns
if circ_coords:
# we are sure now, that there is exactly one circ junction in the fragment.
# now we can start flagging this junction with SUPPORT or WARNINGs, depending
# on what the other mates, splices, and segments do.
circ_coord = circ.coord
circ_chrom,circ_start,circ_end,circ_strand = circ_coord
circ_junc_span = circ_junc_spans[0]
if len(circ_junc_spans) > 1:
# we had multiple splices covering the same junction
# in one fragment, i.e. the fragment went "around" the circ.
# Let's call this a "closure".
warns.add('SUPPORT_CLOSURE')
# record all observed linear events
lin_cons = set()
lin_incons = set()
lin_coords = set()
for junc_span in linear_junc_spans:
if not junc_span.is_uniq:
N['lin_junc_not_unique'] += 1
continue
splices = junc_span.find_breakpoints()
w = junc_span.weight
if not splices:
N['lin_no_bp'] += 1
warns.add('WARN_UNRESOLVED_LINSPLICE')
continue
N['lin_spliced'] += 1
for splice in splices:
lin = linear_splices.add(splice)
junctions.add(lin)
lin_coords.add(lin.coord)
if circ_coords:
if splice.start <= circ_start or splice.end >= circ_end:
warns.add('WARN_OUTSIDE_SPLICE_JUNCTION')
lin_incons.add(splice.coord)
else:
lin_cons.add(splice.coord)
warns.add('SUPPORT_INSIDE_SPLICE_JUNCTION')
if not options.allhits:
break
if options.test:
def extract_coords(align):
chrom = fast_chrom_lookup(align)
if options.stranded:
if align.is_reverse:
return chrom, align.pos, align.aend, "-"
else:
return chrom, align.pos, align.aend, "+"
else:
# unspliced segments are reported without strand information!
return chrom, align.pos, align.aend, "*"
unspliced_coords = set([extract_coords(mate) for mate in unspliced_mates])
seg_broken_coords = set([extract_coords(seg) for seg in seg_broken])
validate_hits_for_test_fragment(frag_name, lin_coords, circ_coords, unspliced_coords, seg_broken_coords)
if circ_coords:
# investigate unspliced mates
unspliced_cons = set()
unspliced_incons = set()
for align in unspliced_mates:
# TODO: fix strand handling of fr, ff, rr, rf mates.
#if align.is_reverse != circ_junc_span.primary.is_reverse:
#circ.add_flag('WARN_OTHER_STRAND_MATE',frag_name)
strand = '*'
chrom = fast_chrom_lookup(align)
coord = (chrom,align.pos,align.aend,strand)
if circ_junc_span.primary.tid != align.tid:
warns.add('WARN_OTHER_CHROM_MATE')
unspliced_incons.add( coord )
# test if unspliced reads fall within the circ
# allow for [anchor-length] nucleotides to lie outside, as these may simply
# have failed to be soft-clipped/spliced.
elif align.pos + options.asize <= circ_start or align.aend - options.asize >= circ_end:
warns.add('WARN_OUTSIDE_MATE')
unspliced_incons.add( coord )
else:
warns.add('SUPPORT_INSIDE_MATE')
unspliced_cons.add( coord )
if seg_broken:
warns.add('BROKEN_SEGMENTS')
if options.debug:
print "record_hits(",circ_coord,") linear: ",sorted(lin_cons),sorted(lin_incons)," unspliced",sorted(unspliced_cons),sorted(unspliced_incons)
if (unspliced_cons or unspliced_incons or lin_cons or lin_incons) and options.multi_events:
# we have a multi-splicing event!
multi_events.record(frag_name, circ, lin_cons, lin_incons, unspliced_cons, unspliced_incons)
for w in warns:
circ.add_flag(w,frag_name)
if options.debug:
print "fragment:",frag_name,warns
return junctions,warns
def write_read(mate,junctions,flags):
flag_str = ",".join(sorted(flags))
junc_str = ",".join(sorted([j.name for j in junctions]))
#reads_file.write(">%s %s %s\n%s\n" % (mate.primary.qname,junc_str,flag_str,mate.primary.seq))
name = "%s %s %s" % (mate.primary.qname,junc_str,flag_str)
reads_file.write("@%s\n%s\n+%s\n%s\n" % (name,mate.primary.seq,name,mate.primary.qual))
def collected_bwa_mem_segments(sam_input):
"""
Generator that loops over the SAM alignments. It groups alignments
belonging to the same original read.
"""
current_mate = None
other_mate = None
I = enumerate(sam_input).__iter__()
# optimization: fetch first element to remove one IF from the main loop.
null,align = next(I)
current_mate = MateSegments(align)
for line_num,align in I:
if align.is_unmapped:
N['unmapped_reads'] += 1
else:
if current_mate.is_segment(align):
#assert align.is_supplementary == True
current_mate.add_segment(align)
elif current_mate.is_other_mate(align):
#assert align.is_supplementary == False
# we are switching to the other mate now:
other_mate,current_mate = current_mate,MateSegments(align)
else:
# we have a completely new read!
# Yield what we have so far:
yield line_num,other_mate,current_mate
# and start fresh
#assert align.is_supplementary == False
other_mate = None
current_mate = MateSegments(align)
yield line_num, other_mate, current_mate
def main():
def process_mate(mate):
if len(mate.proper_segs) < 2:
N['unspliced_mates'] += 1
seg_unspliced.append(mate.primary)
return
# keep track of which parts of the read are already aligned
L = len(mate.full_seq)
min_s = L
max_e = 0
#for A,B,r_start,r_end,w in mate.adjacent_segment_pairs():
for junc_span in mate.adjacent_segment_pairs():
if junc_span.is_backsplice:
seg_circ_splices.append(junc_span)
else:
seg_linear_splices.append(junc_span)
min_s = min(min_s,junc_span.q_start)
max_e = max(max_e,junc_span.q_end)
if (max_e < L - options.asize) or (min_s > options.asize):
# we are still missing a part of the read larger than options.asize
# that could not be accounted for by the proper_segs
# treat possible other fragments as if they were an unspliced mate
seg_broken.extend(mate.other_chrom_segs)
seg_broken.extend(mate.other_strand_segs)
if options.debug:
print "we have (at most) been able to assign pos {0}-{1} of this read!".format(min_s,max_e)
print "start-non-covered",mate.full_seq[0:min_s],"end-non-covered",mate.full_seq[max_e:]
print "these are unassigned segments we could have used"
for seg in seg_broken:
print "broken_seg>>>",seg
from time import time
t0 = time()
t_last = t0
n_reads = 0
try:
for sam_line,mate1,mate2 in collected_bwa_mem_segments(sam_input):
n_reads += 1
if options.debug:
print ">collected_bwa_mem_segments"
print "mate1",mate1
print "mate2",mate2
frag_name = mate2.primary.qname
if n_reads and options.throughput and not (n_reads % options.chunksize):
t1 = time()
M_reads = n_reads / 1E6
mins = (t1 - t0)/60.
krps = float(options.chunksize)/float(t1-t_last)/1000.
#krps = float(n_reads)/(t1 - t0)/1000.
sys.stderr.write("\rprocessed {M_reads:.1f}M (paired-end) reads in {mins:.1f} minutes ({krps:.2f}k reads/second) \r".format(**locals()))
t_last = t1
if options.noop:
# this is useful for optimizing throughput of alignments w/o any splice detection.
# It is quite fast actually, if combined with samtools -buh to have decompression
# in a separate process!
continue
seg_circ_splices = []
seg_linear_splices = []
seg_unspliced = []
seg_broken = []
if mate1: process_mate(mate1)
if mate2: process_mate(mate2)
if not seg_circ_splices and options.nolinear:
continue
if seg_circ_splices or seg_linear_splices:
junctions,flags = record_hits(frag_name,seg_circ_splices,seg_linear_splices,seg_unspliced,seg_broken)
if mate1 and junctions: write_read(mate1,junctions,flags)
if mate2 and junctions: write_read(mate2,junctions,flags)
except KeyboardInterrupt:
logging.warning("KeyboardInterrupt by user while processing input starting at SAM line {sam_line}".format(**locals()))
except:
logging.error("Unhandled exception raised while processing input starting at SAM line {sam_line}".format(**locals()))
exc = traceback.format_exc()
logging.error(exc)
sys.stderr.write(exc)
sys.exit(1)
if options.throughput:
sys.stderr.write('\n')
t1 = time()
M_reads = n_reads / 1E6
mins = (t1 - t0)/60.
krps = float(n_reads)/(t1 - t0)/1000.
txt = "processed {M_reads:.2f}M (paired or single end) reads in {mins:.1f} minutes (overall {krps:.2f}k reads/second on average)".format(**locals())
logger.info(txt)
if not options.silent and not options.stdout:
print "#",txt
print "# results stored in '{0}'".format(options.output)
if options.profile:
import cProfile
cProfile.run('main()')
else:
main()
logger.info('run finished')
for key in sorted(N.keys()):
logger.info('{0}={1}'.format(key,N[key]))
circ_splices.store_list(circs_file)
linear_splices.store_list(lins_file) | rajewsky-lab/find_circ2 | find_circ.py | Python | gpl-3.0 | 60,667 |
#
# Copyright 2009 Facebook
#
# 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.
"""Utility classes to write to and read from non-blocking files and sockets.
Contents:
* `BaseIOStream`: Generic interface for reading and writing.
* `IOStream`: Implementation of BaseIOStream using non-blocking sockets.
* `SSLIOStream`: SSL-aware version of IOStream.
* `PipeIOStream`: Pipe-based IOStream implementation.
"""
import asyncio
import collections
import errno
import io
import numbers
import os
import socket
import ssl
import sys
import re
from tornado.concurrent import Future, future_set_result_unless_cancelled
from tornado import ioloop
from tornado.log import gen_log
from tornado.netutil import ssl_wrap_socket, _client_ssl_defaults, _server_ssl_defaults
from tornado.util import errno_from_exception
import typing
from typing import (
Union,
Optional,
Awaitable,
Callable,
Pattern,
Any,
Dict,
TypeVar,
Tuple,
)
from types import TracebackType
if typing.TYPE_CHECKING:
from typing import Deque, List, Type # noqa: F401
_IOStreamType = TypeVar("_IOStreamType", bound="IOStream")
try:
from tornado.platform.posix import _set_nonblocking
except ImportError:
_set_nonblocking = None # type: ignore
# These errnos indicate that a connection has been abruptly terminated.
# They should be caught and handled less noisily than other errors.
_ERRNO_CONNRESET = (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE, errno.ETIMEDOUT)
if hasattr(errno, "WSAECONNRESET"):
_ERRNO_CONNRESET += ( # type: ignore
errno.WSAECONNRESET, # type: ignore
errno.WSAECONNABORTED, # type: ignore
errno.WSAETIMEDOUT, # type: ignore
)
if sys.platform == "darwin":
# OSX appears to have a race condition that causes send(2) to return
# EPROTOTYPE if called while a socket is being torn down:
# http://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
# Since the socket is being closed anyway, treat this as an ECONNRESET
# instead of an unexpected error.
_ERRNO_CONNRESET += (errno.EPROTOTYPE,) # type: ignore
_WINDOWS = sys.platform.startswith("win")
class StreamClosedError(IOError):
"""Exception raised by `IOStream` methods when the stream is closed.
Note that the close callback is scheduled to run *after* other
callbacks on the stream (to allow for buffered data to be processed),
so you may see this error before you see the close callback.
The ``real_error`` attribute contains the underlying error that caused
the stream to close (if any).
.. versionchanged:: 4.3
Added the ``real_error`` attribute.
"""
def __init__(self, real_error: Optional[BaseException] = None) -> None:
super(StreamClosedError, self).__init__("Stream is closed")
self.real_error = real_error
class UnsatisfiableReadError(Exception):
"""Exception raised when a read cannot be satisfied.
Raised by ``read_until`` and ``read_until_regex`` with a ``max_bytes``
argument.
"""
pass
class StreamBufferFullError(Exception):
"""Exception raised by `IOStream` methods when the buffer is full.
"""
class _StreamBuffer(object):
"""
A specialized buffer that tries to avoid copies when large pieces
of data are encountered.
"""
def __init__(self) -> None:
# A sequence of (False, bytearray) and (True, memoryview) objects
self._buffers = (
collections.deque()
) # type: Deque[Tuple[bool, Union[bytearray, memoryview]]]
# Position in the first buffer
self._first_pos = 0
self._size = 0
def __len__(self) -> int:
return self._size
# Data above this size will be appended separately instead
# of extending an existing bytearray
_large_buf_threshold = 2048
def append(self, data: Union[bytes, bytearray, memoryview]) -> None:
"""
Append the given piece of data (should be a buffer-compatible object).
"""
size = len(data)
if size > self._large_buf_threshold:
if not isinstance(data, memoryview):
data = memoryview(data)
self._buffers.append((True, data))
elif size > 0:
if self._buffers:
is_memview, b = self._buffers[-1]
new_buf = is_memview or len(b) >= self._large_buf_threshold
else:
new_buf = True
if new_buf:
self._buffers.append((False, bytearray(data)))
else:
b += data # type: ignore
self._size += size
def peek(self, size: int) -> memoryview:
"""
Get a view over at most ``size`` bytes (possibly fewer) at the
current buffer position.
"""
assert size > 0
try:
is_memview, b = self._buffers[0]
except IndexError:
return memoryview(b"")
pos = self._first_pos
if is_memview:
return typing.cast(memoryview, b[pos : pos + size])
else:
return memoryview(b)[pos : pos + size]
def advance(self, size: int) -> None:
"""
Advance the current buffer position by ``size`` bytes.
"""
assert 0 < size <= self._size
self._size -= size
pos = self._first_pos
buffers = self._buffers
while buffers and size > 0:
is_large, b = buffers[0]
b_remain = len(b) - size - pos
if b_remain <= 0:
buffers.popleft()
size -= len(b) - pos
pos = 0
elif is_large:
pos += size
size = 0
else:
# Amortized O(1) shrink for Python 2
pos += size
if len(b) <= 2 * pos:
del typing.cast(bytearray, b)[:pos]
pos = 0
size = 0
assert size == 0
self._first_pos = pos
class BaseIOStream(object):
"""A utility class to write to and read from a non-blocking file or socket.
We support a non-blocking ``write()`` and a family of ``read_*()``
methods. When the operation completes, the ``Awaitable`` will resolve
with the data read (or ``None`` for ``write()``). All outstanding
``Awaitables`` will resolve with a `StreamClosedError` when the
stream is closed; `.BaseIOStream.set_close_callback` can also be used
to be notified of a closed stream.
When a stream is closed due to an error, the IOStream's ``error``
attribute contains the exception object.
Subclasses must implement `fileno`, `close_fd`, `write_to_fd`,
`read_from_fd`, and optionally `get_fd_error`.
"""
def __init__(
self,
max_buffer_size: Optional[int] = None,
read_chunk_size: Optional[int] = None,
max_write_buffer_size: Optional[int] = None,
) -> None:
"""`BaseIOStream` constructor.
:arg max_buffer_size: Maximum amount of incoming data to buffer;
defaults to 100MB.
:arg read_chunk_size: Amount of data to read at one time from the
underlying transport; defaults to 64KB.
:arg max_write_buffer_size: Amount of outgoing data to buffer;
defaults to unlimited.
.. versionchanged:: 4.0
Add the ``max_write_buffer_size`` parameter. Changed default
``read_chunk_size`` to 64KB.
.. versionchanged:: 5.0
The ``io_loop`` argument (deprecated since version 4.1) has been
removed.
"""
self.io_loop = ioloop.IOLoop.current()
self.max_buffer_size = max_buffer_size or 104857600
# A chunk size that is too close to max_buffer_size can cause
# spurious failures.
self.read_chunk_size = min(read_chunk_size or 65536, self.max_buffer_size // 2)
self.max_write_buffer_size = max_write_buffer_size
self.error = None # type: Optional[BaseException]
self._read_buffer = bytearray()
self._read_buffer_pos = 0
self._read_buffer_size = 0
self._user_read_buffer = False
self._after_user_read_buffer = None # type: Optional[bytearray]
self._write_buffer = _StreamBuffer()
self._total_write_index = 0
self._total_write_done_index = 0
self._read_delimiter = None # type: Optional[bytes]
self._read_regex = None # type: Optional[Pattern]
self._read_max_bytes = None # type: Optional[int]
self._read_bytes = None # type: Optional[int]
self._read_partial = False
self._read_until_close = False
self._read_future = None # type: Optional[Future]
self._write_futures = (
collections.deque()
) # type: Deque[Tuple[int, Future[None]]]
self._close_callback = None # type: Optional[Callable[[], None]]
self._connect_future = None # type: Optional[Future[IOStream]]
# _ssl_connect_future should be defined in SSLIOStream
# but it's here so we can clean it up in _signal_closed
# TODO: refactor that so subclasses can add additional futures
# to be cancelled.
self._ssl_connect_future = None # type: Optional[Future[SSLIOStream]]
self._connecting = False
self._state = None # type: Optional[int]
self._closed = False
def fileno(self) -> Union[int, ioloop._Selectable]:
"""Returns the file descriptor for this stream."""
raise NotImplementedError()
def close_fd(self) -> None:
"""Closes the file underlying this stream.
``close_fd`` is called by `BaseIOStream` and should not be called
elsewhere; other users should call `close` instead.
"""
raise NotImplementedError()
def write_to_fd(self, data: memoryview) -> int:
"""Attempts to write ``data`` to the underlying file.
Returns the number of bytes written.
"""
raise NotImplementedError()
def read_from_fd(self, buf: Union[bytearray, memoryview]) -> Optional[int]:
"""Attempts to read from the underlying file.
Reads up to ``len(buf)`` bytes, storing them in the buffer.
Returns the number of bytes read. Returns None if there was
nothing to read (the socket returned `~errno.EWOULDBLOCK` or
equivalent), and zero on EOF.
.. versionchanged:: 5.0
Interface redesigned to take a buffer and return a number
of bytes instead of a freshly-allocated object.
"""
raise NotImplementedError()
def get_fd_error(self) -> Optional[Exception]:
"""Returns information about any error on the underlying file.
This method is called after the `.IOLoop` has signaled an error on the
file descriptor, and should return an Exception (such as `socket.error`
with additional information, or None if no such information is
available.
"""
return None
def read_until_regex(
self, regex: bytes, max_bytes: Optional[int] = None
) -> Awaitable[bytes]:
"""Asynchronously read until we have matched the given regex.
The result includes the data that matches the regex and anything
that came before it.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the regex is
not satisfied.
.. versionchanged:: 4.0
Added the ``max_bytes`` argument. The ``callback`` argument is
now optional and a `.Future` will be returned if it is omitted.
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
future = self._start_read()
self._read_regex = re.compile(regex)
self._read_max_bytes = max_bytes
try:
self._try_inline_read()
except UnsatisfiableReadError as e:
# Handle this the same way as in _handle_events.
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=e)
return future
except:
# Ensure that the future doesn't log an error because its
# failure was never examined.
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_until(
self, delimiter: bytes, max_bytes: Optional[int] = None
) -> Awaitable[bytes]:
"""Asynchronously read until we have found the given delimiter.
The result includes all the data read including the delimiter.
If ``max_bytes`` is not None, the connection will be closed
if more than ``max_bytes`` bytes have been read and the delimiter
is not found.
.. versionchanged:: 4.0
Added the ``max_bytes`` argument. The ``callback`` argument is
now optional and a `.Future` will be returned if it is omitted.
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
future = self._start_read()
self._read_delimiter = delimiter
self._read_max_bytes = max_bytes
try:
self._try_inline_read()
except UnsatisfiableReadError as e:
# Handle this the same way as in _handle_events.
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=e)
return future
except:
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_bytes(self, num_bytes: int, partial: bool = False) -> Awaitable[bytes]:
"""Asynchronously read a number of bytes.
If ``partial`` is true, data is returned as soon as we have
any bytes to return (but never more than ``num_bytes``)
.. versionchanged:: 4.0
Added the ``partial`` argument. The callback argument is now
optional and a `.Future` will be returned if it is omitted.
.. versionchanged:: 6.0
The ``callback`` and ``streaming_callback`` arguments have
been removed. Use the returned `.Future` (and
``partial=True`` for ``streaming_callback``) instead.
"""
future = self._start_read()
assert isinstance(num_bytes, numbers.Integral)
self._read_bytes = num_bytes
self._read_partial = partial
try:
self._try_inline_read()
except:
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_into(self, buf: bytearray, partial: bool = False) -> Awaitable[int]:
"""Asynchronously read a number of bytes.
``buf`` must be a writable buffer into which data will be read.
If ``partial`` is true, the callback is run as soon as any bytes
have been read. Otherwise, it is run when the ``buf`` has been
entirely filled with read data.
.. versionadded:: 5.0
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
future = self._start_read()
# First copy data already in read buffer
available_bytes = self._read_buffer_size
n = len(buf)
if available_bytes >= n:
end = self._read_buffer_pos + n
buf[:] = memoryview(self._read_buffer)[self._read_buffer_pos : end]
del self._read_buffer[:end]
self._after_user_read_buffer = self._read_buffer
elif available_bytes > 0:
buf[:available_bytes] = memoryview(self._read_buffer)[
self._read_buffer_pos :
]
# Set up the supplied buffer as our temporary read buffer.
# The original (if it had any data remaining) has been
# saved for later.
self._user_read_buffer = True
self._read_buffer = buf
self._read_buffer_pos = 0
self._read_buffer_size = available_bytes
self._read_bytes = n
self._read_partial = partial
try:
self._try_inline_read()
except:
future.add_done_callback(lambda f: f.exception())
raise
return future
def read_until_close(self) -> Awaitable[bytes]:
"""Asynchronously reads all data from the socket until it is closed.
This will buffer all available data until ``max_buffer_size``
is reached. If flow control or cancellation are desired, use a
loop with `read_bytes(partial=True) <.read_bytes>` instead.
.. versionchanged:: 4.0
The callback argument is now optional and a `.Future` will
be returned if it is omitted.
.. versionchanged:: 6.0
The ``callback`` and ``streaming_callback`` arguments have
been removed. Use the returned `.Future` (and `read_bytes`
with ``partial=True`` for ``streaming_callback``) instead.
"""
future = self._start_read()
if self.closed():
self._finish_read(self._read_buffer_size, False)
return future
self._read_until_close = True
try:
self._try_inline_read()
except:
future.add_done_callback(lambda f: f.exception())
raise
return future
def write(self, data: Union[bytes, memoryview]) -> "Future[None]":
"""Asynchronously write the given data to this stream.
This method returns a `.Future` that resolves (with a result
of ``None``) when the write has been completed.
The ``data`` argument may be of type `bytes` or `memoryview`.
.. versionchanged:: 4.0
Now returns a `.Future` if no callback is given.
.. versionchanged:: 4.5
Added support for `memoryview` arguments.
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
self._check_closed()
if data:
if (
self.max_write_buffer_size is not None
and len(self._write_buffer) + len(data) > self.max_write_buffer_size
):
raise StreamBufferFullError("Reached maximum write buffer size")
self._write_buffer.append(data)
self._total_write_index += len(data)
future = Future() # type: Future[None]
future.add_done_callback(lambda f: f.exception())
self._write_futures.append((self._total_write_index, future))
if not self._connecting:
self._handle_write()
if self._write_buffer:
self._add_io_state(self.io_loop.WRITE)
self._maybe_add_error_listener()
return future
def set_close_callback(self, callback: Optional[Callable[[], None]]) -> None:
"""Call the given callback when the stream is closed.
This mostly is not necessary for applications that use the
`.Future` interface; all outstanding ``Futures`` will resolve
with a `StreamClosedError` when the stream is closed. However,
it is still useful as a way to signal that the stream has been
closed while no other read or write is in progress.
Unlike other callback-based interfaces, ``set_close_callback``
was not removed in Tornado 6.0.
"""
self._close_callback = callback
self._maybe_add_error_listener()
def close(
self,
exc_info: Union[
None,
bool,
BaseException,
Tuple[
"Optional[Type[BaseException]]",
Optional[BaseException],
Optional[TracebackType],
],
] = False,
) -> None:
"""Close this stream.
If ``exc_info`` is true, set the ``error`` attribute to the current
exception from `sys.exc_info` (or if ``exc_info`` is a tuple,
use that instead of `sys.exc_info`).
"""
if not self.closed():
if exc_info:
if isinstance(exc_info, tuple):
self.error = exc_info[1]
elif isinstance(exc_info, BaseException):
self.error = exc_info
else:
exc_info = sys.exc_info()
if any(exc_info):
self.error = exc_info[1]
if self._read_until_close:
self._read_until_close = False
self._finish_read(self._read_buffer_size, False)
elif self._read_future is not None:
# resolve reads that are pending and ready to complete
try:
pos = self._find_read_pos()
except UnsatisfiableReadError:
pass
else:
if pos is not None:
self._read_from_buffer(pos)
if self._state is not None:
self.io_loop.remove_handler(self.fileno())
self._state = None
self.close_fd()
self._closed = True
self._signal_closed()
def _signal_closed(self) -> None:
futures = [] # type: List[Future]
if self._read_future is not None:
futures.append(self._read_future)
self._read_future = None
futures += [future for _, future in self._write_futures]
self._write_futures.clear()
if self._connect_future is not None:
futures.append(self._connect_future)
self._connect_future = None
for future in futures:
if not future.done():
future.set_exception(StreamClosedError(real_error=self.error))
# Reference the exception to silence warnings. Annoyingly,
# this raises if the future was cancelled, but just
# returns any other error.
try:
future.exception()
except asyncio.CancelledError:
pass
if self._ssl_connect_future is not None:
# _ssl_connect_future expects to see the real exception (typically
# an ssl.SSLError), not just StreamClosedError.
if not self._ssl_connect_future.done():
if self.error is not None:
self._ssl_connect_future.set_exception(self.error)
else:
self._ssl_connect_future.set_exception(StreamClosedError())
self._ssl_connect_future.exception()
self._ssl_connect_future = None
if self._close_callback is not None:
cb = self._close_callback
self._close_callback = None
self.io_loop.add_callback(cb)
# Clear the buffers so they can be cleared immediately even
# if the IOStream object is kept alive by a reference cycle.
# TODO: Clear the read buffer too; it currently breaks some tests.
self._write_buffer = None # type: ignore
def reading(self) -> bool:
"""Returns ``True`` if we are currently reading from the stream."""
return self._read_future is not None
def writing(self) -> bool:
"""Returns ``True`` if we are currently writing to the stream."""
return bool(self._write_buffer)
def closed(self) -> bool:
"""Returns ``True`` if the stream has been closed."""
return self._closed
def set_nodelay(self, value: bool) -> None:
"""Sets the no-delay flag for this stream.
By default, data written to TCP streams may be held for a time
to make the most efficient use of bandwidth (according to
Nagle's algorithm). The no-delay flag requests that data be
written as soon as possible, even if doing so would consume
additional bandwidth.
This flag is currently defined only for TCP-based ``IOStreams``.
.. versionadded:: 3.1
"""
pass
def _handle_connect(self) -> None:
raise NotImplementedError()
def _handle_events(self, fd: Union[int, ioloop._Selectable], events: int) -> None:
if self.closed():
gen_log.warning("Got events for closed stream %s", fd)
return
try:
if self._connecting:
# Most IOLoops will report a write failed connect
# with the WRITE event, but SelectIOLoop reports a
# READ as well so we must check for connecting before
# either.
self._handle_connect()
if self.closed():
return
if events & self.io_loop.READ:
self._handle_read()
if self.closed():
return
if events & self.io_loop.WRITE:
self._handle_write()
if self.closed():
return
if events & self.io_loop.ERROR:
self.error = self.get_fd_error()
# We may have queued up a user callback in _handle_read or
# _handle_write, so don't close the IOStream until those
# callbacks have had a chance to run.
self.io_loop.add_callback(self.close)
return
state = self.io_loop.ERROR
if self.reading():
state |= self.io_loop.READ
if self.writing():
state |= self.io_loop.WRITE
if state == self.io_loop.ERROR and self._read_buffer_size == 0:
# If the connection is idle, listen for reads too so
# we can tell if the connection is closed. If there is
# data in the read buffer we won't run the close callback
# yet anyway, so we don't need to listen in this case.
state |= self.io_loop.READ
if state != self._state:
assert (
self._state is not None
), "shouldn't happen: _handle_events without self._state"
self._state = state
self.io_loop.update_handler(self.fileno(), self._state)
except UnsatisfiableReadError as e:
gen_log.info("Unsatisfiable read, closing connection: %s" % e)
self.close(exc_info=e)
except Exception as e:
gen_log.error("Uncaught exception, closing connection.", exc_info=True)
self.close(exc_info=e)
raise
def _read_to_buffer_loop(self) -> Optional[int]:
# This method is called from _handle_read and _try_inline_read.
if self._read_bytes is not None:
target_bytes = self._read_bytes # type: Optional[int]
elif self._read_max_bytes is not None:
target_bytes = self._read_max_bytes
elif self.reading():
# For read_until without max_bytes, or
# read_until_close, read as much as we can before
# scanning for the delimiter.
target_bytes = None
else:
target_bytes = 0
next_find_pos = 0
while not self.closed():
# Read from the socket until we get EWOULDBLOCK or equivalent.
# SSL sockets do some internal buffering, and if the data is
# sitting in the SSL object's buffer select() and friends
# can't see it; the only way to find out if it's there is to
# try to read it.
if self._read_to_buffer() == 0:
break
# If we've read all the bytes we can use, break out of
# this loop.
# If we've reached target_bytes, we know we're done.
if target_bytes is not None and self._read_buffer_size >= target_bytes:
break
# Otherwise, we need to call the more expensive find_read_pos.
# It's inefficient to do this on every read, so instead
# do it on the first read and whenever the read buffer
# size has doubled.
if self._read_buffer_size >= next_find_pos:
pos = self._find_read_pos()
if pos is not None:
return pos
next_find_pos = self._read_buffer_size * 2
return self._find_read_pos()
def _handle_read(self) -> None:
try:
pos = self._read_to_buffer_loop()
except UnsatisfiableReadError:
raise
except asyncio.CancelledError:
raise
except Exception as e:
gen_log.warning("error on read: %s" % e)
self.close(exc_info=e)
return
if pos is not None:
self._read_from_buffer(pos)
def _start_read(self) -> Future:
if self._read_future is not None:
# It is an error to start a read while a prior read is unresolved.
# However, if the prior read is unresolved because the stream was
# closed without satisfying it, it's better to raise
# StreamClosedError instead of AssertionError. In particular, this
# situation occurs in harmless situations in http1connection.py and
# an AssertionError would be logged noisily.
#
# On the other hand, it is legal to start a new read while the
# stream is closed, in case the read can be satisfied from the
# read buffer. So we only want to check the closed status of the
# stream if we need to decide what kind of error to raise for
# "already reading".
#
# These conditions have proven difficult to test; we have no
# unittests that reliably verify this behavior so be careful
# when making changes here. See #2651 and #2719.
self._check_closed()
assert self._read_future is None, "Already reading"
self._read_future = Future()
return self._read_future
def _finish_read(self, size: int, streaming: bool) -> None:
if self._user_read_buffer:
self._read_buffer = self._after_user_read_buffer or bytearray()
self._after_user_read_buffer = None
self._read_buffer_pos = 0
self._read_buffer_size = len(self._read_buffer)
self._user_read_buffer = False
result = size # type: Union[int, bytes]
else:
result = self._consume(size)
if self._read_future is not None:
future = self._read_future
self._read_future = None
future_set_result_unless_cancelled(future, result)
self._maybe_add_error_listener()
def _try_inline_read(self) -> None:
"""Attempt to complete the current read operation from buffered data.
If the read can be completed without blocking, schedules the
read callback on the next IOLoop iteration; otherwise starts
listening for reads on the socket.
"""
# See if we've already got the data from a previous read
pos = self._find_read_pos()
if pos is not None:
self._read_from_buffer(pos)
return
self._check_closed()
pos = self._read_to_buffer_loop()
if pos is not None:
self._read_from_buffer(pos)
return
# We couldn't satisfy the read inline, so make sure we're
# listening for new data unless the stream is closed.
if not self.closed():
self._add_io_state(ioloop.IOLoop.READ)
def _read_to_buffer(self) -> Optional[int]:
"""Reads from the socket and appends the result to the read buffer.
Returns the number of bytes read. Returns 0 if there is nothing
to read (i.e. the read returns EWOULDBLOCK or equivalent). On
error closes the socket and raises an exception.
"""
try:
while True:
try:
if self._user_read_buffer:
buf = memoryview(self._read_buffer)[
self._read_buffer_size :
] # type: Union[memoryview, bytearray]
else:
buf = bytearray(self.read_chunk_size)
bytes_read = self.read_from_fd(buf)
except (socket.error, IOError, OSError) as e:
# ssl.SSLError is a subclass of socket.error
if self._is_connreset(e):
# Treat ECONNRESET as a connection close rather than
# an error to minimize log spam (the exception will
# be available on self.error for apps that care).
self.close(exc_info=e)
return None
self.close(exc_info=e)
raise
break
if bytes_read is None:
return 0
elif bytes_read == 0:
self.close()
return 0
if not self._user_read_buffer:
self._read_buffer += memoryview(buf)[:bytes_read]
self._read_buffer_size += bytes_read
finally:
# Break the reference to buf so we don't waste a chunk's worth of
# memory in case an exception hangs on to our stack frame.
del buf
if self._read_buffer_size > self.max_buffer_size:
gen_log.error("Reached maximum read buffer size")
self.close()
raise StreamBufferFullError("Reached maximum read buffer size")
return bytes_read
def _read_from_buffer(self, pos: int) -> None:
"""Attempts to complete the currently-pending read from the buffer.
The argument is either a position in the read buffer or None,
as returned by _find_read_pos.
"""
self._read_bytes = self._read_delimiter = self._read_regex = None
self._read_partial = False
self._finish_read(pos, False)
def _find_read_pos(self) -> Optional[int]:
"""Attempts to find a position in the read buffer that satisfies
the currently-pending read.
Returns a position in the buffer if the current read can be satisfied,
or None if it cannot.
"""
if self._read_bytes is not None and (
self._read_buffer_size >= self._read_bytes
or (self._read_partial and self._read_buffer_size > 0)
):
num_bytes = min(self._read_bytes, self._read_buffer_size)
return num_bytes
elif self._read_delimiter is not None:
# Multi-byte delimiters (e.g. '\r\n') may straddle two
# chunks in the read buffer, so we can't easily find them
# without collapsing the buffer. However, since protocols
# using delimited reads (as opposed to reads of a known
# length) tend to be "line" oriented, the delimiter is likely
# to be in the first few chunks. Merge the buffer gradually
# since large merges are relatively expensive and get undone in
# _consume().
if self._read_buffer:
loc = self._read_buffer.find(
self._read_delimiter, self._read_buffer_pos
)
if loc != -1:
loc -= self._read_buffer_pos
delimiter_len = len(self._read_delimiter)
self._check_max_bytes(self._read_delimiter, loc + delimiter_len)
return loc + delimiter_len
self._check_max_bytes(self._read_delimiter, self._read_buffer_size)
elif self._read_regex is not None:
if self._read_buffer:
m = self._read_regex.search(self._read_buffer, self._read_buffer_pos)
if m is not None:
loc = m.end() - self._read_buffer_pos
self._check_max_bytes(self._read_regex, loc)
return loc
self._check_max_bytes(self._read_regex, self._read_buffer_size)
return None
def _check_max_bytes(self, delimiter: Union[bytes, Pattern], size: int) -> None:
if self._read_max_bytes is not None and size > self._read_max_bytes:
raise UnsatisfiableReadError(
"delimiter %r not found within %d bytes"
% (delimiter, self._read_max_bytes)
)
def _handle_write(self) -> None:
while True:
size = len(self._write_buffer)
if not size:
break
assert size > 0
try:
if _WINDOWS:
# On windows, socket.send blows up if given a
# write buffer that's too large, instead of just
# returning the number of bytes it was able to
# process. Therefore we must not call socket.send
# with more than 128KB at a time.
size = 128 * 1024
num_bytes = self.write_to_fd(self._write_buffer.peek(size))
if num_bytes == 0:
break
self._write_buffer.advance(num_bytes)
self._total_write_done_index += num_bytes
except BlockingIOError:
break
except (socket.error, IOError, OSError) as e:
if not self._is_connreset(e):
# Broken pipe errors are usually caused by connection
# reset, and its better to not log EPIPE errors to
# minimize log spam
gen_log.warning("Write error on %s: %s", self.fileno(), e)
self.close(exc_info=e)
return
while self._write_futures:
index, future = self._write_futures[0]
if index > self._total_write_done_index:
break
self._write_futures.popleft()
future_set_result_unless_cancelled(future, None)
def _consume(self, loc: int) -> bytes:
# Consume loc bytes from the read buffer and return them
if loc == 0:
return b""
assert loc <= self._read_buffer_size
# Slice the bytearray buffer into bytes, without intermediate copying
b = (
memoryview(self._read_buffer)[
self._read_buffer_pos : self._read_buffer_pos + loc
]
).tobytes()
self._read_buffer_pos += loc
self._read_buffer_size -= loc
# Amortized O(1) shrink
# (this heuristic is implemented natively in Python 3.4+
# but is replicated here for Python 2)
if self._read_buffer_pos > self._read_buffer_size:
del self._read_buffer[: self._read_buffer_pos]
self._read_buffer_pos = 0
return b
def _check_closed(self) -> None:
if self.closed():
raise StreamClosedError(real_error=self.error)
def _maybe_add_error_listener(self) -> None:
# This method is part of an optimization: to detect a connection that
# is closed when we're not actively reading or writing, we must listen
# for read events. However, it is inefficient to do this when the
# connection is first established because we are going to read or write
# immediately anyway. Instead, we insert checks at various times to
# see if the connection is idle and add the read listener then.
if self._state is None or self._state == ioloop.IOLoop.ERROR:
if (
not self.closed()
and self._read_buffer_size == 0
and self._close_callback is not None
):
self._add_io_state(ioloop.IOLoop.READ)
def _add_io_state(self, state: int) -> None:
"""Adds `state` (IOLoop.{READ,WRITE} flags) to our event handler.
Implementation notes: Reads and writes have a fast path and a
slow path. The fast path reads synchronously from socket
buffers, while the slow path uses `_add_io_state` to schedule
an IOLoop callback.
To detect closed connections, we must have called
`_add_io_state` at some point, but we want to delay this as
much as possible so we don't have to set an `IOLoop.ERROR`
listener that will be overwritten by the next slow-path
operation. If a sequence of fast-path ops do not end in a
slow-path op, (e.g. for an @asynchronous long-poll request),
we must add the error handler.
TODO: reevaluate this now that callbacks are gone.
"""
if self.closed():
# connection has been closed, so there can be no future events
return
if self._state is None:
self._state = ioloop.IOLoop.ERROR | state
self.io_loop.add_handler(self.fileno(), self._handle_events, self._state)
elif not self._state & state:
self._state = self._state | state
self.io_loop.update_handler(self.fileno(), self._state)
def _is_connreset(self, exc: BaseException) -> bool:
"""Return ``True`` if exc is ECONNRESET or equivalent.
May be overridden in subclasses.
"""
return (
isinstance(exc, (socket.error, IOError))
and errno_from_exception(exc) in _ERRNO_CONNRESET
)
class IOStream(BaseIOStream):
r"""Socket-based `IOStream` implementation.
This class supports the read and write methods from `BaseIOStream`
plus a `connect` method.
The ``socket`` parameter may either be connected or unconnected.
For server operations the socket is the result of calling
`socket.accept <socket.socket.accept>`. For client operations the
socket is created with `socket.socket`, and may either be
connected before passing it to the `IOStream` or connected with
`IOStream.connect`.
A very simple (and broken) HTTP client using this class:
.. testcode::
import tornado.ioloop
import tornado.iostream
import socket
async def main():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
stream = tornado.iostream.IOStream(s)
await stream.connect(("friendfeed.com", 80))
await stream.write(b"GET / HTTP/1.0\r\nHost: friendfeed.com\r\n\r\n")
header_data = await stream.read_until(b"\r\n\r\n")
headers = {}
for line in header_data.split(b"\r\n"):
parts = line.split(b":")
if len(parts) == 2:
headers[parts[0].strip()] = parts[1].strip()
body_data = await stream.read_bytes(int(headers[b"Content-Length"]))
print(body_data)
stream.close()
if __name__ == '__main__':
tornado.ioloop.IOLoop.current().run_sync(main)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
stream = tornado.iostream.IOStream(s)
stream.connect(("friendfeed.com", 80), send_request)
tornado.ioloop.IOLoop.current().start()
.. testoutput::
:hide:
"""
def __init__(self, socket: socket.socket, *args: Any, **kwargs: Any) -> None:
self.socket = socket
self.socket.setblocking(False)
super(IOStream, self).__init__(*args, **kwargs)
def fileno(self) -> Union[int, ioloop._Selectable]:
return self.socket
def close_fd(self) -> None:
self.socket.close()
self.socket = None # type: ignore
def get_fd_error(self) -> Optional[Exception]:
errno = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
return socket.error(errno, os.strerror(errno))
def read_from_fd(self, buf: Union[bytearray, memoryview]) -> Optional[int]:
try:
return self.socket.recv_into(buf, len(buf))
except BlockingIOError:
return None
finally:
del buf
def write_to_fd(self, data: memoryview) -> int:
try:
return self.socket.send(data) # type: ignore
finally:
# Avoid keeping to data, which can be a memoryview.
# See https://github.com/tornadoweb/tornado/pull/2008
del data
def connect(
self: _IOStreamType, address: Any, server_hostname: Optional[str] = None
) -> "Future[_IOStreamType]":
"""Connects the socket to a remote address without blocking.
May only be called if the socket passed to the constructor was
not previously connected. The address parameter is in the
same format as for `socket.connect <socket.socket.connect>` for
the type of socket passed to the IOStream constructor,
e.g. an ``(ip, port)`` tuple. Hostnames are accepted here,
but will be resolved synchronously and block the IOLoop.
If you have a hostname instead of an IP address, the `.TCPClient`
class is recommended instead of calling this method directly.
`.TCPClient` will do asynchronous DNS resolution and handle
both IPv4 and IPv6.
If ``callback`` is specified, it will be called with no
arguments when the connection is completed; if not this method
returns a `.Future` (whose result after a successful
connection will be the stream itself).
In SSL mode, the ``server_hostname`` parameter will be used
for certificate validation (unless disabled in the
``ssl_options``) and SNI (if supported; requires Python
2.7.9+).
Note that it is safe to call `IOStream.write
<BaseIOStream.write>` while the connection is pending, in
which case the data will be written as soon as the connection
is ready. Calling `IOStream` read methods before the socket is
connected works on some platforms but is non-portable.
.. versionchanged:: 4.0
If no callback is given, returns a `.Future`.
.. versionchanged:: 4.2
SSL certificates are validated by default; pass
``ssl_options=dict(cert_reqs=ssl.CERT_NONE)`` or a
suitably-configured `ssl.SSLContext` to the
`SSLIOStream` constructor to disable.
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
self._connecting = True
future = Future() # type: Future[_IOStreamType]
self._connect_future = typing.cast("Future[IOStream]", future)
try:
self.socket.connect(address)
except BlockingIOError:
# In non-blocking mode we expect connect() to raise an
# exception with EINPROGRESS or EWOULDBLOCK.
pass
except socket.error as e:
# On freebsd, other errors such as ECONNREFUSED may be
# returned immediately when attempting to connect to
# localhost, so handle them the same way as an error
# reported later in _handle_connect.
if future is None:
gen_log.warning("Connect error on fd %s: %s", self.socket.fileno(), e)
self.close(exc_info=e)
return future
self._add_io_state(self.io_loop.WRITE)
return future
def start_tls(
self,
server_side: bool,
ssl_options: Optional[Union[Dict[str, Any], ssl.SSLContext]] = None,
server_hostname: Optional[str] = None,
) -> Awaitable["SSLIOStream"]:
"""Convert this `IOStream` to an `SSLIOStream`.
This enables protocols that begin in clear-text mode and
switch to SSL after some initial negotiation (such as the
``STARTTLS`` extension to SMTP and IMAP).
This method cannot be used if there are outstanding reads
or writes on the stream, or if there is any data in the
IOStream's buffer (data in the operating system's socket
buffer is allowed). This means it must generally be used
immediately after reading or writing the last clear-text
data. It can also be used immediately after connecting,
before any reads or writes.
The ``ssl_options`` argument may be either an `ssl.SSLContext`
object or a dictionary of keyword arguments for the
`ssl.wrap_socket` function. The ``server_hostname`` argument
will be used for certificate validation unless disabled
in the ``ssl_options``.
This method returns a `.Future` whose result is the new
`SSLIOStream`. After this method has been called,
any other operation on the original stream is undefined.
If a close callback is defined on this stream, it will be
transferred to the new stream.
.. versionadded:: 4.0
.. versionchanged:: 4.2
SSL certificates are validated by default; pass
``ssl_options=dict(cert_reqs=ssl.CERT_NONE)`` or a
suitably-configured `ssl.SSLContext` to disable.
"""
if (
self._read_future
or self._write_futures
or self._connect_future
or self._closed
or self._read_buffer
or self._write_buffer
):
raise ValueError("IOStream is not idle; cannot convert to SSL")
if ssl_options is None:
if server_side:
ssl_options = _server_ssl_defaults
else:
ssl_options = _client_ssl_defaults
socket = self.socket
self.io_loop.remove_handler(socket)
self.socket = None # type: ignore
socket = ssl_wrap_socket(
socket,
ssl_options,
server_hostname=server_hostname,
server_side=server_side,
do_handshake_on_connect=False,
)
orig_close_callback = self._close_callback
self._close_callback = None
future = Future() # type: Future[SSLIOStream]
ssl_stream = SSLIOStream(socket, ssl_options=ssl_options)
ssl_stream.set_close_callback(orig_close_callback)
ssl_stream._ssl_connect_future = future
ssl_stream.max_buffer_size = self.max_buffer_size
ssl_stream.read_chunk_size = self.read_chunk_size
return future
def _handle_connect(self) -> None:
try:
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
except socket.error as e:
# Hurd doesn't allow SO_ERROR for loopback sockets because all
# errors for such sockets are reported synchronously.
if errno_from_exception(e) == errno.ENOPROTOOPT:
err = 0
if err != 0:
self.error = socket.error(err, os.strerror(err))
# IOLoop implementations may vary: some of them return
# an error state before the socket becomes writable, so
# in that case a connection failure would be handled by the
# error path in _handle_events instead of here.
if self._connect_future is None:
gen_log.warning(
"Connect error on fd %s: %s",
self.socket.fileno(),
errno.errorcode[err],
)
self.close()
return
if self._connect_future is not None:
future = self._connect_future
self._connect_future = None
future_set_result_unless_cancelled(future, self)
self._connecting = False
def set_nodelay(self, value: bool) -> None:
if self.socket is not None and self.socket.family in (
socket.AF_INET,
socket.AF_INET6,
):
try:
self.socket.setsockopt(
socket.IPPROTO_TCP, socket.TCP_NODELAY, 1 if value else 0
)
except socket.error as e:
# Sometimes setsockopt will fail if the socket is closed
# at the wrong time. This can happen with HTTPServer
# resetting the value to ``False`` between requests.
if e.errno != errno.EINVAL and not self._is_connreset(e):
raise
class SSLIOStream(IOStream):
"""A utility class to write to and read from a non-blocking SSL socket.
If the socket passed to the constructor is already connected,
it should be wrapped with::
ssl.wrap_socket(sock, do_handshake_on_connect=False, **kwargs)
before constructing the `SSLIOStream`. Unconnected sockets will be
wrapped when `IOStream.connect` is finished.
"""
socket = None # type: ssl.SSLSocket
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""The ``ssl_options`` keyword argument may either be an
`ssl.SSLContext` object or a dictionary of keywords arguments
for `ssl.wrap_socket`
"""
self._ssl_options = kwargs.pop("ssl_options", _client_ssl_defaults)
super(SSLIOStream, self).__init__(*args, **kwargs)
self._ssl_accepting = True
self._handshake_reading = False
self._handshake_writing = False
self._server_hostname = None # type: Optional[str]
# If the socket is already connected, attempt to start the handshake.
try:
self.socket.getpeername()
except socket.error:
pass
else:
# Indirectly start the handshake, which will run on the next
# IOLoop iteration and then the real IO state will be set in
# _handle_events.
self._add_io_state(self.io_loop.WRITE)
def reading(self) -> bool:
return self._handshake_reading or super(SSLIOStream, self).reading()
def writing(self) -> bool:
return self._handshake_writing or super(SSLIOStream, self).writing()
def _do_ssl_handshake(self) -> None:
# Based on code from test_ssl.py in the python stdlib
try:
self._handshake_reading = False
self._handshake_writing = False
self.socket.do_handshake()
except ssl.SSLError as err:
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
self._handshake_reading = True
return
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
self._handshake_writing = True
return
elif err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
return self.close(exc_info=err)
elif err.args[0] == ssl.SSL_ERROR_SSL:
try:
peer = self.socket.getpeername()
except Exception:
peer = "(not connected)"
gen_log.warning(
"SSL Error on %s %s: %s", self.socket.fileno(), peer, err
)
return self.close(exc_info=err)
raise
except ssl.CertificateError as err:
# CertificateError can happen during handshake (hostname
# verification) and should be passed to user. Starting
# in Python 3.7, this error is a subclass of SSLError
# and will be handled by the previous block instead.
return self.close(exc_info=err)
except socket.error as err:
# Some port scans (e.g. nmap in -sT mode) have been known
# to cause do_handshake to raise EBADF and ENOTCONN, so make
# those errors quiet as well.
# https://groups.google.com/forum/?fromgroups#!topic/python-tornado/ApucKJat1_0
# Errno 0 is also possible in some cases (nc -z).
# https://github.com/tornadoweb/tornado/issues/2504
if self._is_connreset(err) or err.args[0] in (
0,
errno.EBADF,
errno.ENOTCONN,
):
return self.close(exc_info=err)
raise
except AttributeError as err:
# On Linux, if the connection was reset before the call to
# wrap_socket, do_handshake will fail with an
# AttributeError.
return self.close(exc_info=err)
else:
self._ssl_accepting = False
if not self._verify_cert(self.socket.getpeercert()):
self.close()
return
self._finish_ssl_connect()
def _finish_ssl_connect(self) -> None:
if self._ssl_connect_future is not None:
future = self._ssl_connect_future
self._ssl_connect_future = None
future_set_result_unless_cancelled(future, self)
def _verify_cert(self, peercert: Any) -> bool:
"""Returns ``True`` if peercert is valid according to the configured
validation mode and hostname.
The ssl handshake already tested the certificate for a valid
CA signature; the only thing that remains is to check
the hostname.
"""
if isinstance(self._ssl_options, dict):
verify_mode = self._ssl_options.get("cert_reqs", ssl.CERT_NONE)
elif isinstance(self._ssl_options, ssl.SSLContext):
verify_mode = self._ssl_options.verify_mode
assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL)
if verify_mode == ssl.CERT_NONE or self._server_hostname is None:
return True
cert = self.socket.getpeercert()
if cert is None and verify_mode == ssl.CERT_REQUIRED:
gen_log.warning("No SSL certificate given")
return False
try:
ssl.match_hostname(peercert, self._server_hostname)
except ssl.CertificateError as e:
gen_log.warning("Invalid SSL certificate: %s" % e)
return False
else:
return True
def _handle_read(self) -> None:
if self._ssl_accepting:
self._do_ssl_handshake()
return
super(SSLIOStream, self)._handle_read()
def _handle_write(self) -> None:
if self._ssl_accepting:
self._do_ssl_handshake()
return
super(SSLIOStream, self)._handle_write()
def connect(
self, address: Tuple, server_hostname: Optional[str] = None
) -> "Future[SSLIOStream]":
self._server_hostname = server_hostname
# Ignore the result of connect(). If it fails,
# wait_for_handshake will raise an error too. This is
# necessary for the old semantics of the connect callback
# (which takes no arguments). In 6.0 this can be refactored to
# be a regular coroutine.
# TODO: This is trickier than it looks, since if write()
# is called with a connect() pending, we want the connect
# to resolve before the write. Or do we care about this?
# (There's a test for it, but I think in practice users
# either wait for the connect before performing a write or
# they don't care about the connect Future at all)
fut = super(SSLIOStream, self).connect(address)
fut.add_done_callback(lambda f: f.exception())
return self.wait_for_handshake()
def _handle_connect(self) -> None:
# Call the superclass method to check for errors.
super(SSLIOStream, self)._handle_connect()
if self.closed():
return
# When the connection is complete, wrap the socket for SSL
# traffic. Note that we do this by overriding _handle_connect
# instead of by passing a callback to super().connect because
# user callbacks are enqueued asynchronously on the IOLoop,
# but since _handle_events calls _handle_connect immediately
# followed by _handle_write we need this to be synchronous.
#
# The IOLoop will get confused if we swap out self.socket while the
# fd is registered, so remove it now and re-register after
# wrap_socket().
self.io_loop.remove_handler(self.socket)
old_state = self._state
assert old_state is not None
self._state = None
self.socket = ssl_wrap_socket(
self.socket,
self._ssl_options,
server_hostname=self._server_hostname,
do_handshake_on_connect=False,
)
self._add_io_state(old_state)
def wait_for_handshake(self) -> "Future[SSLIOStream]":
"""Wait for the initial SSL handshake to complete.
If a ``callback`` is given, it will be called with no
arguments once the handshake is complete; otherwise this
method returns a `.Future` which will resolve to the
stream itself after the handshake is complete.
Once the handshake is complete, information such as
the peer's certificate and NPN/ALPN selections may be
accessed on ``self.socket``.
This method is intended for use on server-side streams
or after using `IOStream.start_tls`; it should not be used
with `IOStream.connect` (which already waits for the
handshake to complete). It may only be called once per stream.
.. versionadded:: 4.2
.. versionchanged:: 6.0
The ``callback`` argument was removed. Use the returned
`.Future` instead.
"""
if self._ssl_connect_future is not None:
raise RuntimeError("Already waiting")
future = self._ssl_connect_future = Future()
if not self._ssl_accepting:
self._finish_ssl_connect()
return future
def write_to_fd(self, data: memoryview) -> int:
try:
return self.socket.send(data) # type: ignore
except ssl.SSLError as e:
if e.args[0] == ssl.SSL_ERROR_WANT_WRITE:
# In Python 3.5+, SSLSocket.send raises a WANT_WRITE error if
# the socket is not writeable; we need to transform this into
# an EWOULDBLOCK socket.error or a zero return value,
# either of which will be recognized by the caller of this
# method. Prior to Python 3.5, an unwriteable socket would
# simply return 0 bytes written.
return 0
raise
finally:
# Avoid keeping to data, which can be a memoryview.
# See https://github.com/tornadoweb/tornado/pull/2008
del data
def read_from_fd(self, buf: Union[bytearray, memoryview]) -> Optional[int]:
try:
if self._ssl_accepting:
# If the handshake hasn't finished yet, there can't be anything
# to read (attempting to read may or may not raise an exception
# depending on the SSL version)
return None
try:
return self.socket.recv_into(buf, len(buf))
except ssl.SSLError as e:
# SSLError is a subclass of socket.error, so this except
# block must come first.
if e.args[0] == ssl.SSL_ERROR_WANT_READ:
return None
else:
raise
except BlockingIOError:
return None
finally:
del buf
def _is_connreset(self, e: BaseException) -> bool:
if isinstance(e, ssl.SSLError) and e.args[0] == ssl.SSL_ERROR_EOF:
return True
return super(SSLIOStream, self)._is_connreset(e)
class PipeIOStream(BaseIOStream):
"""Pipe-based `IOStream` implementation.
The constructor takes an integer file descriptor (such as one returned
by `os.pipe`) rather than an open file object. Pipes are generally
one-way, so a `PipeIOStream` can be used for reading or writing but not
both.
"""
def __init__(self, fd: int, *args: Any, **kwargs: Any) -> None:
self.fd = fd
self._fio = io.FileIO(self.fd, "r+")
_set_nonblocking(fd)
super(PipeIOStream, self).__init__(*args, **kwargs)
def fileno(self) -> int:
return self.fd
def close_fd(self) -> None:
self._fio.close()
def write_to_fd(self, data: memoryview) -> int:
try:
return os.write(self.fd, data) # type: ignore
finally:
# Avoid keeping to data, which can be a memoryview.
# See https://github.com/tornadoweb/tornado/pull/2008
del data
def read_from_fd(self, buf: Union[bytearray, memoryview]) -> Optional[int]:
try:
return self._fio.readinto(buf) # type: ignore
except (IOError, OSError) as e:
if errno_from_exception(e) == errno.EBADF:
# If the writing half of a pipe is closed, select will
# report it as readable but reads will fail with EBADF.
self.close(exc_info=e)
return None
else:
raise
finally:
del buf
def doctests() -> Any:
import doctest
return doctest.DocTestSuite()
| bdarnell/tornado | tornado/iostream.py | Python | apache-2.0 | 65,697 |
# -*- coding: utf-8 -*-
"""
Show a tray icon to indicate the status of Github service.
Could serve as notification for pull requests, etc, in the future.
Author: Gabriel Patiño <gepatino@gmail.com>
License: Do whatever you want
"""
import appindicator
import dateutil.parser
import gtk
import os
import pynotify
import sys
from ghindicator import language
from ghindicator.monitor import GitHubMonitor
from ghindicator.options import ICON_DIR
from ghindicator.options import APPNAME
import logging
logger = logging.getLogger(APPNAME)
def get_icon_file_path(name):
path = os.path.join(ICON_DIR, name + '.png')
return path
class GitHubApplet(object):
def __init__(self, options):
self.options = options
self.last_updated = None
self.monitor = GitHubMonitor(options.username, options.password)
self.tray = self.create_indicator()
self.status_menu = None
self.status_details_menu = None
self.menu = self.create_menu()
self.last_events = []
pynotify.init(APPNAME)
def create_indicator(self): pass
def set_icon(self, icon): pass
def create_menu(self):
self.status_menu = gtk.MenuItem('Status: Unknown')
self.status_details_menu = gtk.MenuItem('')
#item_events = gtk.MenuItem('Last events')
#item_events.connect('activate', self.last_events_cb)
#item_prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
#item_prefs.connect('activate', self.preferences_cb)
item_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
item_quit.connect('activate', self.quit_cb)
menu = gtk.Menu()
menu.append(self.status_menu)
menu.append(self.status_details_menu)
menu.append(gtk.SeparatorMenuItem())
#menu.append(item_events)
#menu.append(gtk.SeparatorMenuItem())
#menu.append(item_prefs)
#menu.append(gtk.SeparatorMenuItem())
menu.append(item_quit)
return menu
def main(self):
gtk.timeout_add(500, self.update_status)
gtk.timeout_add(500, self.update_events)
gtk.main()
def last_events_cb(self, *args, **kwargs):
pass
def preferences_cb(self, *args, **kwargs):
pass
def quit_cb(self, *args, **kwargs):
gtk.main_quit()
sys.exit()
raise KeyboardInterrupt
def update_status(self, *args, **kwargs):
status = self.monitor.check_status()
if status is not None:
service_status = status['message']['status']
details = status['message']['body']
date = status['message']['created_on']
date = dateutil.parser.parse(date)
date = date.strftime('%Y-%M-%d %H:%M')
title = _('GitHub service status is %(status)s') % {'status': service_status}
message = _('%(created_on)s - %(body)s') % {'body': details, 'created_on': date}
icon = get_icon_file_path(service_status)
self.set_icon(icon)
self.notify(title, message, icon)
self._set_menu_status(title, message)
gtk.timeout_add(self.options.update_time * 1000, self.update_status)
def _set_menu_status(self, title, message):
LINE_LENGTH = 50
if len(message) > LINE_LENGTH:
i = 0
parts = []
while i < len(message):
j = min(len(message), i + LINE_LENGTH)
if j < len(message):
if message[j] != ' ':
j = message.find(' ', j)
parts.append(message[i:j])
i = j
msg = '\n'.join(parts)
else:
msg = message
self.status_menu.get_child().set_text(title)
self.status_details_menu.get_child().set_text(msg)
def update_events(self, *args, **kwargs):
events = self.monitor.check_events()
update_menu = False
for e in reversed(events):
update_menu = True
title = _('%(created_at)s - %(type)s') % e
data = {'actor': e['actor']['login'], 'object': e['repo']['name']}
message = _('%(actor)s on %(object)s') % data
icon = self.monitor.get_user_icon(e['actor'])
self.notify(title, message, icon)
self.last_events.insert(e)
if update_menu:
self.last_events = self.last_events[:5]
gtk.timeout_add(5 * 60 * 1000, self.update_events)
def notify(self, title, message, icon):
logger.debug('%s - %s' % (title, message.replace('\n', ' ')))
n = pynotify.Notification(title, message, icon)
n.show()
class GitHubAppIndicator(GitHubApplet):
def create_indicator(self):
icon_file = get_icon_file_path('unknown')
logger.debug(_('Creating appindicator with default icon %s') % icon_file)
ind = appindicator.Indicator(APPNAME, icon_file,
appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status(appindicator.STATUS_ACTIVE)
return ind
def create_menu(self):
menu = super(GitHubAppIndicator, self).create_menu()
self.tray.set_menu(menu)
menu.show_all()
return menu
def set_icon(self, icon):
logger.debug(_('Setting icon from file: %s') % icon)
self.tray.set_icon(icon)
class GitHubStatusIcon(GitHubApplet):
def create_indicator(self):
icon_file = get_icon_file_path('unknown')
logger.debug(_('Creating StatusIcon from file (%s)') % icon_file)
icon = gtk.status_icon_new_from_file(icon_file)
if not icon.is_embedded():
logging.error(_('Notification area not found for Status Icon version'))
return icon
def create_menu(self):
menu = super(GitHubStatusIcon, self).create_menu()
self.tray.connect('popup-menu', self.popup_menu_cb)
return men
def set_icon(self, icon):
logger.debug(_('Setting icon from file: %s') % icon)
self.tray.set_from_file(icon)
def popup_menu_cb(self, widget, button, time):
if button == 3:
self.menu.show_all()
self.menu.popup(None, None, None, 3, time)
def get_app(options):
if options.status_icon:
logger.debug(_('Using StatusIcon version'))
app = GitHubStatusIcon(options)
else:
logger.debug(_('Using AppIndicator version'))
app = GitHubAppIndicator(options)
return app
| gepatino/github-indicator | ghindicator/gui.py | Python | gpl-3.0 | 6,462 |
# -*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
kallithea.lib.auth_modules.auth_ldap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kallithea authentication plugin for LDAP
This file was forked by the Kallithea project in July 2014.
Original author and date, and relevant copyright and licensing information is below:
:created_on: Created on Nov 17, 2010
:author: marcink
:copyright: (c) 2013 RhodeCode GmbH, and others.
:license: GPLv3, see LICENSE.md for more details.
"""
import logging
import traceback
from kallithea.lib import auth_modules
from kallithea.lib.compat import hybrid_property
from kallithea.lib.utils2 import safe_unicode, safe_str
from kallithea.lib.exceptions import (
LdapConnectionError, LdapUsernameError, LdapPasswordError, LdapImportError
)
from kallithea.model.db import User
log = logging.getLogger(__name__)
try:
import ldap
except ImportError:
# means that python-ldap is not installed
ldap = None
class AuthLdap(object):
def __init__(self, server, base_dn, port=389, bind_dn='', bind_pass='',
tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3,
ldap_filter='(&(objectClass=user)(!(objectClass=computer)))',
search_scope='SUBTREE', attr_login='uid'):
if ldap is None:
raise LdapImportError
self.ldap_version = ldap_version
ldap_server_type = 'ldap'
self.TLS_KIND = tls_kind
if self.TLS_KIND == 'LDAPS':
port = port or 689
ldap_server_type = ldap_server_type + 's'
OPT_X_TLS_DEMAND = 2
self.TLS_REQCERT = getattr(ldap, 'OPT_X_TLS_%s' % tls_reqcert,
OPT_X_TLS_DEMAND)
# split server into list
self.LDAP_SERVER_ADDRESS = server.split(',')
self.LDAP_SERVER_PORT = port
# USE FOR READ ONLY BIND TO LDAP SERVER
self.LDAP_BIND_DN = safe_str(bind_dn)
self.LDAP_BIND_PASS = safe_str(bind_pass)
_LDAP_SERVERS = []
for host in self.LDAP_SERVER_ADDRESS:
_LDAP_SERVERS.append("%s://%s:%s" % (ldap_server_type,
host.replace(' ', ''),
self.LDAP_SERVER_PORT))
self.LDAP_SERVER = str(', '.join(s for s in _LDAP_SERVERS))
self.BASE_DN = safe_str(base_dn)
self.LDAP_FILTER = safe_str(ldap_filter)
self.SEARCH_SCOPE = getattr(ldap, 'SCOPE_%s' % search_scope)
self.attr_login = attr_login
def authenticate_ldap(self, username, password):
"""
Authenticate a user via LDAP and return his/her LDAP properties.
Raises AuthenticationError if the credentials are rejected, or
EnvironmentError if the LDAP server can't be reached.
:param username: username
:param password: password
"""
from kallithea.lib.helpers import chop_at
uid = chop_at(username, "@%s" % self.LDAP_SERVER_ADDRESS)
if not password:
log.debug("Attempt to authenticate LDAP user "
"with blank password rejected.")
raise LdapPasswordError()
if "," in username:
raise LdapUsernameError("invalid character in username: ,")
try:
if hasattr(ldap, 'OPT_X_TLS_CACERTDIR'):
ldap.set_option(ldap.OPT_X_TLS_CACERTDIR,
'/etc/openldap/cacerts')
ldap.set_option(ldap.OPT_REFERRALS, ldap.OPT_OFF)
ldap.set_option(ldap.OPT_RESTART, ldap.OPT_ON)
ldap.set_option(ldap.OPT_TIMEOUT, 20)
ldap.set_option(ldap.OPT_NETWORK_TIMEOUT, 10)
ldap.set_option(ldap.OPT_TIMELIMIT, 15)
if self.TLS_KIND != 'PLAIN':
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, self.TLS_REQCERT)
server = ldap.initialize(self.LDAP_SERVER)
if self.ldap_version == 2:
server.protocol = ldap.VERSION2
else:
server.protocol = ldap.VERSION3
if self.TLS_KIND == 'START_TLS':
server.start_tls_s()
if self.LDAP_BIND_DN and self.LDAP_BIND_PASS:
log.debug('Trying simple_bind with password and given DN: %s'
% self.LDAP_BIND_DN)
server.simple_bind_s(self.LDAP_BIND_DN, self.LDAP_BIND_PASS)
filter_ = '(&%s(%s=%s))' % (self.LDAP_FILTER, self.attr_login,
username)
log.debug("Authenticating %r filter %s at %s", self.BASE_DN,
filter_, self.LDAP_SERVER)
lobjects = server.search_ext_s(self.BASE_DN, self.SEARCH_SCOPE,
filter_)
if not lobjects:
raise ldap.NO_SUCH_OBJECT()
for (dn, _attrs) in lobjects:
if dn is None:
continue
try:
log.debug('Trying simple bind with %s' % dn)
server.simple_bind_s(dn, safe_str(password))
attrs = server.search_ext_s(dn, ldap.SCOPE_BASE,
'(objectClass=*)')[0][1]
break
except ldap.INVALID_CREDENTIALS:
log.debug("LDAP rejected password for user '%s' (%s): %s"
% (uid, username, dn))
else:
log.debug("No matching LDAP objects for authentication "
"of '%s' (%s)", uid, username)
raise LdapPasswordError()
except ldap.NO_SUCH_OBJECT:
log.debug("LDAP says no such user '%s' (%s)" % (uid, username))
raise LdapUsernameError()
except ldap.SERVER_DOWN:
raise LdapConnectionError("LDAP can't access authentication server")
return dn, attrs
class KallitheaAuthPlugin(auth_modules.KallitheaExternalAuthPlugin):
def __init__(self):
self._logger = logging.getLogger(__name__)
self._tls_kind_values = ["PLAIN", "LDAPS", "START_TLS"]
self._tls_reqcert_values = ["NEVER", "ALLOW", "TRY", "DEMAND", "HARD"]
self._search_scopes = ["BASE", "ONELEVEL", "SUBTREE"]
@hybrid_property
def name(self):
return "ldap"
def settings(self):
settings = [
{
"name": "host",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "Host of the LDAP Server",
"formname": "LDAP Host"
},
{
"name": "port",
"validator": self.validators.Number(strip=True, not_empty=True),
"type": "string",
"description": "Port that the LDAP server is listening on",
"default": 389,
"formname": "Port"
},
{
"name": "dn_user",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "User to connect to LDAP",
"formname": "Account"
},
{
"name": "dn_pass",
"validator": self.validators.UnicodeString(strip=True),
"type": "password",
"description": "Password to connect to LDAP",
"formname": "Password"
},
{
"name": "tls_kind",
"validator": self.validators.OneOf(self._tls_kind_values),
"type": "select",
"values": self._tls_kind_values,
"description": "TLS Type",
"default": 'PLAIN',
"formname": "Connection Security"
},
{
"name": "tls_reqcert",
"validator": self.validators.OneOf(self._tls_reqcert_values),
"type": "select",
"values": self._tls_reqcert_values,
"description": "Require Cert over TLS?",
"formname": "Certificate Checks"
},
{
"name": "base_dn",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "Base DN to search (e.g., dc=mydomain,dc=com)",
"formname": "Base DN"
},
{
"name": "filter",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "Filter to narrow results (e.g., ou=Users, etc)",
"formname": "LDAP Search Filter"
},
{
"name": "search_scope",
"validator": self.validators.OneOf(self._search_scopes),
"type": "select",
"values": self._search_scopes,
"description": "How deep to search LDAP",
"formname": "LDAP Search Scope"
},
{
"name": "attr_login",
"validator": self.validators.AttrLoginValidator(not_empty=True, strip=True),
"type": "string",
"description": "LDAP Attribute to map to user name",
"formname": "Login Attribute"
},
{
"name": "attr_firstname",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "LDAP Attribute to map to first name",
"formname": "First Name Attribute"
},
{
"name": "attr_lastname",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "LDAP Attribute to map to last name",
"formname": "Last Name Attribute"
},
{
"name": "attr_email",
"validator": self.validators.UnicodeString(strip=True),
"type": "string",
"description": "LDAP Attribute to map to email address",
"formname": "Email Attribute"
}
]
return settings
def use_fake_password(self):
return True
def user_activation_state(self):
def_user_perms = User.get_default_user().AuthUser.permissions['global']
return 'hg.extern_activate.auto' in def_user_perms
def auth(self, userobj, username, password, settings, **kwargs):
"""
Given a user object (which may be null), username, a plaintext password,
and a settings object (containing all the keys needed as listed in settings()),
authenticate this user's login attempt.
Return None on failure. On success, return a dictionary of the form:
see: KallitheaAuthPluginBase.auth_func_attrs
This is later validated for correctness
"""
if not username or not password:
log.debug('Empty username or password skipping...')
return None
kwargs = {
'server': settings.get('host', ''),
'base_dn': settings.get('base_dn', ''),
'port': settings.get('port'),
'bind_dn': settings.get('dn_user'),
'bind_pass': settings.get('dn_pass'),
'tls_kind': settings.get('tls_kind'),
'tls_reqcert': settings.get('tls_reqcert'),
'ldap_filter': settings.get('filter'),
'search_scope': settings.get('search_scope'),
'attr_login': settings.get('attr_login'),
'ldap_version': 3,
}
if kwargs['bind_dn'] and not kwargs['bind_pass']:
log.debug('Using dynamic binding.')
kwargs['bind_dn'] = kwargs['bind_dn'].replace('$login', username)
kwargs['bind_pass'] = password
log.debug('Checking for ldap authentication')
try:
aldap = AuthLdap(**kwargs)
(user_dn, ldap_attrs) = aldap.authenticate_ldap(username, password)
log.debug('Got ldap DN response %s' % user_dn)
get_ldap_attr = lambda k: ldap_attrs.get(settings.get(k), [''])[0]
# old attrs fetched from Kallithea database
admin = getattr(userobj, 'admin', False)
active = getattr(userobj, 'active', self.user_activation_state())
email = getattr(userobj, 'email', '')
firstname = getattr(userobj, 'firstname', '')
lastname = getattr(userobj, 'lastname', '')
extern_type = getattr(userobj, 'extern_type', '')
user_attrs = {
'username': username,
'firstname': safe_unicode(get_ldap_attr('attr_firstname') or firstname),
'lastname': safe_unicode(get_ldap_attr('attr_lastname') or lastname),
'groups': [],
'email': get_ldap_attr('attr_email' or email),
'admin': admin,
'active': active,
"active_from_extern": None,
'extern_name': user_dn,
'extern_type': extern_type,
}
log.info('user %s authenticated correctly' % user_attrs['username'])
return user_attrs
except (LdapUsernameError, LdapPasswordError, LdapImportError):
log.error(traceback.format_exc())
return None
except (Exception,):
log.error(traceback.format_exc())
return None
| msabramo/kallithea | kallithea/lib/auth_modules/auth_ldap.py | Python | gpl-3.0 | 14,266 |
"""Module for representation of wing section's structure
This module defines classes which allow definition of a wing section as chain of multiple structure elements.
Definition of a structure starts with SectionBase, which stores airfoil coordinates. Beginning with this exterior
geometry structure elements can be added from out to inside. Possible Elements are Layers, covering the whole
surface, Reinforcements for higher stiffness locally and Spar elements (ISpar and BoxSpar).
Example
-------
.. code-block:: python
import numpy as np
from wingstructure import structure
# Load cooardinates
coords = np.loadtxt('ah93157.dat', skiprows=1) * 1.2
sectionbase = structure.SectionBase(coords)
# Define Material
import collections
Material = collections.namedtuple('Material', ['ρ'])
carbonfabric = Material(1.225)
foam = Material(1.225)
sandwich = Material(1.225)
# create layers
outerlayer = structure.Layer(carbonfabric, 5e-4)
core = structure.Layer(foam, 1e-2)
innerlayer = structure.Layer(carbonfabric, 5e-4)
# create Spar
spar = structure.ISpar(material={'flange': carbonfabric, 'web': sandwich},
midpos=0.45,
flangewidth=0.2,
flangethickness=0.03,
webpos=0.5,
webthickness=0.02)
# add to sectionbase
sectionbase.extend([outerlayer, core, innerlayer, spar])
# Analyse Mass
massana = structure.MassAnalysis(sectionbase)
cg, mass = massana.massproperties()
"""
from abc import ABC, abstractmethod
from functools import wraps
import numpy as np
from collections import namedtuple
from numpy.linalg import norm
from shapely import geometry as shpl_geom
from shapely import ops
from shapely.algorithms import cga
from .section_helper import _get_inside_direction, _create_offset_box, _updatedecorator, _refine_interior
class SectionBase:
"""Foundation for section's wing structure description
Implements a list like interface for the assembling of wing section's interior.
Parameters
----------
airfoil_coordinates : np.ndarray
airfoils coordinates from dat file
Attributes
----------
interior: shapely.geometry.LinearRing
representation of airfoil as shapely geometry
"""
def __init__(self, airfoil_coordinates):
self._geometry = shpl_geom.LinearRing(airfoil_coordinates)
self._features = []
self._featuregeometries = []
@_updatedecorator
def append(self, featuredef):
self._features.append(featuredef)
@_updatedecorator
def insert(self, index, newfeature):
self._features.insert(index, newfeature)
@_updatedecorator
def extend(self, featuredefs):
for featuredef in featuredefs:
self.append(featuredef)
@_updatedecorator
def remove(self, featuredef):
if featuredef not in self._features:
raise Exception('No feature {} found.'.format(featuredef))
self._features.remove(featuredef)
@_updatedecorator
def pop(self):
self._features.pop()
def _update_callback(self, updated_feature):
try:
first_idx = self._features.index(updated_feature) #TODO: Error handling
except ValueError:
raise ValueError('Feature {} not in {}s features.'.format(updated_feature, self))
self._update()
def _update(self):
# reset geometries
self._featuregeometries = []
self.tmp = []
exterior = self._geometry
for feature in self._features:
tmp, tmp_geometry = feature._calculate_geometry(exterior)
self.tmp.append(tmp)
exterior=tmp
self._featuregeometries.append(tmp_geometry)
def _repr_svg_(self):
shply_collection = shpl_geom.GeometryCollection([self._geometry, *self._featuregeometries])
svg = shply_collection._repr_svg_()
return rework_svg(svg, 1000, 250)
def exportgeometry(self, refpoint=np.zeros(2)):
geoms = []
for feature, geometry in zip(self._features, self._featuregeometries):
geoms.extend(exportstructure(geometry, feature.material, refpoint))
return geoms
def __getitem__(self, idx):
return self._features[idx] # TODO rework
class Layer:
"""Layer of constant thickness representation
Parameters
----------
material :
Material definition
thickness : float
The Layers geometric thickness
Attributes
----------
interior :
shapely geometry representation of interior
"""
def __init__(self, material, thickness=0.0):
self.material = material
self.thickness = thickness
def _calculate_geometry(self, exterior):
inside_direction = _get_inside_direction(exterior)
interior = exterior.parallel_offset(self.thickness, side=inside_direction)
if interior.type == 'MultiLineString':
interior = shpl_geom.LinearRing(interior.geoms[0])
else:
interior = shpl_geom.LinearRing(interior)
geometry = shpl_geom.Polygon(exterior)-shpl_geom.Polygon(interior)
return interior, geometry
def _centerline(self):
inside_direction = _get_inside_direction(self.exterior)
centerline = self.exterior.parallel_offset(self._thickness/2.0,
side=inside_direction)
return centerline
def middle_circumference(self):
"""Calculate circumference of centerline
Returns
-------
float
circumference value
"""
return self._centerline().length
def enclosed_area(self):
"""Calculate area enclosed by centerline
Returns
-------
float
ecnlosed area
"""
cline = self._centerline()
return shpl_geom.Polygon(cline).area
class CompositeLayer(Layer):
pass #TODO: implement
class Reinforcement(Layer):
"""Local reinforcement structure
Parameters
----------
material :
Material Defintion
thickness :
reinforcement thickness
limits :
bounds for reinforcement in chordwise direction
Attributes
----------
interior :
shapely geometry representation of interior
"""
def __init__(self, material, thickness=0.0, limits=None):
super().__init__(material, thickness)
self._limits = np.array(limits)
def _calculate_geometry(self, exterior):
limited_box = shpl_geom.box(self._limits[0], exterior.bounds[1]*1.1,
self._limits[1], exterior.bounds[3]*1.1)
intersection = limited_box.intersection(exterior)
side = _get_inside_direction(exterior)
tmp_geometries = []
tmp_interior = shpl_geom.Polygon(exterior)
for ageo in intersection.geoms:
tmp_geometry = _create_offset_box(ageo, self.thickness, side,
symmetric=False)
tmp_interior -= tmp_geometry
tmp_geometries.append(tmp_geometry)
geometry = shpl_geom.GeometryCollection(tmp_geometries)
interior = shpl_geom.LinearRing(tmp_interior.exterior)
return _refine_interior(interior), geometry
def exportgeometry(self, refpoint=np.zeros(2)):
return [geom2array(geo, refpoint)._replace(material=self.material) for geo in self.geometry.geoms]
class MassAnalysis:
"""Analyse Mass of Structure
Parameters
----------
sectionbase
section definiton to be analyzed
"""
def __init__(self, sectionbase):
self.secbase = sectionbase
@property
def massproperties(self):
mass = 0.0
cg = np.zeros(2)
for feature in self.secbase._features:
cur_cg, cur_mass = feature.massproperties
mass += cur_mass
cg += cur_mass * np.array(cur_cg)
return cg/mass, mass
def _oderside(side):
if side == 'left':
return 'right'
else:
return 'left'
def rework_svg(svg:str, width:float, height:float=100.0, stroke_width:float=None)->str:
"""Prettify svgs generated by shapely
Parameters
----------
svg : str
svg definitiom
width : float
with of returned svg
height : int, optional
height of returned svg (the default is 100)
stroke_width : float, optional
width of lines in svg (the default is None, which [default_description])
Raises
------
Exception
raised when input svg string is invalid
Returns
-------
str
prettified svg string
"""
import re
if stroke_width is None:
search_res = re.search(r'viewBox="((?:-?\d+.\d+\s*){4})"', svg)
if search_res is None:
raise Exception('Invalid SVG!')
bounds = [float(val) for val in search_res.groups()[0].split()]
Δy = bounds[3]-bounds[1]
Δx = bounds[2]-bounds[0]
stroke_width = min(Δx,Δy)/100
svg = re.sub(r'width="\d+\.\d+"',
'width="{:.1f}"'.format(width),
svg,
count=1)
svg = re.sub(r'height="\d+\.\d+"',
'heigth="{:.1f}"'.format(height),
svg,
count=1)
svg = re.sub(r'stroke-width="\d+\.\d+"',
'stroke-width="{:f}"'.format(stroke_width),
svg)
return svg
Structure = namedtuple('Structure', ['exterior','interiors','material'])
def exportstructure(geometry, material, refpoint=np.zeros(2)):
"""Helper function to export polygon geometry from shapely to numpy arrays based format
Parameters
----------
geometry : shapely.Polygon
Geometrie to be exported (must be a Polygon)
refpoint : np.array, optional
reference point (2D), will be substracted from coordinates
(the default is np.zeros(2)
Raises
------
ValueError
Wrong geometry type given..
Returns
-------
ArrayStruc
Custom geometry and material container
"""
def coordsclockwise(linearring):
if cga.signed_area(linearring) < 0.0:
return np.array(linearring.coords)
else:
return np.array(linearring.coords)[::-1]
if geometry.type in ('GeometryCollection', 'MultiPolygon'):
res = []
for geo in geometry.geoms:
res.extend(exportstructure(geo, material, refpoint))
return res
elif geometry.type != 'Polygon':
raise ValueError('Geometry must be of type \'Polygon\' or \'GeometryCollection\', not {}'.format(geometry.type))
exterior = coordsclockwise(geometry.exterior) - refpoint.flat
interiors = [coordsclockwise(interior) - refpoint.flat for interior in geometry.interiors]
return [Structure(exterior, interiors, material)]
| helo9/wingstructure | wingstructure/structure/section.py | Python | mit | 11,241 |
# Copyright (c) 2014-2016, Clemson University
# 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 Clemson University 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 HOLDER 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.
from django.db import models
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db.models.signals import pre_save
from django.dispatch import receiver
try:
from django.utils.timezone import now
except ImportError:
import datetime
now = datetime.datetime.now
from django_sshkey.util import PublicKeyParseError, pubkey_parse
from django_sshkey import settings
class UserKey(models.Model):
user = models.ForeignKey(User, db_index=True)
name = models.CharField(max_length=50, blank=True)
key = models.TextField(max_length=2000)
fingerprint = models.CharField(max_length=128, blank=True, db_index=True)
created = models.DateTimeField(auto_now_add=True, null=True)
last_modified = models.DateTimeField(null=True)
last_used = models.DateTimeField(null=True)
class Meta:
db_table = 'sshkey_userkey'
unique_together = [
('user', 'name'),
]
def __unicode__(self):
return unicode(self.user) + u': ' + self.name
def clean_fields(self, exclude=None):
if not exclude or 'key' not in exclude:
self.key = self.key.strip()
if not self.key:
raise ValidationError({'key': ["This field is required."]})
def clean(self):
self.key = self.key.strip()
if not self.key:
return
try:
pubkey = pubkey_parse(self.key)
except PublicKeyParseError as e:
raise ValidationError(str(e))
self.key = pubkey.format_openssh()
self.fingerprint = pubkey.fingerprint()
if not self.name:
if not pubkey.comment:
raise ValidationError('Name or key comment required')
self.name = pubkey.comment
def validate_unique(self, exclude=None):
if self.pk is None:
objects = type(self).objects
else:
objects = type(self).objects.exclude(pk=self.pk)
if exclude is None or 'name' not in exclude:
if objects.filter(user=self.user, name=self.name).count():
message = 'You already have a key with that name'
raise ValidationError({'name': [message]})
if exclude is None or 'key' not in exclude:
try:
other = objects.get(fingerprint=self.fingerprint, key=self.key)
if self.user == other.user:
message = 'You already have that key on file (%s)' % other.name
else:
message = 'Somebody else already has that key on file'
raise ValidationError({'key': [message]})
except type(self).DoesNotExist:
pass
def export(self, format='RFC4716'):
pubkey = pubkey_parse(self.key)
f = format.upper()
if f == 'RFC4716':
return pubkey.format_rfc4716()
if f == 'PEM':
return pubkey.format_pem()
raise ValueError("Invalid format")
def save(self, *args, **kwargs):
if kwargs.pop('update_last_modified', True):
self.last_modified = now()
super(UserKey, self).save(*args, **kwargs)
def touch(self):
self.last_used = now()
self.save(update_last_modified=False)
@receiver(pre_save, sender=UserKey)
def send_email_add_key(sender, instance, **kwargs):
if not settings.SSHKEY_EMAIL_ADD_KEY or instance.pk:
return
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
from django.core.urlresolvers import reverse
context_dict = {
'key': instance,
'subject': settings.SSHKEY_EMAIL_ADD_KEY_SUBJECT,
}
request = getattr(instance, 'request', None)
if request:
context_dict['request'] = request
context_dict['userkey_list_uri'] = request.build_absolute_uri(
reverse('django_sshkey.views.userkey_list'))
text_content = render_to_string('sshkey/add_key.txt', context_dict)
msg = EmailMultiAlternatives(
settings.SSHKEY_EMAIL_ADD_KEY_SUBJECT,
text_content,
settings.SSHKEY_FROM_EMAIL,
[instance.user.email],
)
if settings.SSHKEY_SEND_HTML_EMAIL:
html_content = render_to_string('sshkey/add_key.html', context_dict)
msg.attach_alternative(html_content, 'text/html')
msg.send()
| ClemsonSoCUnix/django-sshkey | django_sshkey/models.py | Python | bsd-3-clause | 5,547 |
import sys
sys.path.insert(1, "../../../")
import h2o
def offset_gamma(ip,port):
# Connect to a pre-existing cluster
h2o.init(ip,port)
insurance = h2o.import_frame(h2o.locate("smalldata/glm_test/insurance.csv"))
insurance["offset"] = insurance["Holders"].log()
gbm = h2o.gbm(x=insurance[0:3], y=insurance["Claims"], distribution="gamma", ntrees=600, max_depth=1, min_rows=1,
learn_rate=.1, offset_column="offset", training_frame=insurance)
predictions = gbm.predict(insurance)
# Comparison result generated from harrysouthworth's gbm:
# fit2 = gbm(Claims ~ District + Group + Age+ offset(log(Holders)) , interaction.depth = 1,n.minobsinnode = 1,shrinkage = .1,bag.fraction = 1,train.fraction = 1,
# data = Insurance, distribution ="gamma", n.trees = 600)
# pr = predict(fit2, Insurance)
# pr = exp(pr+log(Insurance$Holders))
assert abs(-1.714958 - gbm._model_json['output']['init_f']) < 1e-5, "expected init_f to be {0}, but got {1}". \
format(-1.714958, gbm._model_json['output']['init_f'])
assert abs(50.10707 - predictions.mean()) < 1e-3, "expected prediction mean to be {0}, but got {1}". \
format(50.10707, predictions.mean())
assert abs(0.9133843 - predictions.min()) < 1e-4, "expected prediction min to be {0}, but got {1}". \
format(0.9133843, predictions.min())
assert abs(392.6667 - predictions.max()) < 1e-2, "expected prediction max to be {0}, but got {1}". \
format(392.6667, predictions.max())
if __name__ == "__main__":
h2o.run_test(sys.argv, offset_gamma)
| ChristosChristofidis/h2o-3 | h2o-py/tests/testdir_algos/gbm/pyunit_offset_gammaGBM.py | Python | apache-2.0 | 1,603 |
from eve import Eve
from eve.auth import TokenAuth
import jwt
import os
from flask import Flask, request, redirect, url_for
from werkzeug.utils import secure_filename
from cross import crossdomain
import uuid
app = Eve()
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
UPLOAD_FOLDER = 'C:/Bitnami/wampstack-5.6.27-0/apache2/htdocs/'
class RolesAuth(TokenAuth):
def check_auth(self, token, allowed_roles, resource, method):
users = app.data.driver.db['auth']
lookup = {'token': token}
user = users.find_one(lookup)
if user :
if user['role'] in allowed_roles:
return user
return False
def add_token(documents):
for document in documents:
payload = {'login': document['login']}
document["token"] = jwt.encode(payload, 'jemix')
def allowed_file(filename):
return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
def name_file(filename,src):
return 'app/img/' + src +'/' + str(uuid.uuid1()) + '.' + filename.rsplit('.', 1)[1]
@app.route('/images/user', methods=['POST'])
@crossdomain(origin='*')
def upload_img_user():
file = request.files['img']
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
n = name_file(filename,'user')
file.save(os.path.join(UPLOAD_FOLDER,n))
return n
@app.route('/images/doc', methods=['POST'])
@crossdomain(origin='*')
def upload_img_doc():
file = request.files['img']
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
n = name_file(filename,'doc')
file.save(os.path.join(UPLOAD_FOLDER,n))
return n
@app.route('/images/cert', methods=['POST'])
@crossdomain(origin='*')
def upload_img_cert():
file = request.files['img']
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
n = name_file(filename,'cert')
file.save(os.path.join(UPLOAD_FOLDER,n))
return n
@app.route('/images/edu', methods=['POST'])
@crossdomain(origin='*')
def upload_img_edu():
file = request.files['img']
if file and allowed_file(file.filename):
filename = secure_filename(file.filename)
n = name_file(filename,'edu')
file.save(os.path.join(UPLOAD_FOLDER,n))
return n
if __name__ == '__main__':
# app = Eve(auth=RolesAuth)
app.on_insert_auth += add_token
app.run(host='0.0.0.0',debug=True)
# app.run(debug=True)
| jemiaymen/pm | restful/run.py | Python | mit | 2,598 |
## The brain of WhiteDragon
# chenmz 2017.9.1
from modules import stateMachine as sm
from modules import ioControl as io
import math
import json
import time
# Import the configure infomation
conf = json.load(open('conf.json'))
# Move forward for 0.01 meter
# state: (position_x(unit: m), position_y(unit: m), angle_theta(unit: pi))
class ForwardSM(sm.SM):
def __init__(self, s):
self.startState = s
def getNextValues(self, state, inp):
print inp
(last_x, last_y, last_theta) = state
new_x = last_x + math.cos(last_theta)
new_y = last_y + math.sin(last_theta)
new_state = (new_x, new_y, last_theta)
print new_state
return (new_state, white.controller.action(0, 0.01)) # angle:0 distance:1
# Rotate left for
class RotateSM(sm.SM):
length = conf['Robot_length']
width = conf['Robot_width']
def __init__(self, s, direction):
self.startState = s
# self.direct =
# def getNextValues(self, state, inp):
# (last_x, last_y, last_theta) = state
# (inp )
# new_x =
# new_theta =
# Stop
class StopSM(sm.SM):
startState = (0, 0, 0)
def getNextValues(self, state, inp):
return (state, white.controller.stop())
# Destination finder
class DestFinder(sm.SM):
def __init__(self, currPosition, destPosition):
self.startState = currPosition
self.endState = destPosition
def getNextValues(self, state, inp):
pass
# Wall finder
# SenserInput:(distance(unit: cm), barrierLeft(value:0, 1), barrierLeft(value:0, 1))
class WallFinder(sm.SM):
startState = 0
def __init__(self, dDesired):
self.desireDistance = dDesired
def getNextValues(self, state, inp):
#print state, inp
current_distance = inp[0]
k = current_distance - self.desireDistance
print k
# time.sleep(0.1)
return (state+1, white.controller.Action([1,1], k))
#if dM < 0.01:
# return (state, white.controller.action(0, 0))
#elif dM < 1:
# return (state + dM/100, white.controller.action(0, dM/100))
#else:
# return (state + dM/10, white.controller.action(0, dM/10))
# WhiteBrain
class Brain(object):
def __init__(self):
self.behavior = StopSM()
self.controller = io.Controller()
self.senser = io.Senser()
def setup(self):
self.senser.setup()
self.controller.setup()
self.behavior.start() # Start the state machine
def step(self):
self.behavior.step(self.senser.sensorInput())
def run(self):
i = 0
while(1):
i = i + 1
self.step()
def stop(self):
self.controller.Stop()
# Create instance of WhiteDragon
white = Brain()
white.behavior = WallFinder(50)
white.setup()
#white.step()
#white.run()
| treegod13/whiteDragon | whiteBrain.py | Python | gpl-3.0 | 2,884 |
import re
import urllib.parse as urlparse
from django.conf import settings
REPLACE_STR = '$encrypted$'
class UriCleaner(object):
REPLACE_STR = REPLACE_STR
SENSITIVE_URI_PATTERN = re.compile(r'(\w{1,20}:(\/?\/?)[^\s]+)', re.MULTILINE) # NOQA
@staticmethod
def remove_sensitive(cleartext):
# exclude_list contains the items that will _not_ be redacted
exclude_list = [settings.PUBLIC_GALAXY_SERVER['url']]
if settings.PRIMARY_GALAXY_URL:
exclude_list += [settings.PRIMARY_GALAXY_URL]
if settings.FALLBACK_GALAXY_SERVERS:
exclude_list += [server['url'] for server in settings.FALLBACK_GALAXY_SERVERS]
redactedtext = cleartext
text_index = 0
while True:
match = UriCleaner.SENSITIVE_URI_PATTERN.search(redactedtext, text_index)
if not match:
break
uri_str = match.group(1)
# Do not redact items from the exclude list
if any(uri_str.startswith(exclude_uri) for exclude_uri in exclude_list):
text_index = match.start() + len(uri_str)
continue
try:
# May raise a ValueError if invalid URI for one reason or another
o = urlparse.urlsplit(uri_str)
if not o.username and not o.password:
if o.netloc and ":" in o.netloc:
# Handle the special case url http://username:password that can appear in SCM url
# on account of a bug? in ansible redaction
(username, password) = o.netloc.split(':')
else:
text_index += len(match.group(1))
continue
else:
username = o.username
password = o.password
# Given a python MatchObject, with respect to redactedtext, find and
# replace the first occurance of username and the first and second
# occurance of password
uri_str = redactedtext[match.start():match.end()]
if username:
uri_str = uri_str.replace(username, UriCleaner.REPLACE_STR, 1)
# 2, just in case the password is $encrypted$
if password:
uri_str = uri_str.replace(password, UriCleaner.REPLACE_STR, 2)
t = redactedtext[:match.start()] + uri_str
text_index = len(t)
if (match.end() < len(redactedtext)):
t += redactedtext[match.end():]
redactedtext = t
if text_index >= len(redactedtext):
text_index = len(redactedtext) - 1
except ValueError:
# Invalid URI, redact the whole URI to be safe
redactedtext = redactedtext[:match.start()] + UriCleaner.REPLACE_STR + redactedtext[match.end():]
text_index = match.start() + len(UriCleaner.REPLACE_STR)
return redactedtext
class PlainTextCleaner(object):
REPLACE_STR = REPLACE_STR
@staticmethod
def remove_sensitive(cleartext, sensitive):
if sensitive == '':
return cleartext
return re.sub(r'%s' % re.escape(sensitive), '$encrypted$', cleartext)
| GoogleCloudPlatform/sap-deployment-automation | third_party/github.com/ansible/awx/awx/main/redact.py | Python | apache-2.0 | 3,346 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright 2017 AVSystem <avsystem@avsystem.com>
#
# 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 sys
assert sys.version_info >= (3, 5), "Python < 3.5 is unsupported"
import unittest
import os
import re
import collections
import argparse
import time
import tempfile
import shutil
from framework.pretty_test_runner import PrettyTestRunner, get_test_name, get_suite_name, get_full_test_name
from framework.pretty_test_runner import COLOR_DEFAULT, COLOR_YELLOW, COLOR_GREEN, COLOR_RED
from framework.test_suite import Lwm2mTest, ensure_dir
if sys.version_info[0] >= 3:
sys.stderr = os.fdopen(2, 'w', 1) # force line buffering
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
UNITTEST_PATH = os.path.join(ROOT_DIR, 'suites')
DEFAULT_SUITE_REGEX = r'^default/'
def traverse(tree, cls=None):
if cls is None or isinstance(tree, cls):
yield tree
if isinstance(tree, collections.Iterable):
for elem in tree:
for sub_elem in traverse(elem, cls):
yield sub_elem
def discover_test_suites(test_config):
loader = unittest.TestLoader()
loader.testMethodPrefix = 'runTest'
suite = loader.discover(UNITTEST_PATH, pattern='*.py', top_level_dir=UNITTEST_PATH)
for error in loader.errors:
print(error)
if len(loader.errors):
sys.exit(-1)
for test in traverse(suite, cls=Lwm2mTest):
test.set_config(test_config)
return suite
def list_tests(suite, header='Available tests:'):
print(header)
for test in traverse(suite, cls=Lwm2mTest):
print('* %s: %s' % (test.suite_name(), test.test_name()))
print('')
def run_tests(suites, config):
has_error = False
test_runner = PrettyTestRunner(config)
start_time = time.time()
for suite in suites:
if suite.countTestCases() == 0:
continue
log_dir = os.path.join(config.logs_path, 'test')
ensure_dir(log_dir)
log_filename = os.path.join(log_dir, '%s.log' % (get_suite_name(suite),))
with open(log_filename, 'w') as logfile:
res = test_runner.run(suite, logfile)
if not res.wasSuccessful():
has_error = True
seconds_elapsed = time.time() - start_time
all_tests = sum(r.testsRun for r in test_runner.results)
successes = sum(r.testsPassed for r in test_runner.results)
errors = sum(r.testsErrors for r in test_runner.results)
failures = sum(r.testsFailed for r in test_runner.results)
print('\nFinished in %f s; %s%d/%d successes%s, %s%d/%d errors%s, %s%d/%d failures%s\n'
% (seconds_elapsed,
COLOR_GREEN if successes == all_tests else COLOR_YELLOW, successes, all_tests, COLOR_DEFAULT,
COLOR_RED if errors else COLOR_GREEN, errors, all_tests, COLOR_DEFAULT,
COLOR_RED if failures else COLOR_GREEN, failures, all_tests, COLOR_DEFAULT))
if has_error:
for r in test_runner.results:
print(r.errorSummary(log_root=config.target_logs_path))
raise SystemError("Some tests failed, inspect log for details")
def filter_tests(suite, query_regex):
matching_tests = []
for test in suite:
if isinstance(test, unittest.TestCase):
name = get_test_name(test)
if (re.search(query_regex, get_test_name(test))
or re.search(query_regex, get_full_test_name(test))):
matching_tests.append(test)
elif isinstance(test, unittest.TestSuite):
if test.countTestCases() == 0:
continue
if re.search(query_regex, get_suite_name(test)):
matching_tests.append(test)
else:
matching_suite = filter_tests(test, query_regex)
if matching_suite.countTestCases() > 0:
matching_tests.append(matching_suite)
return unittest.TestSuite(matching_tests)
def merge_directory(src, dst):
for item in os.listdir(src):
src_item = os.path.join(src, item)
dst_item = os.path.join(dst, item)
if os.path.isdir(src_item):
merge_directory(src_item, dst_item)
else:
ensure_dir(os.path.dirname(dst_item))
shutil.copy2(src_item, dst_item)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--list', '-l',
action='store_true',
help='only list matching test cases, do not execute them')
parser.add_argument('--client', '-c',
type=str, required=True,
help='path to the demo application to use')
parser.add_argument('query_regex',
type=str, default=DEFAULT_SUITE_REGEX, nargs='?',
help='regex used to filter test cases, run against suite name, test case name and "suite: test" string')
cmdline_args = parser.parse_args(sys.argv[1:])
with tempfile.TemporaryDirectory() as tmp_log_dir:
class TestConfig:
demo_cmd = os.path.basename(cmdline_args.client)
demo_path = os.path.abspath(os.path.dirname(cmdline_args.client))
logs_path = tmp_log_dir
suite_root_path = os.path.abspath(UNITTEST_PATH)
target_logs_path = os.path.abspath(os.path.join(demo_path, '../test/integration/log'))
def config_to_string(cfg):
config = sorted((k, v) for k, v in cfg.__dict__.items()
if not k.startswith('_')) # skip builtins
max_key_len = max(len(k) for k, _ in config)
return '\n '.join(['Test config:'] + ['%%-%ds = %%s' % max_key_len % kv for kv in config])
test_suites = discover_test_suites(TestConfig)
header = '%d tests:' % test_suites.countTestCases()
if cmdline_args.query_regex:
test_suites = filter_tests(test_suites, cmdline_args.query_regex)
header = '%d tests match pattern %s:' % (test_suites.countTestCases(), cmdline_args.query_regex)
list_tests(test_suites, header=header)
result = None
if not cmdline_args.list:
sys.stderr.write('%s\n\n' % config_to_string(TestConfig))
try:
run_tests(test_suites, TestConfig)
finally:
# calculate logs path based on executable path to prevent it
# from creating files in source directory if building out of source
ensure_dir(os.path.dirname(TestConfig.target_logs_path))
merge_directory(TestConfig.logs_path, TestConfig.target_logs_path)
| dextero/Anjay | test/integration/runtest.py | Python | apache-2.0 | 7,173 |
def str_length(line):
return len(line)
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert str_length("") == 0, "1st example";
assert str_length("mo") == 2, "2st example";
assert str_length("length") == 6, "3st example";
print("Code's finished? Earn rewards by clicking 'Check' to review your tests!") | edwardzhu/checkio-solution | EmpireOfCode/common/Adamantite Mines/strlen.py | Python | mit | 391 |
from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
from schools.sitemaps import school_sitemaps
from places.models import Province, County, District, Division, Location, SubLocation
from places.models import Constituency, SchoolZone
province_dict = {
'queryset': Province.objects.all(),
'date_field': 'updated_on',
}
county_dict = {
'queryset': County.objects.all(),
'date_field': 'updated_on',
}
district_dict = {
'queryset': District.objects.all(),
'date_field': 'updated_on',
}
division_dict = {
'queryset': Division.objects.all(),
'date_field': 'updated_on',
}
location_dict = {
'queryset': Location.objects.all(),
'date_field': 'updated_on',
}
sub_location_dict = {
'queryset': SubLocation.objects.all(),
'date_field': 'updated_on',
}
school_zone_dict = {
'queryset': SchoolZone.objects.all(),
'date_field': 'updated_on',
}
constituency_dict = {
'queryset': Constituency.objects.all(),
'date_field': 'updated_on',
}
sitemaps = {
'flatpages': FlatPageSitemap,
# 'schools': SchoolSitemap,
'province': GenericSitemap(province_dict, priority=0.6, changefreq='monthly'),
'county': GenericSitemap(county_dict, priority=0.6, changefreq='monthly'),
'district': GenericSitemap(district_dict, priority=0.6, changefreq='monthly'),
'division': GenericSitemap(division_dict, priority=0.6, changefreq='monthly'),
'location': GenericSitemap(location_dict, priority=0.6, changefreq='monthly'),
'sub_location': GenericSitemap(sub_location_dict, priority=0.6, changefreq='monthly'),
'school_zone': GenericSitemap(school_zone_dict, priority=0.6, changefreq='monthly'),
'constituency': GenericSitemap(constituency_dict, priority=0.6, changefreq='monthly'),
}
sitemaps = sitemaps.copy()
sitemaps.update(school_sitemaps())
| moshthepitt/shulezote | core/sitemaps.py | Python | mit | 1,839 |
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
#from django.contrib import admin
#admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'base.views.index', name='index'),
url(r'^event/$', 'base.views.event'),
url(r'^event/(?P<event_id>\d+)/$', 'base.views.event'),
url(r'^event/(?P<event_id>\d+)/details/$', 'base.views.event_details'),
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()
| gmjosack/auditor | auditor/urls.py | Python | mit | 597 |
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import pandas as pd
import io
u = u"""latitude,longitude
42.357778,-71.059444
39.952222,-75.163889
25.787778,-80.224167
30.267222, -97.763889"""
# read in data to use for plotted points
# buildingdf = pd.read_csv(io.StringIO(u), delimiter=",")
buildingdf = pd.read_csv("../input/key_haifa-herzliya.csv", delimiter=" ")
# buildingdf = pd.read_csv("../input/key_bus_line_24.csv", delimiter=" ")
lat = buildingdf['latitude'].values
lon = buildingdf['longitude'].values
# determine range to print based on min, max lat and lon of the data
margin = 0.1 # buffer to add to the range
lat_min = min(lat) - margin
lat_max = max(lat) + margin
lon_min = min(lon) - margin
lon_max = max(lon) + margin
# create map using BASEMAP
m = Basemap(llcrnrlon=lon_min,
llcrnrlat=lat_min,
urcrnrlon=lon_max,
urcrnrlat=lat_max,
lat_0=(lat_max - lat_min)/2,
lon_0=(lon_max-lon_min)/2,
# projection='merc',
projection='lcc',
resolution = 'h',
area_thresh=10.,
)
# m.drawcoastlines()
# m.drawcountries()
# m.drawstates()
# m.drawmapboundary(fill_color='#46bcec')
# m.fillcontinents(color = 'white',lake_color='#46bcec')
# m.shadedrelief()
m.etopo()
# convert lat and lon to map projection coordinates
lons, lats = m(lon, lat)
# plot points as red dots
m.scatter(lons, lats, marker = 'o', color='r', zorder=5)
plt.show()
| rbdedu/runway | examples/basemap4.py | Python | mit | 1,490 |
"""
Things commonly needed in Enterprise tests.
"""
from django.conf import settings
FEATURES_WITH_ENTERPRISE_ENABLED = settings.FEATURES.copy()
FEATURES_WITH_ENTERPRISE_ENABLED['ENABLE_ENTERPRISE_INTEGRATION'] = True
FAKE_ENTERPRISE_CUSTOMER = {
'active': True,
'branding_configuration': None,
'catalog': None,
'enable_audit_enrollment': False,
'enable_data_sharing_consent': False,
'enforce_data_sharing_consent': 'at_enrollment',
'enterprise_customer_entitlements': [],
'identity_provider': None,
'name': 'EnterpriseCustomer',
'replace_sensitive_sso_username': True,
'site': {'domain': 'example.com', 'name': 'example.com'},
'uuid': '1cbf230f-f514-4a05-845e-d57b8e29851c'
}
| ahmedaljazzar/edx-platform | openedx/features/enterprise_support/tests/__init__.py | Python | agpl-3.0 | 728 |
#!/usr/bin/python
import sys
import os
VERSION = "0.1"
def run():
sys.argv.insert(1, "serve")
if len(sys.argv) <= 2:
# set default file
config_file_path = os.path.join(os.getcwd(), "config.py")
sys.argv.append(config_file_path)
from pecan.commands import CommandRunner
CommandRunner.handle_command_line()
| jlpk/joulupukki-dispatcher | joulupukki/dispatcher/__init__.py | Python | agpl-3.0 | 348 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
from qframer.qt import QtGui
from qframer.qt import QtCore
from logindialog import login
from exitdialog import exit
from msgdialog import MessageDialog
from msgdialog import msg
from ipaddressdialog import ipaddressinput
from urlinputdialog import urlinput
from numinputdialog import numinput
from confirmdialog import confirm
from confirmdialog import ConfirmDialog
from basedialog import DynamicTextWidget
__version__ = '0.1.0'
__all__ = ['DynamicTextWidget', 'ConfirmDialog', 'MessageDialog','login', 'exit', 'msg', 'ipaddressinput', 'urlinput', 'numinput', 'confirm']
__author__ = 'dragondjf(dragondjf@gmail.com)'
| dragondjf/QMarkdowner | utildialog/__init__.py | Python | mit | 666 |
#!/usr/bin/env python
#
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#########################################################################
# Copyright 2011-2013 Marcus Popp marcus@popp.mx
#########################################################################
# This file is part of SmartHome.py. http://smarthome.sourceforge.net/
#
# SmartHome.py is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SmartHome.py is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SmartHome.py. If not, see <http://www.gnu.org/licenses/>.
##########################################################################
import logging
import datetime
logger = logging.getLogger('')
try:
import ephem
except ImportError, e:
ephem = None # noqa
import dateutil.relativedelta
from dateutil.tz import tzutc
class Orb():
def __init__(self, orb, lon, lat, elev=False):
if ephem is None:
return
self._obs = ephem.Observer()
self._obs.long = str(lon)
self._obs.lat = str(lat)
if elev:
self._obs.elevation = int(elev)
if orb == 'sun':
self._orb = ephem.Sun()
elif orb == 'moon':
self._orb = ephem.Moon()
self.phase = self._phase
self.light = self._light
def rise(self, offset=0, center=True):
# workaround if rise is 0.001 seconds in the past
self._obs.date = datetime.datetime.utcnow() + dateutil.relativedelta.relativedelta(seconds=2)
self._obs.horizon = str(offset)
if offset != 0:
next_rising = self._obs.next_rising(self._orb, use_center=center).datetime()
else:
next_rising = self._obs.next_rising(self._orb).datetime()
return next_rising.replace(tzinfo=tzutc())
def set(self, offset=0, center=True):
# workaround if set is 0.001 seconds in the past
self._obs.date = datetime.datetime.utcnow() + dateutil.relativedelta.relativedelta(seconds=2)
self._obs.horizon = str(offset)
if offset != 0:
next_setting = self._obs.next_setting(self._orb, use_center=center).datetime()
else:
next_setting = self._obs.next_setting(self._orb).datetime()
return next_setting.replace(tzinfo=tzutc())
def pos(self, offset=None): # offset in minutes
date = datetime.datetime.utcnow()
if offset:
date += dateutil.relativedelta.relativedelta(minutes=offset)
self._obs.date = date
angle = self._orb.compute(self._obs)
return (angle.az, angle.alt)
def _light(self, offset=None): # offset in minutes
date = datetime.datetime.utcnow()
if offset:
date += dateutil.relativedelta.relativedelta(minutes=offset)
self._obs.date = date
self._orb.compute(self._obs)
return int(round(self._orb.moon_phase * 100))
def _phase(self, offset=None): # offset in minutes
date = datetime.datetime.utcnow()
cycle = 29.530588861
if offset:
date += dateutil.relativedelta.relativedelta(minutes=offset)
self._obs.date = date
self._orb.compute(self._obs)
last = ephem.previous_new_moon(self._obs.date)
frac = (self._obs.date - last) / cycle
return int(round(frac * 8))
| mptei/smarthome | lib/orb.py | Python | gpl-3.0 | 3,811 |
# Copyright (c) 2012 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.
# Special vlan_id value in ovs_vlan_allocations table indicating flat network
FLAT_VLAN_ID = -1
# Topic for tunnel notifications between the plugin and agent
TUNNEL = 'tunnel'
# Values for network_type
TYPE_FLAT = 'flat'
TYPE_VLAN = 'vlan'
TYPE_GRE = 'gre'
TYPE_LOCAL = 'local'
TYPE_NONE = 'none'
# Name prefixes for veth device pair linking the integration bridge
# with the physical bridge for a physical network
VETH_INTEGRATION_PREFIX = 'int-'
VETH_PHYSICAL_PREFIX = 'phy-'
| ruijie/quantum | quantum/plugins/openvswitch/common/constants.py | Python | apache-2.0 | 1,066 |
#!/usr/bin/env python
"""
Convert GFF2 file format to BED
Careful: GFF2 files have 1-based coordinates and BED files have 0-based coordinates
This is called "off-by-one coordinate"
"""
####################
## Import librairies
####################
# import librairies
import argparse
import os
####################
## Arguments
####################
parser = argparse.ArgumentParser()
parser.add_argument("-i","--gff2",type=str,help="the input GFF2 file to be converted")
parser.add_argument("-o","--bed",type=str,help="the output BED file returned",default="bed.txt")
args = parser.parse_args()
############
with open(args.gff2,"r") as filin:
lines = filin.readlines()
lines = [line.strip() for line in lines]
newlines = [line.split("\t") for line in lines]
with open(args.bed,"w") as fileout:
for i in range(0,len(lines),1):
chrom = newlines[i][0]
start = newlines[i][3]
end = newlines[i][4]
name = newlines[i][8]
score = newlines[i][5]
strand = newlines[i][6]
fileout.write(str(chrom) + "\t" + str(start) + "\t" + str(end) + "\t" + str(name) + "\t" + str(score) + "\t" + str(strand) + "\n")
| BleekerLab/Solanum_sRNAs | scripts/gff2tobed.py | Python | mit | 1,180 |
"""Handles DigitalOcean Domain Record CRD."""
| Jitsusama/lets-do-dns | lets_do_dns/do_domain/__init__.py | Python | apache-2.0 | 46 |
import _objc
__all__ = ['protocolNamed', 'ProtocolError']
class ProtocolError(_objc.error):
__module__ = 'objc'
PROTOCOL_CACHE = {}
def protocolNamed(name):
"""
Returns a Protocol object for the named protocol. This is the
equivalent of @protocol(name) in Objective-C.
Raises objc.ProtocolError when the protocol does not exist.
"""
name = unicode(name)
try:
return PROTOCOL_CACHE[name]
except KeyError:
pass
for p in _objc.protocolsForProcess():
pname = p.__name__
PROTOCOL_CACHE.setdefault(pname, p)
if pname == name:
return p
for cls in _objc.getClassList():
for p in _objc.protocolsForClass(cls):
pname = p.__name__
PROTOCOL_CACHE.setdefault(pname, p)
if pname == name:
return p
raise ProtocolError("protocol %r does not exist" % (name,), name)
| rays/ipodderx-core | objc/_protocols.py | Python | mit | 912 |
from rllab.spaces.base import Space
import tensorflow as tf
import numpy as np
class Product(Space):
def __init__(self, *components):
if isinstance(components[0], (list, tuple)):
assert len(components) == 1
components = components[0]
self._components = tuple(components)
dtypes = [c.dtype for c in components]
if len(dtypes) > 0 and hasattr(dtypes[0], "as_numpy_dtype"):
dtypes = [d.as_numpy_dtype for d in dtypes]
self._common_dtype = np.core.numerictypes.find_common_type([], dtypes)
def sample(self):
return tuple(x.sample() for x in self._components)
@property
def components(self):
return self._components
def contains(self, x):
return isinstance(x, tuple) and all(c.contains(xi) for c, xi in zip(self._components, x))
def new_tensor_variable(self, name, extra_dims):
return tf.placeholder(
dtype=self._common_dtype,
shape=[None] * extra_dims + [self.flat_dim],
name=name,
)
@property
def dtype(self):
return self._common_dtype
@property
def flat_dim(self):
return int(np.sum([c.flat_dim for c in self._components]))
def flatten(self, x):
return np.concatenate([c.flatten(xi) for c, xi in zip(self._components, x)])
def flatten_n(self, xs):
xs_regrouped = [[x[i] for x in xs] for i in range(len(xs[0]))]
flat_regrouped = [c.flatten_n(xi) for c, xi in zip(self.components, xs_regrouped)]
return np.concatenate(flat_regrouped, axis=-1)
def unflatten(self, x):
dims = [c.flat_dim for c in self._components]
flat_xs = np.split(x, np.cumsum(dims)[:-1])
return tuple(c.unflatten(xi) for c, xi in zip(self._components, flat_xs))
def unflatten_n(self, xs):
dims = [c.flat_dim for c in self._components]
flat_xs = np.split(xs, np.cumsum(dims)[:-1], axis=-1)
unflat_xs = [c.unflatten_n(xi) for c, xi in zip(self.components, flat_xs)]
unflat_xs_grouped = list(zip(*unflat_xs))
return unflat_xs_grouped
def __eq__(self, other):
if not isinstance(other, Product):
return False
return tuple(self.components) == tuple(other.components)
def __hash__(self):
return hash(tuple(self.components))
| brain-research/mirage-rl-qprop | sandbox/rocky/tf/spaces/product.py | Python | mit | 2,360 |
#!/usr/bin/python
"""
This example shows subfigure functionality.
.. :copyright: (c) 2014 by Jelte Fennema.
:license: MIT, see License for more details.
"""
# begin-doc-include
from pylatex import Document, Section, Figure, SubFigure, NoEscape
import os
if __name__ == '__main__':
doc = Document(default_filepath='subfigures')
image_filename = os.path.join(os.path.dirname(__file__), 'kitten.jpg')
with doc.create(Section('Showing subfigures')):
with doc.create(Figure(position='h!')) as kittens:
with doc.create(SubFigure(
position='b',
width=NoEscape(r'0.45\linewidth'))) as left_kitten:
left_kitten.add_image(image_filename,
width=NoEscape(r'\linewidth'))
left_kitten.add_caption('Kitten on the left')
with doc.create(SubFigure(
position='b',
width=NoEscape(r'0.45\linewidth'))) as right_kitten:
right_kitten.add_image(image_filename,
width=NoEscape(r'\linewidth'))
right_kitten.add_caption('Kitten on the right')
kittens.add_caption("Two kittens")
doc.generate_pdf(clean_tex=False)
| JelteF/PyLaTeX | examples/subfigure.py | Python | mit | 1,279 |
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.db import IntegrityError
from django.core.exceptions import ObjectDoesNotExist
from sshkm.models import Group, Key, KeyGroup, Permission
from sshkm.forms import GroupForm
@login_required
def GroupList(request):
groups = Group.objects.order_by('name')
context = {'groups': groups}
return render(request, 'sshkm/group/list.html', context)
@login_required
def GroupDetail(request):
if request.method == 'GET' and 'id' in request.GET:
group = get_object_or_404(Group, pk=request.GET['id'])
groupform = GroupForm(instance=group)
permissions = Permission.objects.filter(group_id=request.GET['id'])
members = Key.objects.all()
members_selected = KeyGroup.objects.all().filter(group_id=request.GET['id'])
ids_selected = []
for member_selected in members_selected:
ids_selected.append(member_selected.key_id)
members_not_selected = Key.objects.all().exclude(id__in=ids_selected)
return render(request, 'sshkm/group/detail.html', {
'groupform': groupform,
'permissions': permissions,
'members': members,
'members_selected': members_selected,
'members_not_selected': members_not_selected,
})
else:
groupform = GroupForm()
members_not_selected = Key.objects.all()
return render(request, 'sshkm/group/detail.html', {
'groupform': groupform,
'members_not_selected': members_not_selected,
})
@login_required
def GroupDelete(request):
try:
if request.POST.get('id_multiple') is not None:
Group.objects.filter(id__in=request.POST.getlist('id_multiple')).delete()
messages.add_message(request, messages.SUCCESS, "Groups deleted")
else:
group = Group.objects.get(id=request.GET['id'])
delete = Group(id=request.GET['id']).delete()
messages.add_message(request, messages.SUCCESS, "Group " + group.name + " deleted")
except ObjectDoesNotExist as e:
messages.add_message(request, messages.ERROR, "The group could not be deleted")
except Exception as e:
messages.add_message(request, messages.ERROR, "The group could not be deleted")
return HttpResponseRedirect(reverse('GroupList'))
@login_required
def GroupSave(request):
try:
if request.POST.get('id') is not None:
group = Group(
id=request.POST.get('id'),
name=request.POST.get('name'),
description=request.POST.get('description', ''),
)
KeyGroup.objects.filter(group_id=request.POST.get('id')).delete()
group.save()
for key_id in request.POST.getlist('members'):
keygroup = KeyGroup(key_id=key_id, group_id=group.id)
keygroup.save()
else:
group = Group(
name=request.POST.get('name'),
description=request.POST.get('description'),
)
group.save()
for key_id in request.POST.getlist('members'):
keygroup = KeyGroup(key_id=key_id, group_id=group.id)
keygroup.save()
messages.add_message(request, messages.SUCCESS, "Group " + request.POST.get('name') + " sucessfully saved")
except AttributeError as e:
messages.add_message(request, messages.WARNING, "Group " + request.POST.get('name') + " sucessfully saved with warnings")
except ValueError as e:
messages.add_message(request, messages.ERROR, "The group could not be saved (ValueError)")
except IntegrityError as e:
messages.add_message(request, messages.ERROR, "The group could not be saved. Group already exists.")
except Exception as e:
messages.add_message(request, messages.ERROR, "The group could not be saved")
return HttpResponseRedirect(reverse('GroupList'))
| sshkm/django-sshkm | sshkm/views/group.py | Python | gpl-3.0 | 4,174 |
# Copyright (C) 2016, Hitachi, 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.
#
"""HORCM interface module for Hitachi VSP Driver."""
import functools
import math
import os
import re
from oslo_config import cfg
from oslo_config import types
from oslo_log import log as logging
from oslo_service import loopingcall
from oslo_utils import excutils
from oslo_utils import timeutils
from oslo_utils import units
import six
from six.moves import range
from cinder import coordination
from cinder import exception
from cinder import utils as cinder_utils
from cinder.volume.drivers.hitachi import vsp_common as common
from cinder.volume.drivers.hitachi import vsp_utils as utils
_GETSTORAGEARRAY_ONCE = 1000
_LU_PATH_DEFINED = 'SSB=0xB958,0x015A'
_ANOTHER_LDEV_MAPPED = 'SSB=0xB958,0x0947'
_NOT_LOCKED = 'SSB=0x2E11,0x2205'
_LOCK_WAITTIME = 2 * 60 * 60
NORMAL_STS = 'NML'
_LDEV_STATUS_WAITTIME = 120
_LDEV_CHECK_INTERVAL = 1
_LDEV_CREATED = ['-check_status', NORMAL_STS]
_LDEV_DELETED = ['-check_status', 'NOT', 'DEFINED']
_LUN_MAX_WAITTIME = 50
_LUN_RETRY_INTERVAL = 1
FULL_ATTR = 'MRCF'
THIN_ATTR = 'QS'
VVOL_ATTR = 'VVOL'
_PERMITTED_TYPES = set(['CVS', 'HDP', 'HDT'])
_PAIR_ATTRS = set([FULL_ATTR, THIN_ATTR])
_CHECK_KEYS = ('vol_type', 'vol_size', 'num_port', 'vol_attr', 'sts')
_HORCM_WAITTIME = 1
_EXEC_MAX_WAITTIME = 30
_EXTEND_WAITTIME = 10 * 60
_EXEC_RETRY_INTERVAL = 5
_HORCM_NO_RETRY_ERRORS = [
'SSB=0x2E10,0x9705',
'SSB=0x2E10,0x9706',
'SSB=0x2E10,0x9707',
'SSB=0x2E11,0x8303',
'SSB=0x2E30,0x0007',
'SSB=0xB956,0x3173',
'SSB=0xB956,0x31D7',
'SSB=0xB956,0x31D9',
'SSB=0xB957,0x4188',
_LU_PATH_DEFINED,
'SSB=0xB958,0x015E',
]
SMPL = 1
PVOL = 2
SVOL = 3
COPY = 2
PAIR = 3
PSUS = 4
PSUE = 5
UNKN = 0xff
_STATUS_TABLE = {
'SMPL': SMPL,
'COPY': COPY,
'RCPY': COPY,
'PAIR': PAIR,
'PFUL': PAIR,
'PSUS': PSUS,
'PFUS': PSUS,
'SSUS': PSUS,
'PSUE': PSUE,
}
_NOT_SET = '-'
_SMPL_STAUS = set([_NOT_SET, 'SMPL'])
_HORCM_RUNNING = 1
_COPY_GROUP = utils.DRIVER_PREFIX + '-%s%s%03X%d'
_SNAP_NAME = utils.DRIVER_PREFIX + '-SNAP'
_LDEV_NAME = utils.DRIVER_PREFIX + '-LDEV-%d-%d'
_PAIR_TARGET_NAME_BODY = 'pair00'
_PAIR_TARGET_NAME = utils.TARGET_PREFIX + _PAIR_TARGET_NAME_BODY
_MAX_MUNS = 3
_SNAP_HASH_SIZE = 8
ALL_EXIT_CODE = set(range(256))
HORCM_EXIT_CODE = set(range(128))
EX_ENAUTH = 202
EX_ENOOBJ = 205
EX_CMDRJE = 221
EX_ENLDEV = 227
EX_CMDIOE = 237
EX_ENOGRP = 239
EX_INVCMD = 240
EX_INVMOD = 241
EX_ENORMT = 242
EX_ENODEV = 246
EX_ENOENT = 247
EX_OPTINV = 248
EX_ATTDBG = 250
EX_ATTHOR = 251
EX_INVARG = 253
EX_COMERR = 255
_NO_SUCH_DEVICE = [EX_ENOGRP, EX_ENODEV, EX_ENOENT]
_INVALID_RANGE = [EX_ENLDEV, EX_INVARG]
_HORCM_ERROR = set([EX_ENORMT, EX_ATTDBG, EX_ATTHOR, EX_COMERR])
_COMMAND_IO_TO_RAID = set(
[EX_CMDRJE, EX_CMDIOE, EX_INVCMD, EX_INVMOD, EX_OPTINV])
_DEFAULT_PORT_BASE = 31000
_HORCMGR = 0
_PAIR_HORCMGR = 1
_INFINITE = "-"
_HORCM_PATTERNS = {
'gid': {
'pattern': re.compile(r"ID +(?P<gid>\d+)\(0x\w+\)"),
'type': six.text_type,
},
'ldev': {
'pattern': re.compile(r"^LDEV +: +(?P<ldev>\d+)", re.M),
'type': int,
},
'lun': {
'pattern': re.compile(r"LUN +(?P<lun>\d+)\(0x\w+\)"),
'type': six.text_type,
},
'num_port': {
'pattern': re.compile(r"^NUM_PORT +: +(?P<num_port>\d+)", re.M),
'type': int,
},
'pair_gid': {
'pattern': re.compile(
r"^CL\w-\w+ +(?P<pair_gid>\d+) +%s " % _PAIR_TARGET_NAME, re.M),
'type': six.text_type,
},
'ports': {
'pattern': re.compile(r"^PORTs +: +(?P<ports>.+)$", re.M),
'type': list,
},
'vol_attr': {
'pattern': re.compile(r"^VOL_ATTR +: +(?P<vol_attr>.+)$", re.M),
'type': list,
},
'vol_size': {
'pattern': re.compile(
r"^VOL_Capacity\(BLK\) +: +(?P<vol_size>\d+)""", re.M),
'type': int,
},
'vol_type': {
'pattern': re.compile(r"^VOL_TYPE +: +(?P<vol_type>.+)$", re.M),
'type': six.text_type,
},
'sts': {
'pattern': re.compile(r"^STS +: +(?P<sts>.+)", re.M),
'type': six.text_type,
},
'undefined_ldev': {
'pattern': re.compile(
r"^ +\d+ +(?P<undefined_ldev>\d+) +- +- +NOT +DEFINED", re.M),
'type': int,
},
}
LDEV_SEP_PATTERN = re.compile(r'\ +:\ +')
CMD_PATTERN = re.compile(r"((?:^|\n)HORCM_CMD\n)")
horcm_opts = [
cfg.ListOpt(
'vsp_horcm_numbers',
item_type=types.Integer(min=0, max=2047),
default=[200, 201],
help='Command Control Interface instance numbers in the format of '
'\'xxx,yyy\'. The second one is for Shadow Image operation and '
'the first one is for other purposes.'),
cfg.StrOpt(
'vsp_horcm_user',
help='Name of the user on the storage system.'),
cfg.StrOpt(
'vsp_horcm_password',
secret=True,
help='Password corresponding to vsp_horcm_user.'),
cfg.BoolOpt(
'vsp_horcm_add_conf',
default=True,
help='If True, the driver will create or update the Command Control '
'Interface configuration file as needed.'),
cfg.ListOpt(
'vsp_horcm_pair_target_ports',
help='IDs of the storage ports used to copy volumes by Shadow Image '
'or Thin Image. To specify multiple ports, connect them by '
'commas (e.g. CL1-A,CL2-A).'),
]
_REQUIRED_HORCM_OPTS = [
'vsp_horcm_user',
'vsp_horcm_password',
]
CONF = cfg.CONF
CONF.register_opts(horcm_opts)
LOG = logging.getLogger(__name__)
MSG = utils.VSPMsg
def horcmgr_synchronized(func):
"""Synchronize CCI operations per CCI instance."""
@functools.wraps(func)
def wrap(self, *args, **kwargs):
"""Synchronize CCI operations per CCI instance."""
@coordination.synchronized(self.lock[args[0]])
def func_locked(*_args, **_kwargs):
"""Execute the wrapped function in a synchronized section."""
return func(*_args, **_kwargs)
return func_locked(self, *args, **kwargs)
return wrap
def _is_valid_target(target, target_name, target_ports, is_pair):
"""Return True if the specified target is valid, False otherwise."""
if is_pair:
return (target[:utils.PORT_ID_LENGTH] in target_ports and
target_name == _PAIR_TARGET_NAME)
if (target[:utils.PORT_ID_LENGTH] not in target_ports or
not target_name.startswith(utils.TARGET_PREFIX) or
target_name == _PAIR_TARGET_NAME):
return False
return True
def find_value(stdout, key):
"""Return the first match from the given raidcom command output."""
match = _HORCM_PATTERNS[key]['pattern'].search(stdout)
if match:
if _HORCM_PATTERNS[key]['type'] is list:
return [
value.strip() for value in
LDEV_SEP_PATTERN.split(match.group(key))]
return _HORCM_PATTERNS[key]['type'](match.group(key))
return None
def _run_horcmgr(inst):
"""Return 1 if the CCI instance is running."""
result = utils.execute(
'env', 'HORCMINST=%s' % inst, 'horcmgr', '-check')
return result[0]
def _run_horcmshutdown(inst):
"""Stop the CCI instance and return 0 if successful."""
result = utils.execute('horcmshutdown.sh', inst)
return result[0]
def _run_horcmstart(inst):
"""Start the CCI instance and return 0 if successful."""
result = utils.execute('horcmstart.sh', inst)
return result[0]
def _check_ldev(ldev_info, ldev, existing_ref):
"""Check if the LDEV meets the criteria for being managed by the driver."""
if ldev_info['sts'] != NORMAL_STS:
msg = utils.output_log(MSG.INVALID_LDEV_FOR_MANAGE)
raise exception.ManageExistingInvalidReference(
existing_ref=existing_ref, reason=msg)
vol_attr = set(ldev_info['vol_attr'])
if (not ldev_info['vol_type'].startswith('OPEN-V') or
len(vol_attr) < 2 or not vol_attr.issubset(_PERMITTED_TYPES)):
msg = utils.output_log(MSG.INVALID_LDEV_ATTR_FOR_MANAGE, ldev=ldev,
ldevtype=utils.NVOL_LDEV_TYPE)
raise exception.ManageExistingInvalidReference(
existing_ref=existing_ref, reason=msg)
# Hitachi storage calculates volume sizes in a block unit, 512 bytes.
if ldev_info['vol_size'] % utils.GIGABYTE_PER_BLOCK_SIZE:
msg = utils.output_log(MSG.INVALID_LDEV_SIZE_FOR_MANAGE, ldev=ldev)
raise exception.ManageExistingInvalidReference(
existing_ref=existing_ref, reason=msg)
if ldev_info['num_port']:
msg = utils.output_log(MSG.INVALID_LDEV_PORT_FOR_MANAGE, ldev=ldev)
raise exception.ManageExistingInvalidReference(
existing_ref=existing_ref, reason=msg)
class VSPHORCM(common.VSPCommon):
"""HORCM interface class for Hitachi VSP Driver."""
def __init__(self, conf, storage_protocol, db):
"""Initialize instance variables."""
super(VSPHORCM, self).__init__(conf, storage_protocol, db)
self.conf.append_config_values(horcm_opts)
self._copy_groups = [None] * _MAX_MUNS
self._pair_targets = []
self._pattern = {
'pool': None,
'p_pool': None,
}
def run_raidcom(self, *args, **kwargs):
"""Run a raidcom command and return its output."""
if 'success_code' not in kwargs:
kwargs['success_code'] = HORCM_EXIT_CODE
cmd = ['raidcom'] + list(args) + [
'-s', self.conf.vsp_storage_id,
'-I%s' % self.conf.vsp_horcm_numbers[_HORCMGR]]
return self.run_and_verify_storage_cli(*cmd, **kwargs)
def _run_pair_cmd(self, command, *args, **kwargs):
"""Run a pair-related CCI command and return its output."""
kwargs['horcmgr'] = _PAIR_HORCMGR
if 'success_code' not in kwargs:
kwargs['success_code'] = HORCM_EXIT_CODE
cmd = [command] + list(args) + [
'-IM%s' % self.conf.vsp_horcm_numbers[_PAIR_HORCMGR]]
return self.run_and_verify_storage_cli(*cmd, **kwargs)
def run_storage_cli(self, *cmd, **kwargs):
"""Run a CCI command and return its output."""
interval = kwargs.pop('interval', _EXEC_RETRY_INTERVAL)
flag = {'ignore_enauth': True}
def _wait_for_horcm_execution(start_time, flag, *cmd, **kwargs):
"""Run a CCI command and raise its output."""
ignore_error = kwargs.pop('ignore_error', [])
no_retry_error = ignore_error + _HORCM_NO_RETRY_ERRORS
success_code = kwargs.pop('success_code', HORCM_EXIT_CODE)
timeout = kwargs.pop('timeout', _EXEC_MAX_WAITTIME)
horcmgr = kwargs.pop('horcmgr', _HORCMGR)
do_login = kwargs.pop('do_login', False)
result = utils.execute(*cmd, **kwargs)
if _NOT_LOCKED in result[2] and not utils.check_timeout(
start_time, _LOCK_WAITTIME):
LOG.debug(
"The resource group to which the operation object "
"belongs is being locked by other software.")
return
if (result[0] in success_code or
utils.check_timeout(start_time, timeout) or
utils.check_ignore_error(no_retry_error, result[2])):
raise loopingcall.LoopingCallDone(result)
if result[0] == EX_ENAUTH:
if not self._retry_login(flag['ignore_enauth'], do_login):
raise loopingcall.LoopingCallDone(result)
flag['ignore_enauth'] = False
elif result[0] in _HORCM_ERROR:
if not self._start_horcmgr(horcmgr):
raise loopingcall.LoopingCallDone(result)
elif result[0] not in _COMMAND_IO_TO_RAID:
raise loopingcall.LoopingCallDone(result)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_horcm_execution, timeutils.utcnow(),
flag, *cmd, **kwargs)
return loop.start(interval=interval).wait()
def _retry_login(self, ignore_enauth, do_login):
"""Return True if login to CCI succeeds, False otherwise."""
if not ignore_enauth:
if not do_login:
result = self._run_raidcom_login(do_raise=False)
if do_login or result[0]:
utils.output_log(MSG.HORCM_LOGIN_FAILED,
user=self.conf.vsp_horcm_user)
return False
return True
def _run_raidcom_login(self, do_raise=True):
"""Log in to CCI and return its output."""
return self.run_raidcom(
'-login', self.conf.vsp_horcm_user,
self.conf.vsp_horcm_password,
do_raise=do_raise, do_login=True)
@horcmgr_synchronized
def _restart_horcmgr(self, horcmgr):
"""Restart the CCI instance."""
inst = self.conf.vsp_horcm_numbers[horcmgr]
def _wait_for_horcm_shutdown(start_time, inst):
"""Stop the CCI instance and raise True if it stops."""
if _run_horcmgr(inst) != _HORCM_RUNNING:
raise loopingcall.LoopingCallDone()
if (_run_horcmshutdown(inst) and
_run_horcmgr(inst) == _HORCM_RUNNING or
utils.check_timeout(
start_time, utils.DEFAULT_PROCESS_WAITTIME)):
raise loopingcall.LoopingCallDone(False)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_horcm_shutdown, timeutils.utcnow(), inst)
if not loop.start(interval=_HORCM_WAITTIME).wait():
msg = utils.output_log(
MSG.HORCM_SHUTDOWN_FAILED,
inst=self.conf.vsp_horcm_numbers[horcmgr])
raise exception.VSPError(msg)
ret = _run_horcmstart(inst)
if ret and ret != _HORCM_RUNNING:
msg = utils.output_log(
MSG.HORCM_RESTART_FAILED,
inst=self.conf.vsp_horcm_numbers[horcmgr])
raise exception.VSPError(msg)
@coordination.synchronized('{self.lock[create_ldev]}')
def create_ldev(self, size, is_vvol=False):
"""Create an LDEV of the specified size and the specified type."""
ldev = super(VSPHORCM, self).create_ldev(size, is_vvol=is_vvol)
self._check_ldev_status(ldev)
return ldev
def _check_ldev_status(self, ldev, delete=False):
"""Wait until the LDEV status changes to the specified status."""
if not delete:
args = _LDEV_CREATED
msg_id = MSG.LDEV_CREATION_WAIT_TIMEOUT
else:
args = _LDEV_DELETED
msg_id = MSG.LDEV_DELETION_WAIT_TIMEOUT
def _wait_for_ldev_status(start_time, ldev, *args):
"""Raise True if the LDEV is in the specified status."""
result = self.run_raidcom(
'get', 'ldev', '-ldev_id', ldev, *args, do_raise=False)
if not result[0]:
raise loopingcall.LoopingCallDone()
if utils.check_timeout(start_time, _LDEV_STATUS_WAITTIME):
raise loopingcall.LoopingCallDone(False)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_ldev_status, timeutils.utcnow(), ldev, *args)
if not loop.start(interval=_LDEV_CHECK_INTERVAL).wait():
msg = utils.output_log(msg_id, ldev=ldev)
raise exception.VSPError(msg)
def create_ldev_on_storage(self, ldev, size, is_vvol):
"""Create an LDEV on the storage system."""
args = ['add', 'ldev', '-ldev_id', ldev, '-capacity', '%sG' % size,
'-emulation', 'OPEN-V', '-pool']
if is_vvol:
args.append('snap')
else:
args.append(self.conf.vsp_pool)
self.run_raidcom(*args)
def get_unused_ldev(self):
"""Find an unused LDEV and return its LDEV number."""
if not self.storage_info['ldev_range']:
ldev_info = self.get_ldev_info(
['ldev'], '-ldev_list', 'undefined', '-cnt', '1')
ldev = ldev_info.get('ldev')
else:
ldev = self._find_unused_ldev_by_range()
# When 'ldev' is 0, it should be true.
# Therefore, it cannot remove 'is None'.
if ldev is None:
msg = utils.output_log(MSG.NO_AVAILABLE_RESOURCE, resource='LDEV')
raise exception.VSPError(msg)
return ldev
def _find_unused_ldev_by_range(self):
"""Return the LDEV number of an unused LDEV in the LDEV range."""
success_code = HORCM_EXIT_CODE.union(_INVALID_RANGE)
start, end = self.storage_info['ldev_range'][:2]
while start <= end:
if end - start + 1 > _GETSTORAGEARRAY_ONCE:
cnt = _GETSTORAGEARRAY_ONCE
else:
cnt = end - start + 1
ldev_info = self.get_ldev_info(
['undefined_ldev'], '-ldev_id', start, '-cnt', cnt,
'-key', 'front_end', success_code=success_code)
ldev = ldev_info.get('undefined_ldev')
# When 'ldev' is 0, it should be true.
# Therefore, it cannot remove 'is not None'.
if ldev is not None:
return ldev
start += _GETSTORAGEARRAY_ONCE
return None
def get_ldev_info(self, keys, *args, **kwargs):
"""Return a dictionary of LDEV-related items."""
data = {}
result = self.run_raidcom('get', 'ldev', *args, **kwargs)
for key in keys:
data[key] = find_value(result[1], key)
return data
def copy_on_storage(self, pvol, size, metadata, sync):
"""Check if the LDEV can be copied on the storage."""
ldev_info = self.get_ldev_info(['sts', 'vol_attr'], '-ldev_id', pvol)
if ldev_info['sts'] != NORMAL_STS:
msg = utils.output_log(MSG.INVALID_LDEV_STATUS_FOR_COPY, ldev=pvol)
raise exception.VSPError(msg)
if VVOL_ATTR in ldev_info['vol_attr']:
raise exception.VSPNotSupported()
return super(VSPHORCM, self).copy_on_storage(pvol, size, metadata,
sync)
@coordination.synchronized('{self.lock[create_pair]}')
def create_pair_on_storage(self, pvol, svol, is_thin):
"""Create a copy pair on the storage."""
path_list = []
vol_type, pair_info = self._get_vol_type_and_pair_info(pvol)
if vol_type == SVOL:
self._delete_pair_based_on_svol(
pair_info['pvol'], pair_info['svol_info'],
no_restart=True)
if vol_type != PVOL:
self._initialize_pair_connection(pvol)
path_list.append(pvol)
try:
self._initialize_pair_connection(svol)
path_list.append(svol)
self._create_pair_on_storage_core(pvol, svol, is_thin, vol_type)
except exception.VSPError:
with excutils.save_and_reraise_exception():
for ldev in path_list:
try:
self._terminate_pair_connection(ldev)
except exception.VSPError:
utils.output_log(MSG.UNMAP_LDEV_FAILED, ldev=ldev)
def _create_pair_on_storage_core(self, pvol, svol, is_thin, vol_type):
"""Create a copy pair on the storage depending on the copy method."""
if is_thin:
self._create_thin_copy_pair(pvol, svol)
else:
self._create_full_copy_pair(pvol, svol, vol_type)
def _create_thin_copy_pair(self, pvol, svol):
"""Create a THIN copy pair on the storage."""
snapshot_name = _SNAP_NAME + six.text_type(svol % _SNAP_HASH_SIZE)
self.run_raidcom(
'add', 'snapshot', '-ldev_id', pvol, svol, '-pool',
self.conf.vsp_thin_pool, '-snapshot_name',
snapshot_name, '-copy_size', self.conf.vsp_copy_speed)
try:
self.wait_thin_copy(svol, PAIR)
self.run_raidcom(
'modify', 'snapshot', '-ldev_id', svol,
'-snapshot_data', 'create')
self.wait_thin_copy(svol, PSUS)
except exception.VSPError:
with excutils.save_and_reraise_exception():
interval = self.conf.vsp_async_copy_check_interval
try:
self._delete_thin_copy_pair(pvol, svol, interval)
except exception.VSPError:
utils.output_log(MSG.DELETE_TI_PAIR_FAILED, pvol=pvol,
svol=svol)
def _create_full_copy_pair(self, pvol, svol, vol_type):
"""Create a FULL copy pair on the storage."""
mun = 0
if vol_type == PVOL:
mun = self._get_unused_mun(pvol)
copy_group = self._copy_groups[mun]
ldev_name = _LDEV_NAME % (pvol, svol)
restart = False
create = False
try:
self._add_pair_config(pvol, svol, copy_group, ldev_name, mun)
self._restart_horcmgr(_PAIR_HORCMGR)
restart = True
self._run_pair_cmd(
'paircreate', '-g', copy_group, '-d', ldev_name,
'-c', self.conf.vsp_copy_speed,
'-vl', '-split', '-fq', 'quick')
create = True
self._wait_full_copy(svol, set([PSUS, COPY]))
except exception.VSPError:
with excutils.save_and_reraise_exception():
if create:
try:
self._wait_full_copy(svol, set([PAIR, PSUS, PSUE]))
except exception.VSPError:
utils.output_log(MSG.WAIT_SI_PAIR_STATUS_FAILED,
pvol=pvol, svol=svol)
interval = self.conf.vsp_async_copy_check_interval
try:
self._delete_full_copy_pair(pvol, svol, interval)
except exception.VSPError:
utils.output_log(MSG.DELETE_SI_PAIR_FAILED, pvol=pvol,
svol=svol)
try:
if self._is_smpl(svol):
self._delete_pair_config(
pvol, svol, copy_group, ldev_name)
except exception.VSPError:
utils.output_log(MSG.DELETE_DEVICE_GRP_FAILED, pvol=pvol,
svol=svol)
if restart:
try:
self._restart_horcmgr(_PAIR_HORCMGR)
except exception.VSPError:
utils.output_log(
MSG.HORCM_RESTART_FOR_SI_FAILED,
inst=self.conf.vsp_horcm_numbers[1])
def _get_unused_mun(self, ldev):
"""Return the number of an unused mirror unit."""
pair_list = []
for mun in range(_MAX_MUNS):
pair_info = self._get_full_copy_pair_info(ldev, mun)
if not pair_info:
return mun
pair_list.append((pair_info['svol_info'], mun))
for svol_info, mun in pair_list:
if svol_info['is_psus']:
self._delete_pair_based_on_svol(
ldev, svol_info, no_restart=True)
return mun
utils.output_log(MSG.NO_AVAILABLE_MIRROR_UNIT,
copy_method=utils.FULL, pvol=ldev)
raise exception.VSPBusy()
def _get_vol_type_and_pair_info(self, ldev):
"""Return a tuple of the LDEV's Shadow Image pair status and info."""
ldev_info = self.get_ldev_info(['sts', 'vol_attr'], '-ldev_id', ldev)
if ldev_info['sts'] != NORMAL_STS:
return (SMPL, None)
if THIN_ATTR in ldev_info['vol_attr']:
return (PVOL, None)
if FULL_ATTR in ldev_info['vol_attr']:
pair_info = self._get_full_copy_pair_info(ldev, 0)
if not pair_info:
return (PVOL, None)
if pair_info['pvol'] != ldev:
return (SVOL, pair_info)
return (PVOL, None)
return (SMPL, None)
def _get_full_copy_info(self, ldev):
"""Return a tuple of P-VOL and S-VOL's info of a Shadow Image pair."""
vol_type, pair_info = self._get_vol_type_and_pair_info(ldev)
svol_info = []
if vol_type == SMPL:
return (None, None)
elif vol_type == SVOL:
return (pair_info['pvol'], [pair_info['svol_info']])
for mun in range(_MAX_MUNS):
pair_info = self._get_full_copy_pair_info(ldev, mun)
if pair_info:
svol_info.append(pair_info['svol_info'])
return (ldev, svol_info)
@coordination.synchronized('{self.lock[create_pair]}')
def delete_pair(self, ldev, all_split=True):
"""Delete the specified LDEV in a synchronized section."""
super(VSPHORCM, self).delete_pair(ldev, all_split=all_split)
def delete_pair_based_on_pvol(self, pair_info, all_split):
"""Disconnect all volume pairs to which the specified P-VOL belongs."""
svols = []
restart = False
try:
for svol_info in pair_info['svol_info']:
if svol_info['is_thin'] or not svol_info['is_psus']:
svols.append(six.text_type(svol_info['ldev']))
continue
self.delete_pair_from_storage(
pair_info['pvol'], svol_info['ldev'], False)
restart = True
self._terminate_pair_connection(svol_info['ldev'])
if not svols:
self._terminate_pair_connection(pair_info['pvol'])
finally:
if restart:
self._restart_horcmgr(_PAIR_HORCMGR)
if all_split and svols:
utils.output_log(
MSG.UNABLE_TO_DELETE_PAIR, pvol=pair_info['pvol'],
svol=', '.join(svols))
raise exception.VSPBusy()
def delete_pair_based_on_svol(self, pvol, svol_info):
"""Disconnect all volume pairs to which the specified S-VOL belongs."""
self._delete_pair_based_on_svol(pvol, svol_info)
def _delete_pair_based_on_svol(self, pvol, svol_info, no_restart=False):
"""Disconnect all volume pairs to which the specified S-VOL belongs."""
do_restart = False
if not svol_info['is_psus']:
utils.output_log(MSG.UNABLE_TO_DELETE_PAIR, pvol=pvol,
svol=svol_info['ldev'])
raise exception.VSPBusy()
try:
self.delete_pair_from_storage(
pvol, svol_info['ldev'], svol_info['is_thin'])
do_restart = True
self._terminate_pair_connection(svol_info['ldev'])
self._terminate_pair_connection(pvol)
finally:
if not no_restart and do_restart:
self._restart_horcmgr(_PAIR_HORCMGR)
def delete_pair_from_storage(self, pvol, svol, is_thin):
"""Disconnect the volume pair that consists of the specified LDEVs."""
interval = self.conf.vsp_async_copy_check_interval
if is_thin:
self._delete_thin_copy_pair(pvol, svol, interval)
else:
self._delete_full_copy_pair(pvol, svol, interval)
def _delete_thin_copy_pair(self, pvol, svol, interval):
"""Disconnect a THIN volume pair."""
result = self.run_raidcom(
'get', 'snapshot', '-ldev_id', svol)
if not result[1]:
return
mun = result[1].splitlines()[1].split()[5]
self.run_raidcom(
'unmap', 'snapshot', '-ldev_id', svol,
success_code=ALL_EXIT_CODE)
self.run_raidcom(
'delete', 'snapshot', '-ldev_id', pvol, '-mirror_id', mun)
self._wait_thin_copy_deleting(svol, interval=interval)
def _wait_thin_copy_deleting(self, ldev, **kwargs):
"""Wait until the LDEV is no longer in a THIN volume pair."""
interval = kwargs.pop(
'interval', self.conf.vsp_async_copy_check_interval)
def _wait_for_thin_copy_smpl(start_time, ldev, **kwargs):
"""Raise True if the LDEV is no longer in a THIN volume pair."""
timeout = kwargs.pop('timeout', utils.DEFAULT_PROCESS_WAITTIME)
ldev_info = self.get_ldev_info(
['sts', 'vol_attr'], '-ldev_id', ldev)
if (ldev_info['sts'] != NORMAL_STS or
THIN_ATTR not in ldev_info['vol_attr']):
raise loopingcall.LoopingCallDone()
if utils.check_timeout(start_time, timeout):
raise loopingcall.LoopingCallDone(False)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_thin_copy_smpl, timeutils.utcnow(), ldev, **kwargs)
if not loop.start(interval=interval).wait():
msg = utils.output_log(MSG.TI_PAIR_STATUS_WAIT_TIMEOUT, svol=ldev)
raise exception.VSPError(msg)
def _delete_full_copy_pair(self, pvol, svol, interval):
"""Disconnect a FULL volume pair."""
stdout = self._run_pairdisplay(
'-d', self.conf.vsp_storage_id, svol, 0)
if not stdout:
return
copy_group = stdout.splitlines()[2].split()[0]
ldev_name = _LDEV_NAME % (pvol, svol)
if stdout.splitlines()[1].split()[9] != 'P-VOL':
self._restart_horcmgr(_PAIR_HORCMGR)
try:
self._run_pair_cmd(
'pairsplit', '-g', copy_group, '-d', ldev_name, '-S')
self._wait_full_copy(svol, set([SMPL]), interval=interval)
finally:
if self._is_smpl(svol):
self._delete_pair_config(pvol, svol, copy_group, ldev_name)
def _initialize_pair_connection(self, ldev):
"""Initialize server-volume connection for volume copy."""
port, gid = None, None
for port, gid in self._pair_targets:
try:
targets = {
'list': [(port, gid)],
'lun': {},
}
return self.map_ldev(targets, ldev)
except exception.VSPError:
utils.output_log(MSG.MAP_LDEV_FAILED, ldev=ldev, port=port,
id=gid, lun=None)
msg = utils.output_log(MSG.NO_MAPPING_FOR_LDEV, ldev=ldev)
raise exception.VSPError(msg)
def _terminate_pair_connection(self, ldev):
"""Terminate server-volume connection for volume copy."""
targets = {
'list': [],
}
ldev_info = self.get_ldev_info(['sts', 'vol_attr'], '-ldev_id', ldev)
if (ldev_info['sts'] == NORMAL_STS and
FULL_ATTR in ldev_info['vol_attr'] or
self._get_thin_copy_svol_status(ldev) != SMPL):
LOG.debug(
'The specified LDEV has pair. Therefore, unmapping '
'operation was skipped. '
'(LDEV: %(ldev)s, vol_attr: %(info)s)',
{'ldev': ldev, 'info': ldev_info['vol_attr']})
return
self._find_mapped_targets_from_storage(
targets, ldev, self.storage_info['controller_ports'], is_pair=True)
self.unmap_ldev(targets, ldev)
def check_param(self):
"""Check parameter values and consistency among them."""
super(VSPHORCM, self).check_param()
utils.check_opts(self.conf, horcm_opts)
insts = self.conf.vsp_horcm_numbers
if len(insts) != 2 or insts[_HORCMGR] == insts[_PAIR_HORCMGR]:
msg = utils.output_log(MSG.INVALID_PARAMETER,
param='vsp_horcm_numbers')
raise exception.VSPError(msg)
if (not self.conf.vsp_target_ports and
not self.conf.vsp_horcm_pair_target_ports):
msg = utils.output_log(MSG.INVALID_PARAMETER,
param='vsp_target_ports or '
'vsp_horcm_pair_target_ports')
raise exception.VSPError(msg)
utils.output_log(MSG.SET_CONFIG_VALUE, object='LDEV range',
value=self.storage_info['ldev_range'])
for opt in _REQUIRED_HORCM_OPTS:
if not self.conf.safe_get(opt):
msg = utils.output_log(MSG.INVALID_PARAMETER, param=opt)
raise exception.VSPError(msg)
def _set_copy_groups(self, host_ip):
"""Initialize an instance variable for Shadow Image copy groups."""
serial = self.conf.vsp_storage_id
inst = self.conf.vsp_horcm_numbers[_PAIR_HORCMGR]
for mun in range(_MAX_MUNS):
copy_group = _COPY_GROUP % (host_ip, serial, inst, mun)
self._copy_groups[mun] = copy_group
utils.output_log(MSG.SET_CONFIG_VALUE, object='copy group list',
value=self._copy_groups)
def connect_storage(self):
"""Prepare for using the storage."""
self._set_copy_groups(CONF.my_ip)
if self.conf.vsp_horcm_add_conf:
self._create_horcm_conf()
self._create_horcm_conf(horcmgr=_PAIR_HORCMGR)
self._restart_horcmgr(_HORCMGR)
self._restart_horcmgr(_PAIR_HORCMGR)
self._run_raidcom_login()
super(VSPHORCM, self).connect_storage()
self._pattern['p_pool'] = re.compile(
(r"^%03d +\S+ +\d+ +\d+ +(?P<tp_cap>\d+) +\d+ +\d+ +\d+ +\w+ +"
r"\d+ +(?P<tl_cap>\d+)") % self.storage_info['pool_id'], re.M)
self._pattern['pool'] = re.compile(
r"^%03d +\S+ +\d+ +\S+ +\w+ +\d+ +\w+ +\d+ +(?P<vcap>\S+)" %
self.storage_info['pool_id'], re.M)
def _find_lun(self, ldev, port, gid):
"""Return LUN determined by the given arguments."""
result = self.run_raidcom(
'get', 'lun', '-port', '-'.join([port, gid]))
match = re.search(
r'^%(port)s +%(gid)s +\S+ +(?P<lun>\d+) +1 +%(ldev)s ' % {
'port': port, 'gid': gid, 'ldev': ldev}, result[1], re.M)
if match:
return match.group('lun')
return None
def _find_mapped_targets_from_storage(self, targets, ldev,
target_ports, is_pair=False):
"""Update port-gid list for the specified LDEV."""
ldev_info = self.get_ldev_info(['ports'], '-ldev_id', ldev)
if not ldev_info['ports']:
return
for ports_strings in ldev_info['ports']:
ports = ports_strings.split()
if _is_valid_target(ports[0], ports[2], target_ports, is_pair):
targets['list'].append(ports[0])
def find_mapped_targets_from_storage(self, targets, ldev, target_ports):
"""Update port-gid list for the specified LDEV."""
self._find_mapped_targets_from_storage(targets, ldev, target_ports)
def get_unmap_targets_list(self, target_list, mapped_list):
"""Return a list of IDs of ports that need to be disconnected."""
unmap_list = []
for mapping_info in mapped_list:
if (mapping_info[:utils.PORT_ID_LENGTH],
mapping_info.split('-')[2]) in target_list:
unmap_list.append(mapping_info)
return unmap_list
def unmap_ldev(self, targets, ldev):
"""Delete the LUN between the specified LDEV and port-gid."""
interval = _LUN_RETRY_INTERVAL
success_code = HORCM_EXIT_CODE.union([EX_ENOOBJ])
timeout = utils.DEFAULT_PROCESS_WAITTIME
for target in targets['list']:
self.run_raidcom(
'delete', 'lun', '-port', target, '-ldev_id', ldev,
interval=interval, success_code=success_code, timeout=timeout)
LOG.debug(
'Deleted logical unit path of the specified logical '
'device. (LDEV: %(ldev)s, target: %(target)s)',
{'ldev': ldev, 'target': target})
def find_all_mapped_targets_from_storage(self, targets, ldev):
"""Add all port-gids connected with the LDEV to the list."""
ldev_info = self.get_ldev_info(['ports'], '-ldev_id', ldev)
if ldev_info['ports']:
for port in ldev_info['ports']:
targets['list'].append(port.split()[0])
def delete_target_from_storage(self, port, gid):
"""Delete the host group or the iSCSI target from the port."""
result = self.run_raidcom(
'delete', 'host_grp', '-port',
'-'.join([port, gid]), do_raise=False)
if result[0]:
utils.output_log(MSG.DELETE_TARGET_FAILED, port=port, id=gid)
def _run_add_lun(self, ldev, port, gid, lun=None):
"""Create a LUN between the specified LDEV and port-gid."""
args = ['add', 'lun', '-port', '-'.join([port, gid]), '-ldev_id', ldev]
ignore_error = [_LU_PATH_DEFINED]
if lun:
args.extend(['-lun_id', lun])
ignore_error = [_ANOTHER_LDEV_MAPPED]
result = self.run_raidcom(
*args, ignore_error=ignore_error,
interval=_LUN_RETRY_INTERVAL, timeout=_LUN_MAX_WAITTIME)
if not lun:
if result[0] == EX_CMDRJE:
lun = self._find_lun(ldev, port, gid)
LOG.debug(
'A logical unit path has already been defined in the '
'specified logical device. (LDEV: %(ldev)s, '
'port: %(port)s, gid: %(gid)s, lun: %(lun)s)',
{'ldev': ldev, 'port': port, 'gid': gid, 'lun': lun})
else:
lun = find_value(result[1], 'lun')
elif _ANOTHER_LDEV_MAPPED in result[2]:
utils.output_log(MSG.MAP_LDEV_FAILED, ldev=ldev, port=port, id=gid,
lun=lun)
return None
LOG.debug(
'Created logical unit path to the specified logical device. '
'(LDEV: %(ldev)s, port: %(port)s, '
'gid: %(gid)s, lun: %(lun)s)',
{'ldev': ldev, 'port': port, 'gid': gid, 'lun': lun})
return lun
def map_ldev(self, targets, ldev):
"""Create the path between the server and the LDEV and return LUN."""
port, gid = targets['list'][0]
lun = self._run_add_lun(ldev, port, gid)
targets['lun'][port] = True
for port, gid in targets['list'][1:]:
try:
lun2 = self._run_add_lun(ldev, port, gid, lun=lun)
if lun2 is not None:
targets['lun'][port] = True
except exception.VSPError:
utils.output_log(MSG.MAP_LDEV_FAILED, ldev=ldev, port=port,
id=gid, lun=lun)
return lun
def extend_ldev(self, ldev, old_size, new_size):
"""Extend the specified LDEV to the specified new size."""
timeout = _EXTEND_WAITTIME
self.run_raidcom('extend', 'ldev', '-ldev_id', ldev, '-capacity',
'%sG' % (new_size - old_size), timeout=timeout)
def get_pool_info(self):
"""Return the total and free capacity of the storage pool."""
result = self.run_raidcom('get', 'dp_pool')
p_pool_match = self._pattern['p_pool'].search(result[1])
result = self.run_raidcom('get', 'pool', '-key', 'opt')
pool_match = self._pattern['pool'].search(result[1])
if not p_pool_match or not pool_match:
msg = utils.output_log(MSG.POOL_NOT_FOUND,
pool=self.storage_info['pool_id'])
raise exception.VSPError(msg)
tp_cap = float(p_pool_match.group('tp_cap')) / units.Ki
tl_cap = float(p_pool_match.group('tl_cap')) / units.Ki
vcap = 'infinite' if pool_match.group('vcap') == _INFINITE else (
int(pool_match.group('vcap')))
if vcap == 'infinite':
return 'unknown', 'unknown'
else:
total_gb = int(math.floor(tp_cap * (vcap / 100.0)))
free_gb = int(math.floor(total_gb - tl_cap))
return total_gb, free_gb
def discard_zero_page(self, volume):
"""Return the volume's no-data pages to the storage pool."""
ldev = utils.get_ldev(volume)
try:
self.run_raidcom(
'modify', 'ldev', '-ldev_id', ldev,
'-status', 'discard_zero_page')
except exception.VSPError:
utils.output_log(MSG.DISCARD_ZERO_PAGE_FAILED, ldev=ldev)
def wait_thin_copy(self, ldev, status, **kwargs):
"""Wait until the S-VOL status changes to the specified status."""
interval = kwargs.pop(
'interval', self.conf.vsp_copy_check_interval)
def _wait_for_thin_copy_status(start_time, ldev, status, **kwargs):
"""Raise True if the S-VOL is in the specified status."""
timeout = kwargs.pop('timeout', utils.DEFAULT_PROCESS_WAITTIME)
if self._get_thin_copy_svol_status(ldev) == status:
raise loopingcall.LoopingCallDone()
if utils.check_timeout(start_time, timeout):
raise loopingcall.LoopingCallDone(False)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_thin_copy_status, timeutils.utcnow(),
ldev, status, **kwargs)
if not loop.start(interval=interval).wait():
msg = utils.output_log(MSG.TI_PAIR_STATUS_WAIT_TIMEOUT, svol=ldev)
raise exception.VSPError(msg)
def _get_thin_copy_svol_status(self, ldev):
"""Return the status of the S-VOL in a THIN volume pair."""
result = self.run_raidcom(
'get', 'snapshot', '-ldev_id', ldev)
if not result[1]:
return SMPL
return _STATUS_TABLE.get(result[1].splitlines()[1].split()[2], UNKN)
def _create_horcm_conf(self, horcmgr=_HORCMGR):
"""Create a CCI configuration file."""
inst = self.conf.vsp_horcm_numbers[horcmgr]
serial = self.conf.vsp_storage_id
filename = '/etc/horcm%s.conf' % inst
port = _DEFAULT_PORT_BASE + inst
found = False
if not os.path.exists(filename):
file_str = """
HORCM_MON
#ip_address service poll(10ms) timeout(10ms)
127.0.0.1 %16d 6000 3000
HORCM_CMD
""" % port
else:
file_str = cinder_utils.read_file_as_root(filename)
if re.search(r'^\\\\.\\CMD-%s:/dev/sd$' % serial, file_str, re.M):
found = True
if not found:
repl_str = r'\1\\\\.\\CMD-%s:/dev/sd\n' % serial
file_str = CMD_PATTERN.sub(repl_str, file_str)
result = utils.execute('tee', filename, process_input=file_str)
if result[0]:
msg = utils.output_log(
MSG.CREATE_HORCM_CONF_FILE_FAILED, file=filename,
ret=result[0], err=result[2])
raise exception.VSPError(msg)
def init_cinder_hosts(self, **kwargs):
"""Initialize server-storage connection."""
targets = {
'info': {},
'list': [],
'iqns': {},
}
super(VSPHORCM, self).init_cinder_hosts(targets=targets)
if self.storage_info['pair_ports']:
targets['info'] = {}
ports = self._get_pair_ports()
for port in ports:
targets['info'][port] = True
self._init_pair_targets(targets['info'])
def _init_pair_targets(self, targets_info):
"""Initialize server-storage connection for volume copy."""
for port in targets_info.keys():
if not targets_info[port]:
continue
result = self.run_raidcom('get', 'host_grp', '-port', port)
gid = find_value(result[1], 'pair_gid')
if not gid:
try:
connector = {
'ip': _PAIR_TARGET_NAME_BODY,
'wwpns': [_PAIR_TARGET_NAME_BODY],
}
target_name, gid = self.create_target_to_storage(
port, connector, None)
utils.output_log(MSG.OBJECT_CREATED,
object='a target for pair operation',
details='port: %(port)s, gid: %(gid)s, '
'target_name: %(target)s' %
{'port': port, 'gid': gid,
'target': target_name})
except exception.VSPError:
utils.output_log(MSG.CREATE_HOST_GROUP_FAILED, port=port)
continue
self._pair_targets.append((port, gid))
if not self._pair_targets:
msg = utils.output_log(MSG.ADD_PAIR_TARGET_FAILED)
raise exception.VSPError(msg)
self._pair_targets.sort(reverse=True)
utils.output_log(MSG.SET_CONFIG_VALUE,
object='port-gid list for pair operation',
value=self._pair_targets)
@coordination.synchronized('{self.lock[create_ldev]}')
def delete_ldev_from_storage(self, ldev):
"""Delete the specified LDEV from the storage."""
self._delete_ldev_from_storage(ldev)
self._check_ldev_status(ldev, delete=True)
def _delete_ldev_from_storage(self, ldev):
"""Delete the specified LDEV from the storage."""
result = self.run_raidcom(
'get', 'ldev', '-ldev_id', ldev, *_LDEV_DELETED, do_raise=False)
if not result[0]:
utils.output_log(MSG.LDEV_NOT_EXIST, ldev=ldev)
return
self.run_raidcom('delete', 'ldev', '-ldev_id', ldev)
def _run_pairdisplay(self, *args):
"""Execute Shadow Image pairdisplay command."""
result = self._run_pair_cmd(
'pairdisplay', '-CLI', *args, do_raise=False,
success_code=HORCM_EXIT_CODE.union(_NO_SUCH_DEVICE))
return result[1]
def _check_copy_grp(self, copy_group):
"""Return the number of device groups in the specified copy group."""
count = 0
result = self.run_raidcom('get', 'copy_grp')
for line in result[1].splitlines()[1:]:
line = line.split()
if line[0] == copy_group:
count += 1
if count == 2:
break
return count
def _check_device_grp(self, group_name, ldev, ldev_name=None):
"""Return True if the LDEV is in the device group, False otherwise."""
result = self.run_raidcom(
'get', 'device_grp', '-device_grp_name', group_name)
for line in result[1].splitlines()[1:]:
line = line.split()
if int(line[2]) == ldev:
if not ldev_name:
return True
else:
return line[1] == ldev_name
return False
def _is_smpl(self, ldev):
"""Return True if the status of the LDEV is SMPL, False otherwise."""
stdout = self._run_pairdisplay(
'-d', self.conf.vsp_storage_id, ldev, 0)
if not stdout:
return True
return stdout.splitlines()[2].split()[9] in _SMPL_STAUS
def _get_full_copy_pair_info(self, ldev, mun):
"""Return info of the Shadow Image volume pair."""
stdout = self._run_pairdisplay(
'-d', self.conf.vsp_storage_id, ldev, mun)
if not stdout:
return None
line = stdout.splitlines()[2].split()
if not line[8].isdigit() or not line[12].isdigit():
return None
pvol, svol = int(line[12]), int(line[8])
LOG.debug(
'Full copy pair status. (P-VOL: %(pvol)s, S-VOL: %(svol)s, '
'status: %(status)s)',
{'pvol': pvol, 'svol': svol, 'status': line[10]})
return {
'pvol': pvol,
'svol_info': {
'ldev': svol,
'is_psus': line[10] == "SSUS",
'is_thin': False,
},
}
def _get_thin_copy_info(self, ldev):
"""Return info of the Thin Image volume pair."""
result = self.run_raidcom(
'get', 'snapshot', '-ldev_id', ldev)
if not result[1]:
return (None, None)
line = result[1].splitlines()[1].split()
is_psus = _STATUS_TABLE.get(line[2]) == PSUS
if line[1] == "P-VOL":
pvol, svol = ldev, int(line[6])
else:
pvol, svol = int(line[6]), ldev
LOG.debug(
'Thin copy pair status. (P-VOL: %(pvol)s, S-VOL: %(svol)s, '
'status: %(status)s)',
{'pvol': pvol, 'svol': svol, 'status': line[2]})
return (pvol, [{'ldev': svol, 'is_thin': True, 'is_psus': is_psus}])
def get_pair_info(self, ldev):
"""Return info of the volume pair."""
pair_info = {}
ldev_info = self.get_ldev_info(['sts', 'vol_attr'], '-ldev_id', ldev)
if ldev_info['sts'] != NORMAL_STS or _PAIR_ATTRS.isdisjoint(
ldev_info['vol_attr']):
return None
if FULL_ATTR in ldev_info['vol_attr']:
pvol, svol_info = self._get_full_copy_info(ldev)
# When 'pvol' is 0, it should be true.
# Therefore, it cannot remove 'is not None'.
if pvol is not None:
pair_info['pvol'] = pvol
pair_info.setdefault('svol_info', [])
pair_info['svol_info'].extend(svol_info)
if THIN_ATTR in ldev_info['vol_attr']:
pvol, svol_info = self._get_thin_copy_info(ldev)
# When 'pvol' is 0, it should be true.
# Therefore, it cannot remove 'is not None'.
if pvol is not None:
pair_info['pvol'] = pvol
pair_info.setdefault('svol_info', [])
pair_info['svol_info'].extend(svol_info)
return pair_info
def _get_pair_ports(self):
"""Return a list of ports used for volume pair management."""
return (self.storage_info['pair_ports'] or
self.storage_info['controller_ports'])
def _add_pair_config(self, pvol, svol, copy_group, ldev_name, mun):
"""Create device groups and a copy group for the SI volume pair."""
pvol_group = copy_group + 'P'
svol_group = copy_group + 'S'
self.run_raidcom(
'add', 'device_grp', '-device_grp_name',
pvol_group, ldev_name, '-ldev_id', pvol)
self.run_raidcom(
'add', 'device_grp', '-device_grp_name',
svol_group, ldev_name, '-ldev_id', svol)
nr_copy_groups = self._check_copy_grp(copy_group)
if nr_copy_groups == 1:
self.run_raidcom(
'delete', 'copy_grp', '-copy_grp_name', copy_group)
if nr_copy_groups != 2:
self.run_and_verify_storage_cli(
'raidcom', 'add', 'copy_grp', '-copy_grp_name',
copy_group, pvol_group, svol_group, '-mirror_id', mun,
'-s', self.conf.vsp_storage_id,
'-IM%s' % self.conf.vsp_horcm_numbers[_HORCMGR],
success_code=HORCM_EXIT_CODE)
def _delete_pair_config(self, pvol, svol, copy_group, ldev_name):
"""Delete specified LDEVs from Shadow Image device groups."""
pvol_group = copy_group + 'P'
svol_group = copy_group + 'S'
if self._check_device_grp(pvol_group, pvol, ldev_name=ldev_name):
self.run_raidcom(
'delete', 'device_grp', '-device_grp_name',
pvol_group, '-ldev_id', pvol)
if self._check_device_grp(svol_group, svol, ldev_name=ldev_name):
self.run_raidcom(
'delete', 'device_grp', '-device_grp_name',
svol_group, '-ldev_id', svol)
def _wait_full_copy(self, ldev, status, **kwargs):
"""Wait until the LDEV status changes to the specified status."""
interval = kwargs.pop(
'interval', self.conf.vsp_copy_check_interval)
def _wait_for_full_copy_pair_status(start_time, ldev,
status, **kwargs):
"""Raise True if the LDEV is in the specified status."""
timeout = kwargs.pop('timeout', utils.DEFAULT_PROCESS_WAITTIME)
if self._run_pairevtwait(ldev) in status:
raise loopingcall.LoopingCallDone()
if utils.check_timeout(start_time, timeout):
raise loopingcall.LoopingCallDone(False)
loop = loopingcall.FixedIntervalLoopingCall(
_wait_for_full_copy_pair_status, timeutils.utcnow(),
ldev, status, **kwargs)
if not loop.start(interval=interval).wait():
msg = utils.output_log(MSG.SI_PAIR_STATUS_WAIT_TIMEOUT, svol=ldev)
raise exception.VSPError(msg)
def wait_full_copy_completion(self, pvol, svol):
"""Wait until the Shadow Image volume copy has finished."""
self._wait_full_copy(svol, set([PSUS, PSUE]),
timeout=utils.MAX_PROCESS_WAITTIME)
if self._run_pairevtwait(svol) == PSUE:
msg = utils.output_log(MSG.VOLUME_COPY_FAILED,
copy_method=utils.FULL, pvol=pvol,
svol=svol)
raise exception.VSPError(msg)
def _run_pairevtwait(self, ldev):
"""Execute Shadow Image pairevtwait command."""
result = self._run_pair_cmd(
'pairevtwait', '-d', self.conf.vsp_storage_id,
ldev, '-nowaits')
return result[0]
def get_ldev_size_in_gigabyte(self, ldev, existing_ref):
"""Return the size[GB] of the specified LDEV."""
ldev_info = self.get_ldev_info(
_CHECK_KEYS, '-ldev_id', ldev, do_raise=False)
_check_ldev(ldev_info, ldev, existing_ref)
# Hitachi storage calculates volume sizes in a block unit, 512 bytes.
return ldev_info['vol_size'] / utils.GIGABYTE_PER_BLOCK_SIZE
def get_pool_id(self):
"""Return the pool number of vsp_pool."""
pool_id = super(VSPHORCM, self).get_pool_id()
if pool_id is None:
pool = self.conf.vsp_pool
result = self.run_raidcom('get', 'pool', '-key', 'opt')
for line in result[1].splitlines()[1:]:
line = line.split()
if line[3] == pool:
return int(line[0])
return pool_id
def config_lock(self):
"""Initialize lock resource names."""
for key in ['create_ldev', 'create_pair']:
self.lock[key] = '_'.join([key, self.conf.vsp_storage_id])
self.lock[_HORCMGR] = (
'horcmgr_%s' % self.conf.vsp_horcm_numbers[_HORCMGR])
self.lock[_PAIR_HORCMGR] = (
'horcmgr_%s' % self.conf.vsp_horcm_numbers[_PAIR_HORCMGR])
@horcmgr_synchronized
def _start_horcmgr(self, horcmgr):
"""Start the CCI instance and return True if successful."""
inst = self.conf.vsp_horcm_numbers[horcmgr]
ret = 0
if _run_horcmgr(inst) != _HORCM_RUNNING:
ret = _run_horcmstart(inst)
if ret and ret != _HORCM_RUNNING:
utils.output_log(MSG.HORCM_START_FAILED, inst=inst)
return False
return True
def output_param_to_log(self):
"""Output configuration parameter values to the log file."""
super(VSPHORCM, self).output_param_to_log()
utils.output_opts(self.conf, horcm_opts)
def get_storage_cli_info(self):
"""Return a tuple of the storage CLI name and its version."""
version = 'N/A'
result = utils.execute('raidqry', '-h')
match = re.search(r'^Ver&Rev: +(?P<version>\S+)', result[1], re.M)
if match:
version = match.group('version')
return ('Command Control Interface', version)
def check_vvol(self, ldev):
"""Return True if the specified LDEV is V-VOL, False otherwise."""
ldev_info = self.get_ldev_info(['sts', 'vol_attr'], '-ldev_id', ldev)
if ldev_info['sts'] != NORMAL_STS:
return False
return VVOL_ATTR in ldev_info['vol_attr']
| ge0rgi/cinder | cinder/volume/drivers/hitachi/vsp_horcm.py | Python | apache-2.0 | 56,982 |
#!/usr/bin/env python
#
# waCaptcha
# Copyright (C) 2012 Larroque Stephen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys, exceptions
def import_module(module_name):
''' Reliable import, courtesy of Armin Ronacher '''
try:
__import__(module_name)
except ImportError:
exc_type, exc_value, tb_root = sys.exc_info()
tb = tb_root
while tb is not None:
if tb.tb_frame.f_globals.get('__name__') == module_name:
raise exc_type, exc_value, tb_root
tb = tb.tb_next
return None
return sys.modules[module_name]
def str2int(s):
''' Convert a string to int '''
try:
return int(s)
except exceptions.ValueError:
return int(float(s))
import os, random
def fastRandLine(file, exceptlist=None, exceptposlist=None, maxit=100):
''' Clever random line picker, courtesy of Jonathan Kupferman
Enhanced to accept exceptions lists to avoid picking twice the same line we don't want
The exception list based on cursor position is a bit more optimized than the one based on string content comparison
'''
close_flag = False
if isinstance(file, str):
file = open(file,'r')
close_flag = True
#Get the total file size
#file_size = os.stat(filename)[6]
file_size = os.fstat(file.fileno()).st_size
# We use a loop in case we specified a list of exception (lines to NOT accept in the random pool)
flag = 1
it = 0
while flag:
#Seek to a place in the file which is a random distance away
#Mod by file size so that it wraps around to the beginning
file.seek((file.tell()+random.random()*(file_size-1))%file_size)
#dont use the first readline since it may fall in the middle of a line UNLESS we are at the beginning of the file
if file.tell() > 0:
file.readline()
# Get the current position (for the exception list based on cursor position)
curpos = file.tell()
# If we have specified a list of exception based on cursor position (faster than the exception list based on line comparison)
if exceptposlist and \
curpos in exceptposlist: # and if the current position is in the list of exceptions, we are not good!
flag = 1
# No exception list based on cursor position, OR the current cursor position is not in the list of exception, then we continue
else:
#this will return the next (complete) line from the file (the line we may want to return if not in exception list)
line = file.readline()
line = line.strip() # strip line endings, necessary for string comparison
# If we have a list of exceptions based on line content
if (exceptlist and \
line in exceptlist) or \
not line: # and if the line is found in this list, we are not good! (also if the line is empty, because we have tried to read last line + 1, we're not good!)
flag = 1
# Else, we have passed all the exceptions checks, we are OK!
else:
flag = 0 # end of loop
# Avoid infinite loop
it += 1
if it > maxit:
return None
if close_flag:
file.close()
#here is your random line in the file
return (line, curpos)
def call_it(instance, name, args=(), kwargs=None):
"indirect caller for instance methods and multiprocessing"
if kwargs is None:
kwargs = {}
return getattr(instance, name)(*args, **kwargs)
# Some debug testing here
if __name__ == '__main__':
print cacheListOfModels('models', 'modelscache.txt')
f = open('modelscache.txt', 'rb')
e1 = []
e2 = []
for i in xrange(20):
(line, cur) = fastRandLine(f, e1, e2)
e1.append(line)
e2.append(cur)
print line
f.close()
| lrq3000/waCaptcha | auxlib.py | Python | agpl-3.0 | 4,579 |
# Copyright 2015 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.
import botocore.session
def _get_client(client_name, url, region, access, secret, ca_bundle):
connection_data = {
'config_file': (None, 'AWS_CONFIG_FILE', None, None),
'region': ('region', 'BOTO_DEFAULT_REGION', region, None),
}
session = botocore.session.get_session(connection_data)
kwargs = {
'region_name': region,
'endpoint_url': url,
'aws_access_key_id': access,
'aws_secret_access_key': secret
}
if ca_bundle:
kwargs['verify'] = ca_bundle
return session.create_client(client_name, **kwargs)
def get_ec2_client(url, region, access, secret, ca_bundle=None):
return _get_client('ec2', url, region, access, secret, ca_bundle)
def get_s3_client(url, region, access, secret, ca_bundle=None):
return _get_client('s3', url, region, access, secret, ca_bundle)
| hayderimran7/ec2-api | ec2api/tests/functional/botocoreclient.py | Python | apache-2.0 | 1,492 |
"""OpenBMP File Consumer
Copyright (c) 2013-2016 Cisco Systems, Inc. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
.. moduleauthor:: Tim Evens <tievens@cisco.com>
"""
import logging.handlers
class RawTimedRotatingFileHandler(logging.handlers.TimedRotatingFileHandler):
"""
Modified logging.handlers.TimedRotatingFileHandler to add support for
binary/raw logging.
"""
def emit(self, record):
"""
Emit a record.
Output the record to the file, catering for rollover as described
in doRollover().
"""
try:
if self.shouldRollover(record):
self.doRollover()
# override logging.FileHandler.emit() and logging.StreamHandler.emit()
if self.stream is None:
self.stream = self._open()
stream = self.stream
# write message as is, no formatting and no newline
stream.write(record.getMessage())
except (KeyboardInterrupt, SystemExit):
raise
except:
self.handleError(record)
def computeRollover(self, currentTime):
"""
Work out the rollover time based on the specified time.
Original is from logging.handlers source. This change ensures
that the rollover time is on an internal block instead of interval
plus the current_timestamp. For example, 01, 06, 11, ... becomes
05, 10, 15, ...
"""
# Adjust the current time to ensure it's at a correct block of time.
# original --> result = currentTime + self.interval
result = ((currentTime / self.interval) * self.interval) + self.interval
# If we are rolling over at midnight or weekly, then the interval is already known.
# What we need to figure out is WHEN the next interval is. In other words,
# if you are rolling over at midnight, then your base interval is 1 day,
# but you want to start that one day clock at midnight, not now. So, we
# have to fudge the rolloverAt value in order to trigger the first rollover
# at the right time. After that, the regular interval will take care of
# the rest. Note that this code doesn't care about leap seconds. :)
if self.when == 'MIDNIGHT' or self.when.startswith('W'):
# This could be done with less code, but I wanted it to be clear
if self.utc:
t = time.gmtime(currentTime)
else:
t = time.localtime(currentTime)
currentHour = t[3]
currentMinute = t[4]
currentSecond = t[5]
# r is the number of seconds left between now and midnight
r = _MIDNIGHT - ((currentHour * 60 + currentMinute) * 60 +
currentSecond)
result = currentTime + r
# If we are rolling over on a certain day, add in the number of days until
# the next rollover, but offset by 1 since we just calculated the time
# until the next day starts. There are three cases:
# Case 1) The day to rollover is today; in this case, do nothing
# Case 2) The day to rollover is further in the interval (i.e., today is
# day 2 (Wednesday) and rollover is on day 6 (Sunday). Days to
# next rollover is simply 6 - 2 - 1, or 3.
# Case 3) The day to rollover is behind us in the interval (i.e., today
# is day 5 (Saturday) and rollover is on day 3 (Thursday).
# Days to rollover is 6 - 5 + 3, or 4. In this case, it's the
# number of days left in the current week (1) plus the number
# of days in the next week until the rollover day (3).
# The calculations described in 2) and 3) above need to have a day added.
# This is because the above time calculation takes us to midnight on this
# day, i.e. the start of the next day.
if self.when.startswith('W'):
day = t[6] # 0 is Monday
if day != self.dayOfWeek:
if day < self.dayOfWeek:
daysToWait = self.dayOfWeek - day
else:
daysToWait = 6 - day + self.dayOfWeek + 1
newRolloverAt = result + (daysToWait * (60 * 60 * 24))
if not self.utc:
dstNow = t[-1]
dstAtRollover = time.localtime(newRolloverAt)[-1]
if dstNow != dstAtRollover:
if not dstNow: # DST kicks in before next rollover, so we need to deduct an hour
addend = -3600
else: # DST bows out before next rollover, so we need to add an hour
addend = 3600
newRolloverAt += addend
result = newRolloverAt
return result
| OpenBMP/openbmp-file-consumer | src/site-packages/openbmp/file/RawTimedRotatingFileHandler.py | Python | epl-1.0 | 5,283 |
#!/usr/bin/env python
import sys
import xbmc
#enable localization
getLS = sys.modules[ "__main__" ].__language__
class logging:
@staticmethod
def dbg( msg ):
xbmc.output( "LibraryManager: "+msg.encode('utf-8'), xbmc.LOGDEBUG )
@staticmethod
def err( msg ):
xbmc.output( "LibraryManager: "+msg.encode('utf-8'), xbmc.LOGERROR )
| albertfc/XBMC-Library-Manager | resources/lib/logging.py | Python | gpl-3.0 | 367 |
# Calc command.
from distutils.version import LooseVersion
import logging
import click
import snuggs
from cligj import files_inout_arg
from .helpers import resolve_inout
from . import options
import rasterio
from rasterio.fill import fillnodata
from rasterio.features import sieve
def get_bands(inputs, d, i=None):
"""Get a rasterio.Band object from calc's inputs"""
path = inputs[d] if d in dict(inputs) else inputs[int(d) - 1][1]
src = rasterio.open(path)
return (rasterio.band(src, i) if i else
[rasterio.band(src, j) for j in src.indexes])
def read_array(ix, subix=None, dtype=None):
"""Change the type of a read array"""
arr = snuggs._ctx.lookup(ix, subix)
if dtype:
arr = arr.astype(dtype)
return arr
@click.command(short_help="Raster data calculator.")
@click.argument('command')
@files_inout_arg
@options.output_opt
@click.option('--name', multiple=True,
help='Specify an input file with a unique short (alphas only) '
'name for use in commands like '
'"a=tests/data/RGB.byte.tif".')
@options.dtype_opt
@options.masked_opt
@options.force_overwrite_opt
@options.creation_options
@click.pass_context
def calc(ctx, command, files, output, name, dtype, masked, force_overwrite,
creation_options):
"""A raster data calculator
Evaluates an expression using input datasets and writes the result
to a new dataset.
Command syntax is lisp-like. An expression consists of an operator
or function name and one or more strings, numbers, or expressions
enclosed in parentheses. Functions include ``read`` (gets a raster
array) and ``asarray`` (makes a 3-D array from 2-D arrays).
\b
* (read i) evaluates to the i-th input dataset (a 3-D array).
* (read i j) evaluates to the j-th band of the i-th dataset (a 2-D
array).
* (take foo j) evaluates to the j-th band of a dataset named foo (see
help on the --name option above).
* Standard numpy array operators (+, -, *, /) are available.
* When the final result is a list of arrays, a multi band output
file is written.
* When the final result is a single array, a single band output
file is written.
Example:
\b
$ rio calc "(+ 2 (* 0.95 (read 1)))" tests/data/RGB.byte.tif \\
> /tmp/out.tif
Produces a 3-band GeoTIFF with all values scaled by 0.95 and
incremented by 2.
\b
$ rio calc "(asarray (+ 125 (read 1)) (read 1) (read 1))" \\
> tests/data/shade.tif /tmp/out.tif
Produces a 3-band RGB GeoTIFF, with red levels incremented by 125,
from the single-band input.
"""
import numpy as np
verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
try:
with rasterio.Env(CPL_DEBUG=verbosity > 2):
output, files = resolve_inout(files=files, output=output,
force_overwrite=force_overwrite)
inputs = ([tuple(n.split('=')) for n in name] +
[(None, n) for n in files])
with rasterio.open(inputs[0][1]) as first:
kwargs = first.meta
kwargs.update(**creation_options)
kwargs['transform'] = kwargs.pop('affine')
dtype = dtype or first.meta['dtype']
kwargs['dtype'] = dtype
ctxkwds = {}
for i, (name, path) in enumerate(inputs):
with rasterio.open(path) as src:
# Using the class method instead of instance
# method. Latter raises
#
# TypeError: astype() got an unexpected keyword
# argument 'copy'
#
# possibly something to do with the instance being
# a masked array.
ctxkwds[name or '_i%d' % (i + 1)] = src.read(masked=masked)
# Extend snuggs.
snuggs.func_map['read'] = read_array
snuggs.func_map['band'] = lambda d, i: get_bands(inputs, d, i)
snuggs.func_map['bands'] = lambda d: get_bands(inputs, d)
snuggs.func_map['fillnodata'] = lambda *args: fillnodata(*args)
snuggs.func_map['sieve'] = lambda *args: sieve(*args)
res = snuggs.eval(command, **ctxkwds)
if (isinstance(res, np.ma.core.MaskedArray) and (
tuple(LooseVersion(np.__version__).version) < (1, 9) or
tuple(LooseVersion(np.__version__).version) > (1, 10))):
res = res.filled(kwargs['nodata'])
if len(res.shape) == 3:
results = np.ndarray.astype(res, dtype, copy=False)
else:
results = np.asanyarray(
[np.ndarray.astype(res, dtype, copy=False)])
kwargs['count'] = results.shape[0]
with rasterio.open(output, 'w', **kwargs) as dst:
dst.write(results)
except snuggs.ExpressionError as err:
click.echo("Expression Error:")
click.echo(' %s' % err.text)
click.echo(' ' + ' ' * err.offset + "^")
click.echo(err)
raise click.Abort()
| kapadia/rasterio | rasterio/rio/calc.py | Python | bsd-3-clause | 5,282 |
########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. 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 dsl_parser import (constants,
models)
from dsl_parser.elements import (imports,
misc,
plugins,
node_types,
node_templates,
relationships,
workflows,
policies,
data_types,
version as _version)
from dsl_parser.framework.elements import Element
from dsl_parser.framework.requirements import Value
class BlueprintVersionExtractor(Element):
schema = {
'tosca_definitions_version': _version.ToscaDefinitionsVersion,
# here so it gets version validated
'dsl_definitions': misc.DSLDefinitions,
}
requires = {
_version.ToscaDefinitionsVersion: ['version',
Value('plan_version')]
}
def parse(self, version, plan_version):
return {
'version': version,
'plan_version': plan_version
}
class BlueprintImporter(Element):
schema = {
'imports': imports.ImportsLoader,
}
requires = {
imports.ImportsLoader: ['resource_base']
}
def parse(self, resource_base):
return {
'merged_blueprint': self.child(imports.ImportsLoader).value,
'resource_base': resource_base
}
class Blueprint(Element):
schema = {
'tosca_definitions_version': _version.ToscaDefinitionsVersion,
'description': misc.Description,
'imports': imports.Imports,
'dsl_definitions': misc.DSLDefinitions,
'inputs': misc.Inputs,
'plugins': plugins.Plugins,
'node_types': node_types.NodeTypes,
'relationships': relationships.Relationships,
'node_templates': node_templates.NodeTemplates,
'policy_types': policies.PolicyTypes,
'policy_triggers': policies.PolicyTriggers,
'groups': policies.Groups,
'workflows': workflows.Workflows,
'outputs': misc.Outputs,
'data_types': data_types.DataTypes
}
requires = {
node_templates.NodeTemplates: ['deployment_plugins_to_install'],
workflows.Workflows: ['workflow_plugins_to_install']
}
def parse(self, workflow_plugins_to_install,
deployment_plugins_to_install):
return models.Plan({
constants.DESCRIPTION: self.child(misc.Description).value,
constants.NODES: self.child(node_templates.NodeTemplates).value,
constants.RELATIONSHIPS: self.child(
relationships.Relationships).value,
constants.WORKFLOWS: self.child(workflows.Workflows).value,
constants.POLICY_TYPES: self.child(policies.PolicyTypes).value,
constants.POLICY_TRIGGERS:
self.child(policies.PolicyTriggers).value,
constants.GROUPS: self.child(policies.Groups).value,
constants.INPUTS: self.child(misc.Inputs).value,
constants.OUTPUTS: self.child(misc.Outputs).value,
constants.DEPLOYMENT_PLUGINS_TO_INSTALL:
deployment_plugins_to_install,
constants.WORKFLOW_PLUGINS_TO_INSTALL: workflow_plugins_to_install,
constants.VERSION: self.child(
_version.ToscaDefinitionsVersion).value
})
| codilime/cloudify-dsl-parser | dsl_parser/elements/blueprint.py | Python | apache-2.0 | 4,108 |
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 02 17:43:52 2015
@author: okada
$Id: qc.py 205 2017-08-08 06:25:59Z aokada $
"""
########### js template
js_header = """(function() {
qc_data = {};
"""
js_footer = """
})();
Object.freeze(qc_data);
"""
js_dataset = """
qc_data.Ids = [{IDs}];
qc_data.plots = [{plots}];
qc_data.header = [{header}];
"""
plot_template = "{{chart_id:'{chart_id}', title:'{title}', title_y:'{title_y}', stack:{stack}, stack_id:[{stack_id}], label:[{label}], color:[{color}], tooltip:{tooltip}}},"
js_data1 = "qc_data.value = ["
js_data2 = "];"
########### html template
html_chart_template = "<div id='legend_{chart_id}_svg'></div><div id='{chart_id}'></div>\n"
html_js_template = """
qc_draw.add_div('{chart_id}');
qc_draw.divs[{i}].obj.bar_selected = function(key, on) {{ qc_draw.chart_selected(key, on); }}
"""
html_js_brushed_template = """
qc_draw.divs[{i}].obj.brushed = function(data, range) {{ qc_draw.chart_brushed(data, range); }}
"""
########### functions
def output_html(output_di, positions, config):
data = convert_tojs(output_di["dir"] + "/" + output_di["data"], output_di["dir"] + "/" + output_di["js"], positions, config)
if data != None:
create_html(data, output_di, config)
return True
return False
def convert_tojs(input_file, output_file, positions, config):
import os
import paplot.subcode.data_frame as data_frame
import paplot.subcode.merge as merge
import paplot.subcode.tools as tools
import paplot.convert as convert
import paplot.color as color
cols_di = merge.position_to_dict(positions)
# data read
try:
df = data_frame.load_file(input_file, header = 1, \
sept = tools.config_getstr(config, "result_format_qc", "sept"), \
comment = tools.config_getstr(config, "result_format_qc", "comment") \
)
except Exception as e:
print ("failure open data %s, %s" % (input_file, e.message))
return None
if len(df.data) == 0:
print ("no data %s" % input_file)
return None
# chart list
plots_text = ""
plots_option = []
config_sections = config.sections()
config_sections.sort()
if "qc_chart_brush" in config_sections:
config_sections.remove("qc_chart_brush")
config_sections.insert(0, "qc_chart_brush")
for sec in config.sections():
if not sec.startswith("qc_chart_"):
continue
chart_id = sec.replace("qc_chart_", "chart_")
stack_id = []
label = []
colors_di = {}
counter = 0
for name_set in tools.config_getstr(config, sec, "name_set").split(","):
name_set_split = convert.text_to_list(name_set, ":")
if len(name_set_split) == 0:
continue
stack_id.append("stack" + str(counter))
label.append(name_set_split[0])
if len(name_set_split) > 1:
colors_di[name_set_split[0]] = color.name_to_value(name_set_split[1])
counter += 1
# fill in undefined items
colors_di = color.create_color_dict(label, colors_di, color.metro_colors)
# dict to value
colors_li = []
for key in label:
colors_li.append(colors_di[key])
plots_text += plot_template.format(
chart_id = chart_id, \
title = tools.config_getstr(config, sec, "title"), \
title_y = tools.config_getstr(config, sec, "title_y"), \
stack = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "stack"), \
stack_id = convert.list_to_text(stack_id), \
label = convert.list_to_text(label), \
color = convert.list_to_text(colors_li), \
tooltip = convert.pyformat_to_jstooltip_text(cols_di, config, sec, "result_format_qc", "tooltip_format"), \
)
plots_option.append(chart_id)
# ID list
id_list = []
for row in df.data:
iid = row[df.name_to_index(cols_di["id"])]
if iid != "": id_list.append(iid)
id_list = list(set(id_list))
id_list.sort()
# header
headers = tools.dict_keys(cols_di)
f = open(output_file, "w")
f.write(js_header)
f.write(js_dataset.format(IDs = convert.list_to_text(id_list), \
header = convert.list_to_text(headers), \
plots = plots_text))
f.write(js_data1)
# values
for row in df.data:
iid = row[df.name_to_index(cols_di["id"])]
if iid == "": continue
values = ""
for item in headers:
if len(values) > 0:
values += ","
val = row[df.name_to_index(cols_di[item])]
if type(val) == type(""):
values += "'" + val + "'"
elif type(val) == type(0.0):
values += str('%.2f' % val)
else:
values += str(val)
f.write("[" + values + "],")
f.write(js_data2)
f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/data_qc.js")
js_function = f_template.read()
f_template.close()
f.write(js_function)
f.write(js_footer)
f.close()
return {"plots": plots_option}
def create_html(dataset, output_di, config):
import paplot.subcode.tools as tools
import paplot.prep as prep
import os
chart_txt = ""
js_txt = ""
for i in range(len(dataset["plots"])):
js_txt += html_js_template.format(i = str(i), chart_id = dataset["plots"][i])
if dataset["plots"][i] == "chart_brush":
chart_txt += '<p class="muted pull-left" style="margin-right: 15px;">Select a range to zoom in</p>\n'
js_txt += html_js_brushed_template.format(i = str(i))
chart_txt += html_chart_template.format(chart_id = dataset["plots"][i])
f_template = open(os.path.dirname(os.path.abspath(__file__)) + "/templates/graph_qc.html")
html_template = f_template.read()
f_template.close()
f_html = open(output_di["dir"] + "/" + output_di["html"], "w")
f_html.write(
html_template.format(project = output_di["project"],
title = output_di["title"],
data_js = output_di["js"],
version = prep.version_text(),
date = tools.now_string(),
charts = chart_txt,
js_add_div = js_txt,
style = "../style/%s" % os.path.basename(tools.config_getpath(config, "style", "path", "default.js")),
))
f_html.close()
| Genomon-Project/paplot | scripts/paplot/qc.py | Python | mit | 6,736 |
# Copyright (c) 2009-2010 Arista Networks, Inc. - James Lingard
# Copyright (c) 2004-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Checker for string formatting operations.
"""
import string
from logilab import astng
from pylint.interfaces import IASTNGChecker
from pylint.checkers import BaseChecker
MSGS = {
'E9900': ("Unsupported format character %r (%#02x) at index %d",
"Used when a unsupported format character is used in a format\
string."),
'E9901': ("Format string ends in middle of conversion specifier",
"Used when a format string terminates before the end of a \
conversion specifier."),
'E9902': ("Mixing named and unnamed conversion specifiers in format string",
"Used when a format string contains both named (e.g. '%(foo)d') \
and unnamed (e.g. '%d') conversion specifiers. This is also \
used when a named conversion specifier contains * for the \
minimum field width and/or precision."),
'E9903': ("Expected mapping for format string, not %s",
"Used when a format string that uses named conversion specifiers \
is used with an argument that is not a mapping."),
'W9900': ("Format string dictionary key should be a string, not %s",
"Used when a format string that uses named conversion specifiers \
is used with a dictionary whose keys are not all strings."),
'W9901': ("Unused key %r in format string dictionary",
"Used when a format string that uses named conversion specifiers \
is used with a dictionary that conWtains keys not required by the \
format string."),
'E9904': ("Missing key %r in format string dictionary",
"Used when a format string that uses named conversion specifiers \
is used with a dictionary that doesn't contain all the keys \
required by the format string."),
'E9905': ("Too many arguments for format string",
"Used when a format string that uses unnamed conversion \
specifiers is given too few arguments."),
'E9906': ("Not enough arguments for format string",
"Used when a format string that uses unnamed conversion \
specifiers is given too many arguments"),
}
class IncompleteFormatStringException(Exception):
"""A format string ended in the middle of a format specifier."""
pass
class UnsupportedFormatCharacterException(Exception):
"""A format character in a format string is not one of the supported
format characters."""
def __init__(self, index):
Exception.__init__(self, index)
self.index = index
def parse_format_string(format_string):
"""Parses a format string, returning a tuple of (keys, num_args), where keys
is the set of mapping keys in the format string, and num_args is the number
of arguments required by the format string. Raises
IncompleteFormatStringException or UnsupportedFormatCharacterException if a
parse error occurs."""
keys = set()
num_args = 0
def next_char(i):
i += 1
if i == len(format_string):
raise IncompleteFormatStringException
return (i, format_string[i])
i = 0
while i < len(format_string):
c = format_string[i]
if c == '%':
i, c = next_char(i)
# Parse the mapping key (optional).
key = None
if c == '(':
depth = 1
i, c = next_char(i)
key_start = i
while depth != 0:
if c == '(':
depth += 1
elif c == ')':
depth -= 1
i, c = next_char(i)
key_end = i - 1
key = format_string[key_start:key_end]
# Parse the conversion flags (optional).
while c in '#0- +':
i, c = next_char(i)
# Parse the minimum field width (optional).
if c == '*':
num_args += 1
i, c = next_char(i)
else:
while c in string.digits:
i, c = next_char(i)
# Parse the precision (optional).
if c == '.':
i, c = next_char(i)
if c == '*':
num_args += 1
i, c = next_char(i)
else:
while c in string.digits:
i, c = next_char(i)
# Parse the length modifier (optional).
if c in 'hlL':
i, c = next_char(i)
# Parse the conversion type (mandatory).
if c not in 'diouxXeEfFgGcrs%':
raise UnsupportedFormatCharacterException(i)
if key:
keys.add(key)
elif c != '%':
num_args += 1
i += 1
return keys, num_args
class StringFormatChecker(BaseChecker):
"""Checks string formatting operations to ensure that the format string
is valid and the arguments match the format string.
"""
__implements__ = (IASTNGChecker,)
name = 'string_format'
msgs = MSGS
def visit_binop(self, node):
if node.op != '%':
return
f = node.left
args = node.right
if isinstance(f, astng.Const) and isinstance(f.value, basestring):
format_string = f.value
try:
required_keys, required_num_args = \
parse_format_string(format_string)
except UnsupportedFormatCharacterException, e:
c = format_string[e.index]
self.add_message('E9900', node=node, args=(c, ord(c), e.index))
except IncompleteFormatStringException:
self.add_message('E9901', node=node)
else:
if required_keys and required_num_args:
# The format string uses both named and unnamed format
# specifiers.
self.add_message('E9902', node=node)
elif required_keys:
# The format string uses only named format specifiers.
# Check that the RHS of the % operator is a mapping object
# that contains precisely the set of keys required by the
# format string.
if isinstance(args, astng.Dict):
keys = set()
unknown_keys = False
for k, v in args.items:
if isinstance(k, astng.Const):
key = k.value
if isinstance(key, basestring):
keys.add(key)
else:
self.add_message('W9900',
node=node,
args=key)
else:
# One of the keys was something other than a
# constant. Since we can't tell what it is,
# supress checks for missing keys in the
# dictionary.
unknown_keys = True
if not unknown_keys:
for key in required_keys:
if key not in keys:
self.add_message('E9904',
node=node,
args=key)
for key in keys:
if key not in required_keys:
self.add_message('W9901', node=node, args=key)
elif (isinstance(args, astng.Const) or
isinstance(args, astng.Tuple) or
isinstance(args, astng.List) or
isinstance(args, astng.ListComp) or
isinstance(args, astng.GenExpr) or
isinstance(args, astng.Backquote) or
isinstance(args, astng.Lambda)):
type_name = type(args).__name__
self.add_message('E9903', node=node, args=type_name)
else:
# The RHS of the format specifier is a name or
# expression. It may be a mapping object, so
# there's nothing we can check.
pass
else:
# The format string uses only unnamed format specifiers.
# Check that the number of arguments passed to the RHS of
# the % operator matches the number required by the format
# string.
if isinstance(args, astng.Tuple):
num_args = len(args.elts)
elif (isinstance(args, astng.Const) or
isinstance(args, astng.Dict) or
isinstance(args, astng.List) or
isinstance(args, astng.ListComp) or
isinstance(args, astng.GenExpr) or
isinstance(args, astng.Backquote) or
isinstance(args, astng.Lambda) or
isinstance(args, astng.Function)):
num_args = 1
else:
# The RHS of the format specifier is a name or
# expression. It could be a tuple of unknown size, so
# there's nothing we can check.
num_args = None
if num_args is not None:
if num_args > required_num_args:
self.add_message('E9905', node=node)
elif num_args < required_num_args:
self.add_message('E9906', node=node)
def register(linter):
"""required method to auto register this checker """
linter.register_checker(StringFormatChecker(linter))
| dbbhattacharya/kitsune | vendor/packages/pylint/checkers/string_format.py | Python | bsd-3-clause | 11,146 |
"""
=========================================================
Hashing feature transformation using Totally Random Trees
=========================================================
RandomTreesEmbedding provides a way to map data to a
very high-dimensional, sparse representation, which might
be beneficial for classification.
The mapping is completely unsupervised and very efficient.
This example visualizes the partitions given by several
trees and shows how the transformation can also be used for
non-linear dimensionality reduction or non-linear classification.
Points that are neighboring often share the same leaf of a tree and therefore
share large parts of their hashed representation. This allows to
separate two concentric circles simply based on the principal components of the
transformed data.
In high-dimensional spaces, linear classifiers often achieve
excellent accuracy. For sparse binary data, BernoulliNB
is particularly well-suited. The bottom row compares the
decision boundary obtained by BernoulliNB in the transformed
space with an ExtraTreesClassifier forests learned on the
original data.
"""
import matplotlib.pyplot as plt
import numpy as np
from sklearn.datasets import make_circles
from sklearn.decomposition import TruncatedSVD
from sklearn.ensemble import RandomTreesEmbedding, ExtraTreesClassifier
from sklearn.naive_bayes import BernoulliNB
# make a synthetic dataset
X, y = make_circles(factor=0.5, random_state=0, noise=0.05)
# use RandomTreesEmbedding to transform data
hasher = RandomTreesEmbedding(n_estimators=10, random_state=0, max_depth=3)
X_transformed = hasher.fit_transform(X)
# Visualize result using PCA
pca = TruncatedSVD(n_components=2)
X_reduced = pca.fit_transform(X_transformed)
# Learn a Naive Bayes classifier on the transformed data
nb = BernoulliNB()
nb.fit(X_transformed, y)
# Learn an ExtraTreesClassifier for comparison
trees = ExtraTreesClassifier(max_depth=3, n_estimators=10, random_state=0)
trees.fit(X, y)
# scatter plot of original and reduced data
fig = plt.figure(figsize=(9, 8))
ax = plt.subplot(221)
ax.scatter(X[:, 0], X[:, 1], c=y, s=50)
ax.set_title("Original Data (2d)")
ax.set_xticks(())
ax.set_yticks(())
ax = plt.subplot(222)
ax.scatter(X_reduced[:, 0], X_reduced[:, 1], c=y, s=50)
ax.set_title("PCA reduction (2d) of transformed data (%dd)" %
X_transformed.shape[1])
ax.set_xticks(())
ax.set_yticks(())
# Plot the decision in original space. For that, we will assign a color to each
# point in the mesh [x_min, m_max] x [y_min, y_max].
h = .01
x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
# transform grid using RandomTreesEmbedding
transformed_grid = hasher.transform(np.c_[xx.ravel(), yy.ravel()])
y_grid_pred = nb.predict_proba(transformed_grid)[:, 1]
ax = plt.subplot(223)
ax.set_title("Naive Bayes on Transformed data")
ax.pcolormesh(xx, yy, y_grid_pred.reshape(xx.shape))
ax.scatter(X[:, 0], X[:, 1], c=y, s=50)
ax.set_ylim(-1.4, 1.4)
ax.set_xlim(-1.4, 1.4)
ax.set_xticks(())
ax.set_yticks(())
# transform grid using ExtraTreesClassifier
y_grid_pred = trees.predict_proba(np.c_[xx.ravel(), yy.ravel()])[:, 1]
ax = plt.subplot(224)
ax.set_title("ExtraTrees predictions")
ax.pcolormesh(xx, yy, y_grid_pred.reshape(xx.shape))
ax.scatter(X[:, 0], X[:, 1], c=y, s=50)
ax.set_ylim(-1.4, 1.4)
ax.set_xlim(-1.4, 1.4)
ax.set_xticks(())
ax.set_yticks(())
plt.tight_layout()
plt.show()
| DailyActie/Surrogate-Model | 01-codes/scikit-learn-master/examples/ensemble/plot_random_forest_embedding.py | Python | mit | 3,528 |
"""Support for Dark Sky weather service."""
import logging
from datetime import timedelta
import voluptuous as vol
from requests.exceptions import (
ConnectionError as ConnectError, HTTPError, Timeout)
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
ATTR_ATTRIBUTION, CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE,
CONF_MONITORED_CONDITIONS, CONF_NAME, UNIT_UV_INDEX, CONF_SCAN_INTERVAL)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
_LOGGER = logging.getLogger(__name__)
ATTRIBUTION = "Powered by Dark Sky"
CONF_FORECAST = 'forecast'
CONF_HOURLY_FORECAST = 'hourly_forecast'
CONF_LANGUAGE = 'language'
CONF_UNITS = 'units'
DEFAULT_LANGUAGE = 'en'
DEFAULT_NAME = 'Dark Sky'
SCAN_INTERVAL = timedelta(seconds=300)
DEPRECATED_SENSOR_TYPES = {
'apparent_temperature_max',
'apparent_temperature_min',
'temperature_max',
'temperature_min',
}
# Sensor types are defined like so:
# Name, si unit, us unit, ca unit, uk unit, uk2 unit
SENSOR_TYPES = {
'summary': ['Summary', None, None, None, None, None, None,
['currently', 'hourly', 'daily']],
'minutely_summary': ['Minutely Summary',
None, None, None, None, None, None, []],
'hourly_summary': ['Hourly Summary', None, None, None, None, None, None,
[]],
'daily_summary': ['Daily Summary', None, None, None, None, None, None, []],
'icon': ['Icon', None, None, None, None, None, None,
['currently', 'hourly', 'daily']],
'nearest_storm_distance': ['Nearest Storm Distance',
'km', 'mi', 'km', 'km', 'mi',
'mdi:weather-lightning', ['currently']],
'nearest_storm_bearing': ['Nearest Storm Bearing',
'°', '°', '°', '°', '°',
'mdi:weather-lightning', ['currently']],
'precip_type': ['Precip', None, None, None, None, None,
'mdi:weather-pouring',
['currently', 'minutely', 'hourly', 'daily']],
'precip_intensity': ['Precip Intensity',
'mm/h', 'in', 'mm/h', 'mm/h', 'mm/h',
'mdi:weather-rainy',
['currently', 'minutely', 'hourly', 'daily']],
'precip_probability': ['Precip Probability',
'%', '%', '%', '%', '%', 'mdi:water-percent',
['currently', 'minutely', 'hourly', 'daily']],
'precip_accumulation': ['Precip Accumulation',
'cm', 'in', 'cm', 'cm', 'cm', 'mdi:weather-snowy',
['hourly', 'daily']],
'temperature': ['Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['currently', 'hourly']],
'apparent_temperature': ['Apparent Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['currently', 'hourly']],
'dew_point': ['Dew Point', '°C', '°F', '°C', '°C', '°C',
'mdi:thermometer', ['currently', 'hourly', 'daily']],
'wind_speed': ['Wind Speed', 'm/s', 'mph', 'km/h', 'mph', 'mph',
'mdi:weather-windy', ['currently', 'hourly', 'daily']],
'wind_bearing': ['Wind Bearing', '°', '°', '°', '°', '°', 'mdi:compass',
['currently', 'hourly', 'daily']],
'wind_gust': ['Wind Gust', 'm/s', 'mph', 'km/h', 'mph', 'mph',
'mdi:weather-windy-variant',
['currently', 'hourly', 'daily']],
'cloud_cover': ['Cloud Coverage', '%', '%', '%', '%', '%',
'mdi:weather-partlycloudy',
['currently', 'hourly', 'daily']],
'humidity': ['Humidity', '%', '%', '%', '%', '%', 'mdi:water-percent',
['currently', 'hourly', 'daily']],
'pressure': ['Pressure', 'mbar', 'mbar', 'mbar', 'mbar', 'mbar',
'mdi:gauge', ['currently', 'hourly', 'daily']],
'visibility': ['Visibility', 'km', 'mi', 'km', 'km', 'mi', 'mdi:eye',
['currently', 'hourly', 'daily']],
'ozone': ['Ozone', 'DU', 'DU', 'DU', 'DU', 'DU', 'mdi:eye',
['currently', 'hourly', 'daily']],
'apparent_temperature_max': ['Daily High Apparent Temperature',
'°C', '°F', '°C', '°C', '°C',
'mdi:thermometer', ['daily']],
'apparent_temperature_high': ["Daytime High Apparent Temperature",
'°C', '°F', '°C', '°C', '°C',
'mdi:thermometer', ['daily']],
'apparent_temperature_min': ['Daily Low Apparent Temperature',
'°C', '°F', '°C', '°C', '°C',
'mdi:thermometer', ['daily']],
'apparent_temperature_low': ['Overnight Low Apparent Temperature',
'°C', '°F', '°C', '°C', '°C',
'mdi:thermometer', ['daily']],
'temperature_max': ['Daily High Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['daily']],
'temperature_high': ['Daytime High Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['daily']],
'temperature_min': ['Daily Low Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['daily']],
'temperature_low': ['Overnight Low Temperature',
'°C', '°F', '°C', '°C', '°C', 'mdi:thermometer',
['daily']],
'precip_intensity_max': ['Daily Max Precip Intensity',
'mm/h', 'in', 'mm/h', 'mm/h', 'mm/h',
'mdi:thermometer', ['daily']],
'uv_index': ['UV Index',
UNIT_UV_INDEX, UNIT_UV_INDEX, UNIT_UV_INDEX,
UNIT_UV_INDEX, UNIT_UV_INDEX, 'mdi:weather-sunny',
['currently', 'hourly', 'daily']],
'moon_phase': ['Moon Phase', None, None, None, None, None,
'mdi:weather-night', ['daily']],
'sunrise_time': ['Sunrise', None, None, None, None, None,
'mdi:white-balance-sunny', ['daily']],
'sunset_time': ['Sunset', None, None, None, None, None,
'mdi:weather-night', ['daily']],
'alerts': ['Alerts', None, None, None, None, None,
'mdi:alert-circle-outline', []]
}
CONDITION_PICTURES = {
'clear-day': ['/static/images/darksky/weather-sunny.svg',
'mdi:weather-sunny'],
'clear-night': ['/static/images/darksky/weather-night.svg',
'mdi:weather-sunny'],
'rain': ['/static/images/darksky/weather-pouring.svg',
'mdi:weather-pouring'],
'snow': ['/static/images/darksky/weather-snowy.svg',
'mdi:weather-snowy'],
'sleet': ['/static/images/darksky/weather-hail.svg',
'mdi:weather-snowy-rainy'],
'wind': ['/static/images/darksky/weather-windy.svg',
'mdi:weather-windy'],
'fog': ['/static/images/darksky/weather-fog.svg',
'mdi:weather-fog'],
'cloudy': ['/static/images/darksky/weather-cloudy.svg',
'mdi:weather-cloudy'],
'partly-cloudy-day': ['/static/images/darksky/weather-partlycloudy.svg',
'mdi:weather-partlycloudy'],
'partly-cloudy-night': ['/static/images/darksky/weather-cloudy.svg',
'mdi:weather-partlycloudy'],
}
# Language Supported Codes
LANGUAGE_CODES = [
'ar', 'az', 'be', 'bg', 'bn', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en',
'ja', 'ka', 'kn', 'ko', 'eo', 'es', 'et', 'fi', 'fr', 'he', 'hi', 'hr',
'hu', 'id', 'is', 'it', 'kw', 'lv', 'ml', 'mr', 'nb', 'nl', 'pa', 'pl',
'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'ta', 'te', 'tet', 'tr', 'uk',
'ur', 'x-pig-latin', 'zh', 'zh-tw',
]
ALLOWED_UNITS = ['auto', 'si', 'us', 'ca', 'uk', 'uk2']
ALERTS_ATTRS = [
'time',
'description',
'expires',
'severity',
'uri',
'regions',
'title'
]
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_MONITORED_CONDITIONS):
vol.All(cv.ensure_list, [vol.In(SENSOR_TYPES)]),
vol.Required(CONF_API_KEY): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_UNITS): vol.In(ALLOWED_UNITS),
vol.Optional(CONF_LANGUAGE,
default=DEFAULT_LANGUAGE): vol.In(LANGUAGE_CODES),
vol.Inclusive(
CONF_LATITUDE,
'coordinates',
'Latitude and longitude must exist together'
): cv.latitude,
vol.Inclusive(
CONF_LONGITUDE,
'coordinates',
'Latitude and longitude must exist together'
): cv.longitude,
vol.Optional(CONF_FORECAST):
vol.All(cv.ensure_list, [vol.Range(min=0, max=7)]),
vol.Optional(CONF_HOURLY_FORECAST):
vol.All(cv.ensure_list, [vol.Range(min=0, max=48)]),
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Dark Sky sensor."""
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
language = config.get(CONF_LANGUAGE)
interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL)
if CONF_UNITS in config:
units = config[CONF_UNITS]
elif hass.config.units.is_metric:
units = 'si'
else:
units = 'us'
forecast_data = DarkSkyData(
api_key=config.get(CONF_API_KEY, None), latitude=latitude,
longitude=longitude, units=units, language=language, interval=interval)
forecast_data.update()
forecast_data.update_currently()
# If connection failed don't setup platform.
if forecast_data.data is None:
return
name = config.get(CONF_NAME)
forecast = config.get(CONF_FORECAST)
forecast_hour = config.get(CONF_HOURLY_FORECAST)
sensors = []
for variable in config[CONF_MONITORED_CONDITIONS]:
if variable in DEPRECATED_SENSOR_TYPES:
_LOGGER.warning("Monitored condition %s is deprecated", variable)
if (not SENSOR_TYPES[variable][7] or
'currently' in SENSOR_TYPES[variable][7]):
if variable == 'alerts':
sensors.append(DarkSkyAlertSensor(
forecast_data, variable, name))
else:
sensors.append(DarkSkySensor(forecast_data, variable, name))
if forecast is not None and 'daily' in SENSOR_TYPES[variable][7]:
for forecast_day in forecast:
sensors.append(DarkSkySensor(
forecast_data, variable, name, forecast_day=forecast_day))
if forecast_hour is not None and 'hourly' in SENSOR_TYPES[variable][7]:
for forecast_h in forecast_hour:
sensors.append(DarkSkySensor(
forecast_data, variable, name, forecast_hour=forecast_h))
add_entities(sensors, True)
class DarkSkySensor(Entity):
"""Implementation of a Dark Sky sensor."""
def __init__(self, forecast_data, sensor_type, name,
forecast_day=None, forecast_hour=None):
"""Initialize the sensor."""
self.client_name = name
self._name = SENSOR_TYPES[sensor_type][0]
self.forecast_data = forecast_data
self.type = sensor_type
self.forecast_day = forecast_day
self.forecast_hour = forecast_hour
self._state = None
self._icon = None
self._unit_of_measurement = None
@property
def name(self):
"""Return the name of the sensor."""
if self.forecast_day is not None:
return '{} {} {}d'.format(
self.client_name, self._name, self.forecast_day)
if self.forecast_hour is not None:
return '{} {} {}h'.format(
self.client_name, self._name, self.forecast_hour)
return '{} {}'.format(
self.client_name, self._name)
@property
def state(self):
"""Return the state of the sensor."""
return self._state
@property
def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._unit_of_measurement
@property
def unit_system(self):
"""Return the unit system of this entity."""
return self.forecast_data.unit_system
@property
def entity_picture(self):
"""Return the entity picture to use in the frontend, if any."""
if self._icon is None or 'summary' not in self.type:
return None
if self._icon in CONDITION_PICTURES:
return CONDITION_PICTURES[self._icon][0]
return None
def update_unit_of_measurement(self):
"""Update units based on unit system."""
unit_index = {
'si': 1,
'us': 2,
'ca': 3,
'uk': 4,
'uk2': 5
}.get(self.unit_system, 1)
self._unit_of_measurement = SENSOR_TYPES[self.type][unit_index]
@property
def icon(self):
"""Icon to use in the frontend, if any."""
if 'summary' in self.type and self._icon in CONDITION_PICTURES:
return CONDITION_PICTURES[self._icon][1]
return SENSOR_TYPES[self.type][6]
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
}
def update(self):
"""Get the latest data from Dark Sky and updates the states."""
# Call the API for new forecast data. Each sensor will re-trigger this
# same exact call, but that's fine. We cache results for a short period
# of time to prevent hitting API limits. Note that Dark Sky will
# charge users for too many calls in 1 day, so take care when updating.
self.forecast_data.update()
self.update_unit_of_measurement()
if self.type == 'minutely_summary':
self.forecast_data.update_minutely()
minutely = self.forecast_data.data_minutely
self._state = getattr(minutely, 'summary', '')
self._icon = getattr(minutely, 'icon', '')
elif self.type == 'hourly_summary':
self.forecast_data.update_hourly()
hourly = self.forecast_data.data_hourly
self._state = getattr(hourly, 'summary', '')
self._icon = getattr(hourly, 'icon', '')
elif self.forecast_hour is not None:
self.forecast_data.update_hourly()
hourly = self.forecast_data.data_hourly
if hasattr(hourly, 'data'):
self._state = self.get_state(hourly.data[self.forecast_hour])
else:
self._state = 0
elif self.type == 'daily_summary':
self.forecast_data.update_daily()
daily = self.forecast_data.data_daily
self._state = getattr(daily, 'summary', '')
self._icon = getattr(daily, 'icon', '')
elif self.forecast_day is not None:
self.forecast_data.update_daily()
daily = self.forecast_data.data_daily
if hasattr(daily, 'data'):
self._state = self.get_state(daily.data[self.forecast_day])
else:
self._state = 0
else:
self.forecast_data.update_currently()
currently = self.forecast_data.data_currently
self._state = self.get_state(currently)
def get_state(self, data):
"""
Return a new state based on the type.
If the sensor type is unknown, the current state is returned.
"""
lookup_type = convert_to_camel(self.type)
state = getattr(data, lookup_type, None)
if state is None:
return state
if 'summary' in self.type:
self._icon = getattr(data, 'icon', '')
# Some state data needs to be rounded to whole values or converted to
# percentages
if self.type in ['precip_probability', 'cloud_cover', 'humidity']:
return round(state * 100, 1)
if self.type in ['dew_point', 'temperature', 'apparent_temperature',
'temperature_low', 'apparent_temperature_low',
'temperature_min', 'apparent_temperature_min',
'temperature_high', 'apparent_temperature_high',
'temperature_max', 'apparent_temperature_max'
'precip_accumulation', 'pressure', 'ozone',
'uvIndex']:
return round(state, 1)
return state
class DarkSkyAlertSensor(Entity):
"""Implementation of a Dark Sky sensor."""
def __init__(self, forecast_data, sensor_type, name):
"""Initialize the sensor."""
self.client_name = name
self._name = SENSOR_TYPES[sensor_type][0]
self.forecast_data = forecast_data
self.type = sensor_type
self._state = None
self._icon = None
self._alerts = None
@property
def name(self):
"""Return the name of the sensor."""
return '{} {}'.format(
self.client_name, self._name)
@property
def state(self):
"""Return the state of the sensor."""
return self._state
@property
def icon(self):
"""Icon to use in the frontend, if any."""
if self._state is not None and self._state > 0:
return "mdi:alert-circle"
return "mdi:alert-circle-outline"
@property
def device_state_attributes(self):
"""Return the state attributes."""
return self._alerts
def update(self):
"""Get the latest data from Dark Sky and updates the states."""
# Call the API for new forecast data. Each sensor will re-trigger this
# same exact call, but that's fine. We cache results for a short period
# of time to prevent hitting API limits. Note that Dark Sky will
# charge users for too many calls in 1 day, so take care when updating.
self.forecast_data.update()
self.forecast_data.update_alerts()
alerts = self.forecast_data.data_alerts
self._state = self.get_state(alerts)
def get_state(self, data):
"""
Return a new state based on the type.
If the sensor type is unknown, the current state is returned.
"""
alerts = {}
if data is None:
self._alerts = alerts
return data
multiple_alerts = len(data) > 1
for i, alert in enumerate(data):
for attr in ALERTS_ATTRS:
if multiple_alerts:
dkey = attr + '_' + str(i)
else:
dkey = attr
alerts[dkey] = getattr(alert, attr)
self._alerts = alerts
return len(data)
def convert_to_camel(data):
"""
Convert snake case (foo_bar_bat) to camel case (fooBarBat).
This is not pythonic, but needed for certain situations.
"""
components = data.split('_')
return components[0] + "".join(x.title() for x in components[1:])
class DarkSkyData:
"""Get the latest data from Darksky."""
def __init__(
self, api_key, latitude, longitude, units, language, interval):
"""Initialize the data object."""
self._api_key = api_key
self.latitude = latitude
self.longitude = longitude
self.units = units
self.language = language
self.data = None
self.unit_system = None
self.data_currently = None
self.data_minutely = None
self.data_hourly = None
self.data_daily = None
self.data_alerts = None
# Apply throttling to methods using configured interval
self.update = Throttle(interval)(self._update)
self.update_currently = Throttle(interval)(self._update_currently)
self.update_minutely = Throttle(interval)(self._update_minutely)
self.update_hourly = Throttle(interval)(self._update_hourly)
self.update_daily = Throttle(interval)(self._update_daily)
self.update_alerts = Throttle(interval)(self._update_alerts)
def _update(self):
"""Get the latest data from Dark Sky."""
import forecastio
try:
self.data = forecastio.load_forecast(
self._api_key, self.latitude, self.longitude, units=self.units,
lang=self.language)
except (ConnectError, HTTPError, Timeout, ValueError) as error:
_LOGGER.error("Unable to connect to Dark Sky: %s", error)
self.data = None
self.unit_system = self.data and self.data.json['flags']['units']
def _update_currently(self):
"""Update currently data."""
self.data_currently = self.data and self.data.currently()
def _update_minutely(self):
"""Update minutely data."""
self.data_minutely = self.data and self.data.minutely()
def _update_hourly(self):
"""Update hourly data."""
self.data_hourly = self.data and self.data.hourly()
def _update_daily(self):
"""Update daily data."""
self.data_daily = self.data and self.data.daily()
def _update_alerts(self):
"""Update alerts data."""
self.data_alerts = self.data and self.data.alerts()
| jabesq/home-assistant | homeassistant/components/darksky/sensor.py | Python | apache-2.0 | 21,674 |
#! -*- coding:utf-8 -*-
import os
import time
import signal
import traceback
from pyflumes.channels.base import ChannelBase
class FileChannel(ChannelBase):
def __init__(self, config, section):
super(FileChannel, self).__init__(config, section)
self.store_dir = os.path.join(config.get('GLOBAL', 'DIR'), 'tmp/hive/')
self.file_max_size = int(config.get(section, 'FILE_MAX_SIZE'))
self.ignore_postfix = config.get(section, 'IGNORE_POSTFIX')
self.handlers = dict()
def extract_file_name(self, data):
name = os.path.basename(data.get('filename', ''))
if not name:
self.log.warning('Incorrect format: ' + str(data))
return name
def list_files_size(self):
f_size = dict()
file_names = os.listdir(self.store_dir)
for name in file_names:
if name.endswith(self.ignore_postfix):
continue
size = os.path.getsize(os.path.join(self.store_dir, name))
f_size[name] = size
return f_size
def fetch_full_size_file(self):
cwm = 0
_file_name = ''
for name, size in self.list_files_size().iteritems():
if size > cwm:
cwm = size
_file_name = name
return _file_name, cwm
def get(self, *args, **kwargs):
name, size = self.fetch_full_size_file()
if size > self.file_max_size:
return os.path.join(self.store_dir, name)
else:
return ''
def put(self, data):
file_name = self.extract_file_name(data)
if not file_name:
return None
f = open(os.path.join(self.store_dir, file_name), 'a')
f.write(data.get('data'))
f.flush()
def handout(self, event):
self.log.info(self.name + ' [{}] starts'.format(os.getpid()))
signal.signal(signal.SIGTERM, lambda *args, **kwargs: self.log.info(self.name+': got terminate sig.'))
while event.is_set():
try:
data = self.get()
if data:
func = self.call_backs.get('hive', '')
if func:
# 此channel目前只支持hive collector
func(data)
else:
self.log.warning('Cant find hive callback function.')
except:
self.log.warning(traceback.format_exc())
time.sleep(30)
self.log.info(self.name + ' [{}] starts'.format(os.getpid()))
def __del__(self):
for handler in self.handlers.itervalues():
try:
handler.close()
except:
pass
| jrc-github/pyflume | pyflumes/channels/file_channel.py | Python | gpl-3.0 | 2,715 |
from __future__ import absolute_import
from .runtime import scheduler
from .exceptions import AlreadyScheduled
registered_jobs = {}
def register_interval_job(name, title, func, weeks=0, days=0, hours=0, minutes=0,
seconds=0, start_date=None, args=None,
kwargs=None, job_name=None, **options):
if name in registered_jobs:
raise AlreadyScheduled
job = scheduler.add_interval_job(func=func, weeks=weeks, days=days,
hours=hours, minutes=minutes, seconds=seconds,
start_date=start_date, args=args, kwargs=kwargs, **options)
registered_jobs[name] = {'title': title, 'job': job}
def remove_job(name):
if name in registered_jobs:
scheduler.unschedule_job(registered_jobs[name]['job'])
registered_jobs.pop(name)
def get_job_list():
return registered_jobs.values()
| appsembler/mayan_appsembler | apps/scheduler/api.py | Python | gpl-3.0 | 888 |
# -*- encoding: utf-8 -*-
#
# Copyright © 2012 New Dream Network, LLC (DreamHost)
#
# Author: Doug Hellmann <doug.hellmann@dreamhost.com>
#
# 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.
"""Test listing raw events.
"""
import datetime
import logging
from ceilometer.openstack.common import timeutils
from ceilometer.storage import impl_mongodb
from ceilometer.storage import models
from .base import FunctionalTest
LOG = logging.getLogger(__name__)
class TestComputeDurationByResource(FunctionalTest):
def setUp(self):
super(TestComputeDurationByResource, self).setUp()
# Create events relative to the range and pretend
# that the intervening events exist.
self.early1 = datetime.datetime(2012, 8, 27, 7, 0)
self.early2 = datetime.datetime(2012, 8, 27, 17, 0)
self.start = datetime.datetime(2012, 8, 28, 0, 0)
self.middle1 = datetime.datetime(2012, 8, 28, 8, 0)
self.middle2 = datetime.datetime(2012, 8, 28, 18, 0)
self.end = datetime.datetime(2012, 8, 28, 23, 59)
self.late1 = datetime.datetime(2012, 8, 29, 9, 0)
self.late2 = datetime.datetime(2012, 8, 29, 19, 0)
def _stub_interval_func(self, func):
self.stubs.Set(impl_mongodb.Connection,
'get_meter_statistics',
func)
def _set_interval(self, start, end):
def get_interval(ignore_self, event_filter, period):
assert event_filter.start
assert event_filter.end
if (event_filter.start > end or event_filter.end < start):
return []
duration_start = max(event_filter.start, start)
duration_end = min(event_filter.end, end)
duration = timeutils.delta_seconds(duration_start, duration_end)
return [
models.Statistics(
min=0,
max=0,
avg=0,
sum=0,
count=0,
period=None,
period_start=None,
period_end=None,
duration=duration,
duration_start=duration_start,
duration_end=duration_end,
)
]
self._stub_interval_func(get_interval)
def _invoke_api(self):
return self.get_json('/meters/instance:m1.tiny/statistics',
q=[{'field': 'timestamp',
'op': 'ge',
'value': self.start.isoformat()},
{'field': 'timestamp',
'op': 'le',
'value': self.end.isoformat()},
{'field': 'search_offset',
'value': 10}])
def test_before_range(self):
self._set_interval(self.early1, self.early2)
data = self._invoke_api()
self.assertEqual(data, [])
def _assert_times_match(self, actual, expected):
if actual:
actual = timeutils.parse_isotime(actual)
actual = actual.replace(tzinfo=None)
assert actual == expected
def test_overlap_range_start(self):
self._set_interval(self.early1, self.middle1)
data = self._invoke_api()
self._assert_times_match(data[0]['duration_start'], self.start)
self._assert_times_match(data[0]['duration_end'], self.middle1)
self.assertEqual(data[0]['duration'], 8 * 60 * 60)
def test_within_range(self):
self._set_interval(self.middle1, self.middle2)
data = self._invoke_api()
self._assert_times_match(data[0]['duration_start'], self.middle1)
self._assert_times_match(data[0]['duration_end'], self.middle2)
self.assertEqual(data[0]['duration'], 10 * 60 * 60)
def test_within_range_zero_duration(self):
self._set_interval(self.middle1, self.middle1)
data = self._invoke_api()
self._assert_times_match(data[0]['duration_start'], self.middle1)
self._assert_times_match(data[0]['duration_end'], self.middle1)
self.assertEqual(data[0]['duration'], 0)
def test_overlap_range_end(self):
self._set_interval(self.middle2, self.late1)
data = self._invoke_api()
self._assert_times_match(data[0]['duration_start'], self.middle2)
self._assert_times_match(data[0]['duration_end'], self.end)
self.assertEqual(data[0]['duration'], ((6 * 60) - 1) * 60)
def test_after_range(self):
self._set_interval(self.late1, self.late2)
data = self._invoke_api()
self.assertEqual(data, [])
def test_without_end_timestamp(self):
def get_interval(ignore_self, event_filter, period):
return [
models.Statistics(
count=0,
min=None,
max=None,
avg=None,
duration=None,
duration_start=self.late1,
duration_end=self.late2,
sum=0,
period=None,
period_start=None,
period_end=None,
)
]
self._stub_interval_func(get_interval)
data = self.get_json('/meters/instance:m1.tiny/statistics',
q=[{'field': 'timestamp',
'op': 'ge',
'value': self.late1.isoformat()},
{'field': 'resource_id',
'value': 'resource-id'},
{'field': 'search_offset',
'value': 10}])
self._assert_times_match(data[0]['duration_start'], self.late1)
self._assert_times_match(data[0]['duration_end'], self.late2)
def test_without_start_timestamp(self):
def get_interval(ignore_self, event_filter, period):
return [
models.Statistics(
count=0,
min=None,
max=None,
avg=None,
duration=None,
duration_start=self.early1,
duration_end=self.early2,
#
sum=0,
period=None,
period_start=None,
period_end=None,
)
]
return (self.early1, self.early2)
self._stub_interval_func(get_interval)
data = self.get_json('/meters/instance:m1.tiny/statistics',
q=[{'field': 'timestamp',
'op': 'le',
'value': self.early2.isoformat()},
{'field': 'resource_id',
'value': 'resource-id'},
{'field': 'search_offset',
'value': 10}])
self._assert_times_match(data[0]['duration_start'], self.early1)
self._assert_times_match(data[0]['duration_end'], self.early2)
| dreamhost/ceilometer | tests/api/v2/test_compute_duration_by_resource.py | Python | apache-2.0 | 7,710 |
# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.
from sos.report.plugins import Plugin, RedHatPlugin, PluginOpt
class Rpm(Plugin, RedHatPlugin):
short_desc = 'RPM Package Manager'
plugin_name = 'rpm'
profiles = ('system', 'packagemanager')
option_list = [
PluginOpt('rpmq', default=True,
desc='query package information with rpm -q'),
PluginOpt('rpmva', default=False, desc='verify all packages'),
PluginOpt('rpmdb', default=False, desc='collect /var/lib/rpm')
]
verify_packages = ('rpm',)
def setup(self):
self.add_copy_spec("/var/log/rpmpkgs")
if self.get_option("rpmq"):
rpmq = "rpm --nodigest -qa --qf=%s"
# basic installed-rpms
nvra = '"%-59{NVRA} %{INSTALLTIME:date}\n"'
irpms = "sh -c '%s | sort -V'" % rpmq % nvra
self.add_cmd_output(irpms, root_symlink='installed-rpms',
tags='installed_rpms')
# extended package data
extpd = (
'"%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\\t'
'%{INSTALLTIME:date}\\t%{INSTALLTIME}\\t'
'%{VENDOR}\\t%{BUILDHOST}\\t'
'%{SIGPGP}\\t%{SIGPGP:pgpsig}\\n"'
)
self.add_cmd_output(rpmq % extpd, suggest_filename='package-data',
tags=['installed_rpms', 'package_data'])
if self.get_option("rpmva"):
self.plugin_timeout = 1000
self.add_cmd_output("rpm -Va", root_symlink="rpm-Va",
timeout=900, priority=100,
tags=['rpm_va', 'rpm_V', 'rpm_v',
'insights_rpm_V_packages'])
if self.get_option("rpmdb"):
self.add_cmd_output("lsof +D /var/lib/rpm",
suggest_filename='lsof_D_var_lib_rpm')
self.add_copy_spec("/var/lib/rpm")
self.add_cmd_output("rpm --showrc")
# vim: set et ts=4 sw=4 :
| slashdd/sos | sos/report/plugins/rpm.py | Python | gpl-2.0 | 2,346 |
import json
import numpy as np
from skimage.measure import regionprops
from skimage.morphology import convex_hull_image
from skimage.segmentation import find_boundaries
class STObject(object):
"""
The STObject stores data and location information for objects extracted from the ensemble grids.
Attributes:
grid (ndarray): All of the data values. Supports a 2D array of values, a list of 2D arrays, or a 3D array.
mask (ndarray): Grid of 1's and 0's in which 1's indicate the location of the object.
x (ndarray): Array of x-coordinate values in meters. Longitudes can also be placed here.
y (ndarray): Array of y-coordinate values in meters. Latitudes can also be placed here.
i (ndarray): Array of row indices from the full model domain.
j (ndarray): Array of column indices from the full model domain.
start_time: The first time of the object existence.
end_time: The last time of the object existence.
step: number of hours between timesteps
dx: grid spacing
u: storm motion in x-direction
v: storm motion in y-direction
"""
def __init__(self, grid, mask, x, y, i, j, start_time, end_time, step=1, dx=4000, u=None, v=None):
if hasattr(grid, "shape") and len(grid.shape) == 2:
self.timesteps = [grid]
self.masks = [np.array(mask, dtype=int)]
self.x = [x]
self.y = [y]
self.i = [i]
self.j = [j]
elif hasattr(grid, "shape") and len(grid.shape) > 2:
self.timesteps = []
self.masks = []
self.x = []
self.y = []
self.i = []
self.j = []
for l in range(grid.shape[0]):
self.timesteps.append(grid[l])
self.masks.append(np.array(mask[l], dtype=int))
self.x.append(x[l])
self.y.append(y[l])
self.i.append(i[l])
self.j.append(j[l])
else:
self.timesteps = grid
self.masks = mask
self.x = x
self.y = y
self.i = i
self.j = j
if u is not None and v is not None:
self.u = u
self.v = v
else:
self.u = np.zeros(len(self.timesteps))
self.v = np.zeros(len(self.timesteps))
self.dx = dx
self.start_time = start_time
self.end_time = end_time
self.step = step
self.times = np.arange(start_time, end_time + step, step)
self.attributes = {}
self.observations = None
@property
def __str__(self):
com_x, com_y = self.center_of_mass(self.start_time)
data = dict(maxsize=self.max_size(), comx=com_x, comy=com_y, start=self.start_time, end=self.end_time)
return "ST Object [maxSize=%(maxsize)d,initialCenter=%(comx)0.2f,%(comy)0.2f,duration=%(start)02d-%(end)02d]" % \
data
def center_of_mass(self, time):
"""
Calculate the center of mass at a given timestep.
Args:
time: Time at which the center of mass calculation is performed
Returns:
The x- and y-coordinates of the center of mass.
"""
if self.start_time <= time <= self.end_time:
diff = time - self.start_time
valid = np.flatnonzero(self.masks[diff] != 0)
if valid.size > 0:
com_x = 1.0 / self.timesteps[diff].ravel()[valid].sum() * np.sum(self.timesteps[diff].ravel()[valid] *
self.x[diff].ravel()[valid])
com_y = 1.0 / self.timesteps[diff].ravel()[valid].sum() * np.sum(self.timesteps[diff].ravel()[valid] *
self.y[diff].ravel()[valid])
else:
com_x = np.mean(self.x[diff])
com_y = np.mean(self.y[diff])
else:
com_x = None
com_y = None
return com_x, com_y
def closest_distance(self, time, other_object, other_time):
"""
The shortest distance between two objects at specified times.
Args:
time (int or datetime): Valid time for this STObject
other_object: Another STObject being compared
other_time: The time within the other STObject being evaluated.
Returns:
Distance in units of the x-y coordinates
"""
ti = np.where(self.times == time)[0][0]
oti = np.where(other_object.times == other_time)[0][0]
xs = self.x[ti].ravel()[self.masks[ti].ravel() == 1]
xs = xs.reshape(xs.size, 1)
ys = self.y[ti].ravel()[self.masks[ti].ravel() == 1]
ys = ys.reshape(ys.size, 1)
o_xs = other_object.x[oti].ravel()[other_object.masks[oti].ravel() == 1]
o_xs = o_xs.reshape(1, o_xs.size)
o_ys = other_object.y[oti].ravel()[other_object.masks[oti].ravel() == 1]
o_ys = o_ys.reshape(1, o_ys.size)
distances = (xs - o_xs) ** 2 + (ys - o_ys) ** 2
return np.sqrt(distances.min())
def percentile_distance(self, time, other_object, other_time, percentile):
ti = np.where(self.times == time)[0][0]
oti = np.where(other_object.times == other_time)[0][0]
xs = self.x[ti][self.masks[ti] == 1]
xs = xs.reshape(xs.size, 1)
ys = self.y[ti][self.masks[ti] == 1]
ys = ys.reshape(ys.size, 1)
o_xs = other_object.x[oti][other_object.masks[oti] == 1]
o_xs = o_xs.reshape(1, o_xs.size)
o_ys = other_object.y[oti][other_object.masks[oti] == 1]
o_ys = o_ys.reshape(1, o_ys.size)
distances = (xs - o_xs) ** 2 + (ys - o_ys) ** 2
return np.sqrt(np.percentile(distances, percentile))
def trajectory(self):
"""
Calculates the center of mass for each time step and outputs an array
Returns:
"""
traj = np.zeros((2, self.times.size))
for t, time in enumerate(self.times):
traj[:, t] = self.center_of_mass(time)
return traj
def get_corner(self, time):
"""
Gets the corner array indices of the STObject at a given time that corresponds
to the upper left corner of the bounding box for the STObject.
Args:
time: time at which the corner is being extracted.
Returns:
corner index.
"""
if self.start_time <= time <= self.end_time:
diff = time - self.start_time
return self.i[diff][0, 0], self.j[diff][0, 0]
else:
return -1, -1
def size(self, time):
"""
Gets the size of the object at a given time.
Args:
time: Time value being queried.
Returns:
size of the object in pixels
"""
if self.start_time <= time <= self.end_time:
return self.masks[time - self.start_time].sum()
else:
return 0
def max_size(self):
"""
Gets the largest size of the object over all timesteps.
Returns:
Maximum size of the object in pixels
"""
sizes = np.array([m.sum() for m in self.masks])
return sizes.max()
def max_intensity(self, time):
"""
Calculate the maximum intensity found at a timestep.
"""
ti = np.where(time == self.times)[0][0]
return self.timesteps[ti].max()
def extend(self, step):
"""
Adds the data from another STObject to this object.
Args:
step: another STObject being added after the current one in time.
"""
self.timesteps.extend(step.timesteps)
self.masks.extend(step.masks)
self.x.extend(step.x)
self.y.extend(step.y)
self.i.extend(step.i)
self.j.extend(step.j)
self.end_time = step.end_time
self.times = np.arange(self.start_time, self.end_time + self.step, self.step)
self.u = np.concatenate((self.u, step.u))
self.v = np.concatenate((self.v, step.v))
for attr in self.attributes.keys():
if attr in step.attributes.keys():
self.attributes[attr].extend(step.attributes[attr])
def boundary_polygon(self, time):
"""
Get coordinates of object boundary in counter-clockwise order
"""
ti = np.where(time == self.times)[0][0]
com_x, com_y = self.center_of_mass(time)
# If at least one point along perimeter of the mask rectangle is unmasked, find_boundaries() works.
# But if all perimeter points are masked, find_boundaries() does not find the object.
# Therefore, pad the mask with zeroes first and run find_boundaries on the padded array.
padded_mask = np.pad(self.masks[ti], 1, 'constant', constant_values=0)
chull = convex_hull_image(padded_mask)
boundary_image = find_boundaries(chull, mode='inner', background=0)
# Now remove the padding.
boundary_image = boundary_image[1:-1, 1:-1]
boundary_x = self.x[ti].ravel()[boundary_image.ravel()]
boundary_y = self.y[ti].ravel()[boundary_image.ravel()]
r = np.sqrt((boundary_x - com_x) ** 2 + (boundary_y - com_y) ** 2)
theta = np.arctan2((boundary_y - com_y), (boundary_x - com_x)) * 180.0 / np.pi + 360
polar_coords = np.array([(r[x], theta[x]) for x in range(r.size)], dtype=[('r', 'f4'), ('theta', 'f4')])
coord_order = np.argsort(polar_coords, order=['theta', 'r'])
ordered_coords = np.vstack([boundary_x[coord_order], boundary_y[coord_order]])
return ordered_coords
def estimate_motion(self, time, intensity_grid, max_u, max_v):
"""
Estimate the motion of the object with cross-correlation on the intensity values from the previous time step.
Args:
time: time being evaluated.
intensity_grid: 2D array of intensities used in cross correlation.
max_u: Maximum x-component of motion. Used to limit search area.
max_v: Maximum y-component of motion. Used to limit search area
Returns:
u, v, and the minimum error.
"""
ti = np.where(time == self.times)[0][0]
mask_vals = np.where(self.masks[ti].ravel() == 1)
i_vals = self.i[ti].ravel()[mask_vals]
j_vals = self.j[ti].ravel()[mask_vals]
obj_vals = self.timesteps[ti].ravel()[mask_vals]
u_shifts = np.arange(-max_u, max_u + 1)
v_shifts = np.arange(-max_v, max_v + 1)
min_error = 99999999999.0
best_u = 0
best_v = 0
for u in u_shifts:
j_shift = j_vals - u
for v in v_shifts:
i_shift = i_vals - v
if np.all((0 <= i_shift) & (i_shift < intensity_grid.shape[0]) &
(0 <= j_shift) & (j_shift < intensity_grid.shape[1])):
shift_vals = intensity_grid[i_shift, j_shift]
else:
shift_vals = np.zeros(i_shift.shape)
# This isn't correlation; it is mean absolute error.
error = np.abs(shift_vals - obj_vals).mean()
if error < min_error:
min_error = error
best_u = u * self.dx
best_v = v * self.dx
# 60 seems arbitrarily high
# if min_error > 60:
# best_u = 0
# best_v = 0
self.u[ti] = best_u
self.v[ti] = best_v
return best_u, best_v, min_error
def count_overlap(self, time, other_object, other_time):
"""
Counts the number of points that overlap between this STObject and another STObject. Used for tracking.
"""
ti = np.where(time == self.times)[0][0]
ma = np.where(self.masks[ti].ravel() == 1)
oti = np.where(other_time == other_object.times)[0]
obj_coords = np.zeros(self.masks[ti].sum(), dtype=[('x', int), ('y', int)])
other_obj_coords = np.zeros(other_object.masks[oti].sum(), dtype=[('x', int), ('y', int)])
obj_coords['x'] = self.i[ti].ravel()[ma]
obj_coords['y'] = self.j[ti].ravel()[ma]
other_obj_coords['x'] = other_object.i[oti][other_object.masks[oti] == 1]
other_obj_coords['y'] = other_object.j[oti][other_object.masks[oti] == 1]
return float(np.intersect1d(obj_coords,
other_obj_coords).size) / np.maximum(self.masks[ti].sum(),
other_object.masks[oti].sum())
def extract_attribute_grid(self, model_grid, potential=False, future=False):
"""
Extracts the data from a ModelOutput or ModelGrid object within the bounding box region of the STObject.
Args:
model_grid: A ModelGrid or ModelOutput Object
potential: Extracts from the time before instead of the same time as the object
"""
if potential:
var_name = model_grid.variable + "-potential"
timesteps = np.arange(self.start_time - 1, self.end_time)
elif future:
var_name = model_grid.variable + "-future"
timesteps = np.arange(self.start_time + 1, self.end_time + 2)
else:
var_name = model_grid.variable
timesteps = np.arange(self.start_time, self.end_time + 1)
self.attributes[var_name] = []
for ti, t in enumerate(timesteps):
self.attributes[var_name].append(
model_grid.data[t - model_grid.start_hour, self.i[ti], self.j[ti]])
def extract_attribute_array(self, data_array, var_name):
"""
Extracts data from a 2D array that has the same dimensions as the grid used to identify the object.
Args:
data_array: 2D numpy array
"""
if var_name not in self.attributes.keys():
self.attributes[var_name] = []
for t in range(self.times.size):
self.attributes[var_name].append(data_array[self.i[t], self.j[t]])
def extract_tendency_grid(self, model_grid):
"""
Extracts the difference in model outputs
Args:
model_grid: ModelOutput or ModelGrid object.
"""
var_name = model_grid.variable + "-tendency"
self.attributes[var_name] = []
timesteps = np.arange(self.start_time, self.end_time + 1)
for ti, t in enumerate(timesteps):
t_index = t - model_grid.start_hour
self.attributes[var_name].append(
model_grid.data[t_index, self.i[ti], self.j[ti]] - model_grid.data[t_index - 1, self.i[ti], self.j[ti]]
)
def calc_attribute_statistics(self, statistic_name):
"""
Calculates summary statistics over the domains of each attribute.
Args:
statistic_name (string): numpy statistic, such as mean, std, max, min
Returns:
dict of statistics from each attribute grid.
"""
stats = {}
for var, grids in self.attributes.items():
if len(grids) > 1:
stats[var] = getattr(np.array([getattr(np.ma.array(x, mask=self.masks[t] == 0), statistic_name)()
for t, x in enumerate(grids)]), statistic_name)()
else:
stats[var] = getattr(np.ma.array(grids[0], mask=self.masks[0] == 0), statistic_name)()
return stats
def calc_attribute_statistic(self, attribute, statistic, time):
"""
Calculate statistics based on the values of an attribute. The following statistics are supported:
mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value).
Args:
attribute: Attribute extracted from model grid
statistic: Name of statistic being used.
time: timestep of the object being investigated
Returns:
The value of the statistic
"""
ti = np.where(self.times == time)[0][0]
ma = np.where(self.masks[ti].ravel() == 1)
if len(self.attributes[attribute][ti].ravel()[ma]) < 1:
stat_val = np.nan
return stat_val
if statistic in ['mean', 'max', 'min', 'std', 'ptp']:
stat_val = getattr(self.attributes[attribute][ti].ravel()[ma], statistic)()
elif statistic == 'median':
stat_val = np.median(self.attributes[attribute][ti].ravel()[ma])
elif statistic == "skew":
stat_val = np.mean(self.attributes[attribute][ti].ravel()[ma]) - \
np.median(self.attributes[attribute][ti].ravel()[ma])
elif 'percentile' in statistic:
per = int(statistic.split("_")[1])
stat_val = np.percentile(self.attributes[attribute][ti].ravel()[ma], per)
elif 'dt' in statistic:
stat_name = statistic[:-3]
if ti == 0:
stat_val = 0
else:
stat_val = self.calc_attribute_statistic(attribute, stat_name, time) \
- self.calc_attribute_statistic(attribute, stat_name, time - 1)
else:
stat_val = np.nan
return stat_val
def calc_timestep_statistic(self, statistic, time):
"""
Calculate statistics from the primary attribute of the StObject.
Args:
statistic: statistic being calculated
time: Timestep being investigated
Returns:
Value of the statistic
"""
ti = np.where(self.times == time)[0][0]
ma = np.where(self.masks[ti].ravel() == 1)
if statistic in ['mean', 'max', 'min', 'std', 'ptp']:
stat_val = getattr(self.timesteps[ti].ravel()[ma], statistic)()
elif statistic == 'median':
stat_val = np.median(self.timesteps[ti].ravel()[ma])
elif 'percentile' in statistic:
per = int(statistic.split("_")[1])
stat_val = np.percentile(self.timesteps[ti].ravel()[ma], per)
elif 'dt' in statistic:
stat_name = statistic[:-3]
if ti == 0:
stat_val = 0
else:
stat_val = self.calc_timestep_statistic(stat_name, time) - \
self.calc_timestep_statistic(stat_name, time - 1)
else:
stat_val = np.nan
return stat_val
def calc_shape_statistics(self, stat_names):
"""
Calculate shape statistics using regionprops applied to the object mask.
Args:
stat_names: List of statistics to be extracted from those calculated by regionprops.
Returns:
Dictionary of shape statistics
"""
stats = {}
try:
all_props = [regionprops(m) for m in self.masks]
except TypeError:
raise TypeError("masks not the right type")
for stat in stat_names:
stats[stat] = np.mean([p[0][stat] for p in all_props])
return stats
def calc_shape_step(self, stat_names, time):
"""
Calculate shape statistics for a single time step
Args:
stat_names: List of shape statistics calculated from region props
time: Time being investigated
Returns:
List of shape statistics
"""
ti = np.where(self.times == time)[0][0]
shape_stats = []
try:
props = regionprops(self.masks[ti], self.timesteps[ti])[0]
except:
for stat_name in stat_names:
shape_stats.append(np.nan)
return shape_stats
for stat_name in stat_names:
if "moments_hu" in stat_name:
hu_index = int(stat_name.split("_")[-1])
hu_name = "_".join(stat_name.split("_")[:-1])
hu_val = np.log(props[hu_name][hu_index])
if np.isnan(hu_val):
shape_stats.append(0)
else:
shape_stats.append(hu_val)
else:
shape_stats.append(props[stat_name])
return shape_stats
def to_geojson(self, filename, proj, metadata=None):
"""
Output the data in the STObject to a geoJSON file.
Args:
filename: Name of the file
proj: PyProj object for converting the x and y coordinates back to latitude and longitue values.
metadata: Metadata describing the object to be included in the top-level properties.
"""
if metadata is None:
metadata = {}
json_obj = {"type": "FeatureCollection", "features": [], "properties": {}}
json_obj['properties']['times'] = self.times.tolist()
json_obj['properties']['dx'] = self.dx
json_obj['properties']['step'] = self.step
json_obj['properties']['u'] = self.u.tolist()
json_obj['properties']['v'] = self.v.tolist()
for k, v in metadata.items():
json_obj['properties'][k] = v
for t, time in enumerate(self.times):
feature = {"type": "Feature",
"geometry": {"type": "Polygon"},
"properties": {}}
boundary_coords = self.boundary_polygon(time)
lonlat = np.vstack(proj(boundary_coords[0], boundary_coords[1], inverse=True))
lonlat_list = lonlat.T.tolist()
if len(lonlat_list) > 0:
lonlat_list.append(lonlat_list[0])
feature["geometry"]["coordinates"] = [lonlat_list]
for attr in ["timesteps", "masks", "x", "y", "i", "j"]:
feature["properties"][attr] = getattr(self, attr)[t].tolist()
feature["properties"]["attributes"] = {}
for attr_name, steps in self.attributes.items():
feature["properties"]["attributes"][attr_name] = steps[t].tolist()
json_obj['features'].append(feature)
file_obj = open(filename, "w")
json.dump(json_obj, file_obj, indent=1, sort_keys=True)
file_obj.close()
return
def read_geojson(filename):
"""
Reads a geojson file containing an STObject and initializes a new STObject from the information in the file.
Args:
filename: Name of the geojson file
Returns:
an STObject
"""
json_file = open(filename)
data = json.load(json_file)
json_file.close()
times = data["properties"]["times"]
main_data = dict(timesteps=[], masks=[], x=[], y=[], i=[], j=[])
attribute_data = dict()
for feature in data["features"]:
for main_name in main_data.keys():
main_data[main_name].append(np.array(feature["properties"][main_name]))
for k, v in feature["properties"]["attributes"].items():
if k not in attribute_data.keys():
attribute_data[k] = [np.array(v)]
else:
attribute_data[k].append(np.array(v))
kwargs = {}
for kw in ["dx", "step", "u", "v"]:
if kw in data["properties"].keys():
kwargs[kw] = data["properties"][kw]
sto = STObject(main_data["timesteps"], main_data["masks"], main_data["x"], main_data["y"],
main_data["i"], main_data["j"], times[0], times[-1], **kwargs)
for k, v in attribute_data.items():
sto.attributes[k] = v
return sto
| djgagne/hagelslag | hagelslag/processing/STObject.py | Python | mit | 23,608 |
#! /usr/bin/env python
# Calculate the n^th Fibonacci number.
def fib(n):
if (n < 2):
return n
else:
return fib(n - 1) + fib(n - 2)
res = fib(20)
print(res)
| emerging-technologies/fib-languages | fib.py | Python | mit | 171 |
#
# Copyright 2016 Quantopian, 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 datetime
import calendar
import pandas as pd
import numpy as np
import zipline.finance.risk as risk
from zipline.utils import factory
from zipline.finance.trading import SimulationParameters
from zipline.testing.fixtures import WithTradingEnvironment, ZiplineTestCase
from zipline.finance.risk.period import RiskMetricsPeriod
RETURNS_BASE = 0.01
RETURNS = [RETURNS_BASE] * 251
BENCHMARK_BASE = 0.005
BENCHMARK = [BENCHMARK_BASE] * 251
DECIMAL_PLACES = 8
class TestRisk(WithTradingEnvironment, ZiplineTestCase):
def init_instance_fixtures(self):
super(TestRisk, self).init_instance_fixtures()
self.start_session = pd.Timestamp("2006-01-01", tz='UTC')
self.end_session = self.trading_calendar.minute_to_session_label(
pd.Timestamp("2006-12-31", tz='UTC'),
direction="previous"
)
self.sim_params = SimulationParameters(
start_session=self.start_session,
end_session=self.end_session,
trading_calendar=self.trading_calendar,
)
self.algo_returns = factory.create_returns_from_list(
RETURNS,
self.sim_params
)
self.benchmark_returns = factory.create_returns_from_list(
BENCHMARK,
self.sim_params
)
self.metrics = risk.RiskReport(
self.algo_returns,
self.sim_params,
benchmark_returns=self.benchmark_returns,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
)
def test_factory(self):
returns = [0.1] * 100
r_objects = factory.create_returns_from_list(returns, self.sim_params)
self.assertTrue(r_objects.index[-1] <=
pd.Timestamp('2006-12-31', tz='UTC'))
def test_drawdown(self):
np.testing.assert_equal(
all(x.max_drawdown == 0 for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(x.max_drawdown == 0 for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(x.max_drawdown == 0 for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(x.max_drawdown == 0 for x in self.metrics.year_periods),
True)
def test_benchmark_returns_06(self):
np.testing.assert_almost_equal(
[x.benchmark_period_returns
for x in self.metrics.month_periods],
[(1 + BENCHMARK_BASE) ** len(x.benchmark_returns) - 1
for x in self.metrics.month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.benchmark_period_returns
for x in self.metrics.three_month_periods],
[(1 + BENCHMARK_BASE) ** len(x.benchmark_returns) - 1
for x in self.metrics.three_month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.benchmark_period_returns
for x in self.metrics.six_month_periods],
[(1 + BENCHMARK_BASE) ** len(x.benchmark_returns) - 1
for x in self.metrics.six_month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.benchmark_period_returns
for x in self.metrics.year_periods],
[(1 + BENCHMARK_BASE) ** len(x.benchmark_returns) - 1
for x in self.metrics.year_periods],
DECIMAL_PLACES)
def test_trading_days(self):
self.assertEqual([x.num_trading_days
for x in self.metrics.year_periods],
[251])
self.assertEqual([x.num_trading_days
for x in self.metrics.month_periods],
[20, 19, 23, 19, 22, 22, 20, 23, 20, 22, 21, 20])
def test_benchmark_volatility(self):
# Volatility is calculated by a empyrical function so testing
# of period volatility will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.benchmark_volatility, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.benchmark_volatility, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.benchmark_volatility, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.benchmark_volatility, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_returns(self):
np.testing.assert_almost_equal(
[x.algorithm_period_returns
for x in self.metrics.month_periods],
[(1 + RETURNS_BASE) ** len(x.algorithm_returns) - 1
for x in self.metrics.month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.algorithm_period_returns
for x in self.metrics.three_month_periods],
[(1 + RETURNS_BASE) ** len(x.algorithm_returns) - 1
for x in self.metrics.three_month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.algorithm_period_returns
for x in self.metrics.six_month_periods],
[(1 + RETURNS_BASE) ** len(x.algorithm_returns) - 1
for x in self.metrics.six_month_periods],
DECIMAL_PLACES)
np.testing.assert_almost_equal(
[x.algorithm_period_returns
for x in self.metrics.year_periods],
[(1 + RETURNS_BASE) ** len(x.algorithm_returns) - 1
for x in self.metrics.year_periods],
DECIMAL_PLACES)
def test_algorithm_volatility(self):
# Volatility is calculated by a empyrical function so testing
# of period volatility will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.algorithm_volatility, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.algorithm_volatility, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.algorithm_volatility, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.algorithm_volatility, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_sharpe(self):
# The sharpe ratio is calculated by a empyrical function so testing
# of period sharpe ratios will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.sharpe, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sharpe, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sharpe, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sharpe, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_downside_risk(self):
# Downside risk is calculated by a empyrical function so testing
# of period downside risk will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.downside_risk, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.downside_risk, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.downside_risk, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.downside_risk, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_sortino(self):
# The sortino ratio is calculated by a empyrical function so testing
# of period sortino ratios will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.sortino, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sortino, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sortino, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.sortino, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_information(self):
# The information ratio is calculated by a empyrical function
# testing of period information ratio will be limited to determine
# if the value is numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.information, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.information, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.information, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.information, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_beta(self):
# Beta is calculated by a empyrical function so testing
# of period beta will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.beta, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.beta, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.beta, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.beta, float)
for x in self.metrics.year_periods),
True)
def test_algorithm_alpha(self):
# Alpha is calculated by a empyrical function so testing
# of period alpha will be limited to determine if the value is
# numerical. This tests for its existence and format.
np.testing.assert_equal(
all(isinstance(x.alpha, float)
for x in self.metrics.month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.alpha, float)
for x in self.metrics.three_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.alpha, float)
for x in self.metrics.six_month_periods),
True)
np.testing.assert_equal(
all(isinstance(x.alpha, float)
for x in self.metrics.year_periods),
True)
def test_treasury_returns(self):
returns = factory.create_returns_from_range(self.sim_params)
metrics = risk.RiskReport(returns, self.sim_params,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
benchmark_returns=self.env.benchmark_returns)
self.assertEqual([round(x.treasury_period_return, 4)
for x in metrics.month_periods],
[0.0037,
0.0034,
0.0039,
0.0038,
0.0040,
0.0037,
0.0043,
0.0043,
0.0038,
0.0044,
0.0043,
0.004])
self.assertEqual([round(x.treasury_period_return, 4)
for x in metrics.three_month_periods],
[0.0114,
0.0116,
0.0122,
0.0125,
0.0129,
0.0127,
0.0123,
0.0128,
0.0125,
0.0127])
self.assertEqual([round(x.treasury_period_return, 4)
for x in metrics.six_month_periods],
[0.0260,
0.0257,
0.0258,
0.0252,
0.0259,
0.0256,
0.0257])
self.assertEqual([round(x.treasury_period_return, 4)
for x in metrics.year_periods],
[0.0500])
def test_benchmarkrange(self):
start_session = self.trading_calendar.minute_to_session_label(
pd.Timestamp("2008-01-01", tz='UTC')
)
end_session = self.trading_calendar.minute_to_session_label(
pd.Timestamp("2010-01-01", tz='UTC'), direction="previous"
)
sim_params = SimulationParameters(
start_session=start_session,
end_session=end_session,
trading_calendar=self.trading_calendar,
)
returns = factory.create_returns_from_range(sim_params)
metrics = risk.RiskReport(returns, self.sim_params,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
benchmark_returns=self.env.benchmark_returns)
self.check_metrics(metrics, 24, start_session)
def test_partial_month(self):
start_session = self.trading_calendar.minute_to_session_label(
pd.Timestamp("1991-01-01", tz='UTC')
)
# 1992 and 1996 were leap years
total_days = 365 * 5 + 2
end_session = start_session + datetime.timedelta(days=total_days)
sim_params90s = SimulationParameters(
start_session=start_session,
end_session=end_session,
trading_calendar=self.trading_calendar,
)
returns = factory.create_returns_from_range(sim_params90s)
returns = returns[:-10] # truncate the returns series to end mid-month
metrics = risk.RiskReport(returns, sim_params90s,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
benchmark_returns=self.env.benchmark_returns)
total_months = 60
self.check_metrics(metrics, total_months, start_session)
def check_metrics(self, metrics, total_months, start_date):
"""
confirm that the right number of riskmetrics were calculated for each
window length.
"""
self.assert_range_length(
metrics.month_periods,
total_months,
1,
start_date
)
self.assert_range_length(
metrics.three_month_periods,
total_months,
3,
start_date
)
self.assert_range_length(
metrics.six_month_periods,
total_months,
6,
start_date
)
self.assert_range_length(
metrics.year_periods,
total_months,
12,
start_date
)
def assert_last_day(self, period_end):
# 30 days has september, april, june and november
if period_end.month in [9, 4, 6, 11]:
self.assertEqual(period_end.day, 30)
# all the rest have 31, except for february
elif(period_end.month != 2):
self.assertEqual(period_end.day, 31)
else:
if calendar.isleap(period_end.year):
self.assertEqual(period_end.day, 29)
else:
self.assertEqual(period_end.day, 28)
def assert_month(self, start_month, actual_end_month):
if start_month == 1:
expected_end_month = 12
else:
expected_end_month = start_month - 1
self.assertEqual(expected_end_month, actual_end_month)
def assert_range_length(self, col, total_months,
period_length, start_date):
if (period_length > total_months):
self.assertEqual(len(col), 0)
else:
self.assertEqual(
len(col),
total_months - (period_length - 1),
"mismatch for total months - \
expected:{total_months}/actual:{actual}, \
period:{period_length}, start:{start_date}, \
calculated end:{end}".format(total_months=total_months,
period_length=period_length,
start_date=start_date,
end=col[-1]._end_session,
actual=len(col))
)
self.assert_month(start_date.month, col[-1]._end_session.month)
self.assert_last_day(col[-1]._end_session)
def test_algorithm_leverages(self):
# Max leverage for an algorithm with 'None' as leverage is 0.
np.testing.assert_equal(
[x.max_leverage for x in self.metrics.month_periods],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
np.testing.assert_equal(
[x.max_leverage for x in self.metrics.three_month_periods],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
np.testing.assert_equal(
[x.max_leverage for x in self.metrics.six_month_periods],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
np.testing.assert_equal(
[x.max_leverage for x in self.metrics.year_periods],
[0.0])
def test_returns_beyond_treasury(self):
# The last treasury value is used when return dates go beyond
# treasury curve data
treasury_curves = self.env.treasury_curves
treasury = treasury_curves[treasury_curves.index < self.start_session]
test_period = RiskMetricsPeriod(
start_session=self.start_session,
end_session=self.end_session,
returns=self.algo_returns,
benchmark_returns=self.benchmark_returns,
trading_calendar=self.trading_calendar,
treasury_curves=treasury,
algorithm_leverages=[.01, .02, .03]
)
assert test_period.treasury_curves.equals(treasury[-1:])
# This return period has a list instead of None for algorithm_leverages
# Confirm that max_leverage is set to the max of those values
assert test_period.max_leverage == .03
def test_index_mismatch_exception(self):
# An exception is raised when returns and benchmark returns
# have indexes that do not match
bench_params = SimulationParameters(
start_session=pd.Timestamp("2006-02-01", tz='UTC'),
end_session=pd.Timestamp("2006-02-28", tz='UTC'),
trading_calendar=self.trading_calendar,
)
benchmark = factory.create_returns_from_list(
[BENCHMARK_BASE]*19,
bench_params
)
with np.testing.assert_raises(Exception):
RiskMetricsPeriod(
start_session=self.start_session,
end_session=self.end_session,
returns=self.algo_returns,
benchmark_returns=benchmark,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
)
def test_sharpe_value_when_null(self):
# Sharpe is displayed as '0.0' instead of np.nan
null_returns = factory.create_returns_from_list(
[0.0]*251,
self.sim_params
)
test_period = RiskMetricsPeriod(
start_session=self.start_session,
end_session=self.end_session,
returns=null_returns,
benchmark_returns=self.benchmark_returns,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
)
assert test_period.sharpe == 0.0
def test_representation(self):
test_period = RiskMetricsPeriod(
start_session=self.start_session,
end_session=self.end_session,
returns=self.algo_returns,
benchmark_returns=self.benchmark_returns,
trading_calendar=self.trading_calendar,
treasury_curves=self.env.treasury_curves,
)
metrics = [
"algorithm_period_returns",
"benchmark_period_returns",
"excess_return",
"num_trading_days",
"benchmark_volatility",
"algorithm_volatility",
"sharpe",
"sortino",
"information",
"beta",
"alpha",
"max_drawdown",
"max_leverage",
"algorithm_returns",
"benchmark_returns",
]
representation = test_period.__repr__()
assert all([metric in representation for metric in metrics])
| magne-max/zipline-ja | tests/risk/test_risk_period.py | Python | apache-2.0 | 23,082 |
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2007-2009 Stephane Charette
# Copyright (C) 2009 Gary Burton
# Contribution 2009 by Bob Ham <rah@bash.sh>
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2012-2013 Paul Franklin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
""" a ReportDialog customized for Graphviz-based reports """
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
import os
#-------------------------------------------------------------------------------
#
# GTK+ modules
#
#-------------------------------------------------------------------------------
from gi.repository import Gtk
from gi.repository import GObject
#-------------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.config import config
from gramps.gen.plug.report import CATEGORY_GRAPHVIZ
from ._reportdialog import ReportDialog
from ._papermenu import PaperFrame
import gramps.gen.plug.docgen.graphdoc as graphdoc
from gramps.gen.plug.menu import Menu
#-------------------------------------------------------------------------------
#
# GraphvizFormatComboBox
#
#-------------------------------------------------------------------------------
class GraphvizFormatComboBox(Gtk.ComboBox):
"""
Combo box class for Graphviz report format choices.
"""
def set(self, active=None):
""" initialize the Graphviz choices """
store = Gtk.ListStore(GObject.TYPE_STRING)
self.set_model(store)
cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
index = 0
active_index = 0
for item in graphdoc.FORMATS:
name = item["descr"]
store.append(row=[name])
if item['type'] == active:
active_index = index
index += 1
self.set_active(active_index)
def get_label(self):
""" get the format description """
return graphdoc.FORMATS[self.get_active()]["descr"]
def get_reference(self):
""" get the format class """
return graphdoc.FORMATS[self.get_active()]["class"]
def get_ext(self):
""" get the format extension """
return '.%s' % graphdoc.FORMATS[self.get_active()]['ext']
def get_clname(self):
""" get the report's output format type"""
return graphdoc.FORMATS[self.get_active()]["type"]
#-----------------------------------------------------------------------
#
# GraphvizReportDialog
#
#-----------------------------------------------------------------------
class GraphvizReportDialog(ReportDialog):
"""A class of ReportDialog customized for Graphviz-based reports."""
def __init__(self, dbstate, uistate, opt, name, translated_name):
"""Initialize a dialog to request that the user select options
for a Graphviz report. See the ReportDialog class for
more information."""
self.category = CATEGORY_GRAPHVIZ
self.__gvoptions = graphdoc.GVOptions()
self.dbname = dbstate.db.get_dbname()
ReportDialog.__init__(self, dbstate, uistate, opt,
name, translated_name)
self.doc = None # keep pylint happy
self.format = None
self.paper_label = None
def init_options(self, option_class):
try:
if issubclass(option_class, object): # Old-style class
self.options = option_class(self.raw_name,
self.dbstate.get_database())
except TypeError:
self.options = option_class
menu = Menu()
self.__gvoptions.add_menu_options(menu)
for category in menu.get_categories():
for name in menu.get_option_names(category):
option = menu.get_option(category, name)
self.options.add_menu_option(category, name, option)
self.options.load_previous_values()
def init_interface(self):
ReportDialog.init_interface(self)
self.doc_type_changed(self.format_menu)
self.notebook.set_current_page(1) # don't start on "Paper Options"
def setup_format_frame(self):
"""Set up the format frame of the dialog."""
self.format_menu = GraphvizFormatComboBox()
self.format_menu.set(self.options.handler.get_format_name())
self.format_menu.connect('changed', self.doc_type_changed)
label = Gtk.Label(label=_("%s:") % _("Output Format"))
label.set_halign(Gtk.Align.START)
self.grid.attach(label, 1, self.row, 1, 1)
self.format_menu.set_hexpand(True)
self.grid.attach(self.format_menu, 2, self.row, 2, 1)
self.row += 1
self.open_with_app = Gtk.CheckButton(_("Open with default viewer"))
self.open_with_app.set_active(
config.get('interface.open-with-default-viewer'))
self.grid.attach(self.open_with_app, 2, self.row, 2, 1)
self.row += 1
ext = self.format_menu.get_ext()
if ext is None:
ext = ""
else:
spath = self.get_default_directory()
if self.options.get_output():
base = os.path.basename(self.options.get_output())
else:
if self.dbname is None:
default_name = self.raw_name
else:
default_name = self.dbname + "_" + self.raw_name
base = "%s%s" % (default_name, ext) # "ext" already has a dot
spath = os.path.normpath(os.path.join(spath, base))
self.target_fileentry.set_filename(spath)
def setup_report_options_frame(self):
self.paper_label = Gtk.Label(label='<b>%s</b>' % _("Paper Options"))
self.paper_label.set_use_markup(True)
handler = self.options.handler
self.paper_frame = PaperFrame(
handler.get_paper_metric(),
handler.get_paper_name(),
handler.get_orientation(),
handler.get_margins(),
handler.get_custom_paper_size())
self.notebook.insert_page(self.paper_frame, self.paper_label, 0)
self.paper_frame.show_all()
ReportDialog.setup_report_options_frame(self)
def doc_type_changed(self, obj):
"""
This routine is called when the user selects a new file
format for the report. It adjusts the various dialog sections
to reflect the appropriate values for the currently selected
file format. For example, a HTML document doesn't need any
paper size/orientation options, but it does need a template
file. Those changes are made here.
"""
self.open_with_app.set_sensitive(True)
fname = self.target_fileentry.get_full_path(0)
(spath, ext) = os.path.splitext(fname)
ext_val = obj.get_ext()
if ext_val:
fname = spath + ext_val
else:
fname = spath
self.target_fileentry.set_filename(fname)
output_format_str = obj.get_clname()
if output_format_str in ['gvpdf', 'gspdf', 'ps']:
# Always use 72 DPI for PostScript and PDF files.
self.__gvoptions.dpi.set_value(72)
self.__gvoptions.dpi.set_available(False)
else:
self.__gvoptions.dpi.set_available(True)
if output_format_str in ['gspdf', 'dot']:
# Multiple pages only valid for dot and PDF via GhostsScript.
self.__gvoptions.h_pages.set_available(True)
self.__gvoptions.v_pages.set_available(True)
else:
self.__gvoptions.h_pages.set_value(1)
self.__gvoptions.v_pages.set_value(1)
self.__gvoptions.h_pages.set_available(False)
self.__gvoptions.v_pages.set_available(False)
def make_document(self):
"""Create a document of the type requested by the user.
"""
pstyle = self.paper_frame.get_paper_style()
self.doc = self.format(self.options, pstyle)
self.options.set_document(self.doc)
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Validate
the output file name before doing anything else. If there is
a file name, gather the options and create the report."""
# Is there a filename? This should also test file permissions, etc.
if not self.parse_target_frame():
self.window.run()
# Preparation
self.parse_format_frame()
self.parse_user_options()
self.options.handler.set_paper_metric(
self.paper_frame.get_paper_metric())
self.options.handler.set_paper_name(
self.paper_frame.get_paper_name())
self.options.handler.set_orientation(
self.paper_frame.get_orientation())
self.options.handler.set_margins(
self.paper_frame.get_paper_margins())
self.options.handler.set_custom_paper_size(
self.paper_frame.get_custom_paper_size())
# Create the output document.
self.make_document()
# Save options
self.options.handler.save_options()
config.set('interface.open-with-default-viewer',
self.open_with_app.get_active())
def parse_format_frame(self):
"""Parse the format frame of the dialog. Save the user
selected output format for later use."""
self.format = self.format_menu.get_reference()
format_name = self.format_menu.get_clname()
self.options.handler.set_format_name(format_name)
def setup_style_frame(self):
"""Required by ReportDialog"""
pass
| beernarrd/gramps | gramps/gui/plug/report/_graphvizreportdialog.py | Python | gpl-2.0 | 10,695 |
import os
import re
import string
from itertools import chain
from .detector_morse import Detector
from .detector_morse import slurp
# from .penn_treebank_tokenizer import word_tokenize
import nlup
from pug.nlp.constant import DATA_PATH
from pug.nlp.util import generate_files
# regex namespace only conflicts with regex kwarg in Tokenizer constructur
from pug.nlp.regex import CRE_TOKEN, RE_NONWORD
def list_ngrams(token_list, n=1, join=' '):
"""Return a list of n-tuples, one for each possible sequence of n items in the token_list
Arguments:
join (bool or str): if str, then join ngrom tuples on it before returning
True is equivalent to join=' '
default = True
See: http://stackoverflow.com/a/30609050/623735
>>> list_ngrams('goodbye cruel world'.split(), join=False)
[('goodbye',), ('cruel',), ('world',)]
>>> list_ngrams('goodbye cruel world'.split(), 2, join=False)
[('goodbye', 'cruel'), ('cruel', 'world')]
"""
join = ' ' if join is True else join
if isinstance(join, basestring):
return [join.join(ng) for ng in list_ngrams(token_list, n=n, join=False)]
return zip(*[token_list[i:] for i in range(n)])
def list_ngram_range(token_list, *args, **kwargs):
"""Return a list of n-tuples, one for each possible sequence of n items in the token_list
Arguments:
join (bool or str): if str, then join ngrom tuples on it before returning
True is equivalent to join=' '
default = True
>>> list_ngram_range('goodbye cruel world'.split(), 0, 2, join=False)
[('goodbye',), ('cruel',), ('world',), ('goodbye', 'cruel'), ('cruel', 'world')]
>>> list_ngram_range('goodbye cruel world'.split(), 2, join=False)
[('goodbye',), ('cruel',), ('world',), ('goodbye', 'cruel'), ('cruel', 'world')]
>>> list_ngram_range('goodbye cruel world'.split(), 0, 2, join='|')
['goodbye', 'cruel', 'world', 'goodbye|cruel', 'cruel|world']
>>> list_ngram_range('goodbye cruel world'.split(), 0, 2, join=True)
['goodbye', 'cruel', 'world', 'goodbye cruel', 'cruel world']
"""
m, n = (args if len(args) > 1 else ((0, args[0]) if args else (0, 1)))
join = args[2] if len(args) > 2 else kwargs.pop('join', True)
return list(chain(*(list_ngrams(token_list, i + 1, join=join) for i in range(0, n))))
def generate_sentences(text='', train_path=None, case_sensitive=True, epochs=20, classifier=nlup.BinaryAveragedPerceptron, **kwargs):
"""Generate sentences from a sequence of characters (text)
Thin wrapper for Kyle Gorman's "DetectorMorse" module
Arguments:
case_sensitive (int): whether to consider case to make decisions about sentence boundaries
epochs (int): number of epochs (iterations for classifier training)
"""
if train_path:
generate_sentences.detector = Detector(slurp(train_path), epochs=epochs, nocase=not case_sensitive)
# generate_sentences.detector = SentenceDetector(text=text, nocase=not case_sensitive, epochs=epochs, classifier=classifier)
return iter(generate_sentences.detector.segments(text))
generate_sentences.detector = nlup.decorators.IO(Detector.load)(os.path.join(DATA_PATH, 'wsj_detector_morse_model.json.gz'))
def str_strip(s, strip_chars=string.punctuation + ' \t\n\r'):
return s.strip(strip_chars)
def str_lower(s):
return s.lower()
def to_ascii(s, filler='-'):
if not s:
return ''
if not isinstance(s, basestring): # e.g. np.nan
return to_ascii(repr(s))
try:
return s.encode('utf8')
except:
return ''.join(c if c < chr(128) else filler for c in s if c)
stringify = to_ascii
def passthrough(s):
return s
class Tokenizer(object):
"""Callable and iterable class that yields substrings split on spaces or other configurable delimitters.
For both __init__ and __call__, doc is the first arg.
TODO: All args and functionality of __init__() and __call__() should be the same.
FIXME: Implement the `nltk.tokenize.TokenizerI` interface
Is it at all pythonic to make a class callable and iterable?
Is it pythonic to have to instantiate a TokenizerI instance and then call that instance's `tokenize` method?
>>> abc = (chr(ord('a') + (i % 26)) for i in xrange(1000))
>>> tokenize = Tokenizer(ngrams=5)
>>> ans = list(tokenize(' '.join(abc)))
>>> ans[:7]
['a', 'b', 'c', 'd', 'e', 'f', 'g']
>>> ans[1000:1005]
['a b', 'b c', 'c d', 'd e', 'e f']
>>> ans[1999:2004]
['a b c', 'b c d', 'c d e', 'd e f', 'e f g']
>>> tokenize = Tokenizer(stem='Porter')
>>> doc = "Here're some stemmable words provided to you for your stemming pleasure."
>>> sorted(set(tokenize(doc)) - set(Tokenizer(doc, stem='Lancaster')))
[u"Here'r", u'pleasur', u'some', u'stemmabl', u'your']
>>> sorted(set(Tokenizer(doc, stem='WordNet')) - set(Tokenizer(doc, stem='Lancaster')))
["Here're", 'pleasure', 'provided', 'some', 'stemmable', 'stemming', 'your']
"""
def __init__(self, doc=None, regex=CRE_TOKEN, strip=True, nonwords=False, nonwords_set=None, nonwords_regex=RE_NONWORD,
lower=None, stem=None, ngrams=1):
# specific set of characters to strip
self.strip_chars = None
if isinstance(strip, basestring):
self.strip_chars = strip
# strip_chars takes care of the stripping config, so no need for strip function anymore
self.strip = None
elif strip is True:
self.strip_chars = '-_*`()"' + '"'
strip = strip or None
# strip whitespace, overrides strip() method
self.strip = strip if callable(strip) else (str_strip if strip else None)
self.doc = to_ascii(doc)
self.regex = regex
if isinstance(self.regex, basestring):
self.regex = re.compile(self.regex)
self.nonwords = nonwords # whether to use the default REGEX for nonwords
self.nonwords_set = nonwords_set or set()
self.nonwords_regex = nonwords_regex
self.lower = lower if callable(lower) else (str_lower if lower else None)
self.stemmer_name, self.stem = 'passthrough', passthrough # stem can be a callable Stemmer instance or just a function
self.ngrams = ngrams or 1 # ngram degree, numger of ngrams per token
if isinstance(self.nonwords_regex, basestring):
self.nonwords_regex = re.compile(self.nonwords_regex)
elif self.nonwords:
try:
self.nonwords_set = set(self.nonwords)
except TypeError:
self.nonwords_set = set(['None', 'none', 'and', 'but'])
# if a set of nonwords has been provided dont use the internal nonwords REGEX?
self.nonwords = not bool(self.nonwords)
def __call__(self, doc):
"""Lazily tokenize a new document (tokens aren't generated until the class instance is iterated)
>>> list(Tokenizer()('new string to parse'))
['new', 'string', 'to', 'parse']
"""
# tokenization doesn't happen until you try to iterate through the Tokenizer instance or class
self.doc = to_ascii(doc)
# need to return self so that this will work: Tokenizer()('doc (str) to parse even though default doc is None')
return self
# to conform to this part of the nltk.tokenize.TokenizerI interface
tokenize = __call__
def __reduce__(self):
"""Unpickling constructor and args so that pickling can be done efficiently without any bound methods, etc"""
return (Tokenizer, (None, self.regex, self.strip, self.nonwords, self.nonwords_set, self.nonwords_regex,
self.lower, self.stemmer_name, self.ngrams))
def span_tokenize(self, s):
"""Identify the tokens using integer offsets `(start_i, end_i)` rather than copying them to a new sequence
The sequence of tokens (strings) can be generated with
`s[start_i:end_i] for start_i, end_i in span_tokenize(s)`
Returns:
generator of 2-tuples of ints, like ((int, int) for token in s)
"""
return
# raise NotImplementedError("span_tokenizer interface not yet implemented, so just suck it up and use RAM to tokenize() ;)")
def tokenize_sents(self, strings):
"""NTLK.
Apply ``self.tokenize()`` to each element of ``strings``. I.e.:
return [self.tokenize(s) for s in strings]
:rtype: list(list(str))
"""
return [self.tokenize(s) for s in strings]
def span_tokenize_sents(self, strings):
"""
Apply ``self.span_tokenize()`` to each element of ``strings``. I.e.:
return iter((self.span_tokenize(s) for s in strings))
:rtype: iter(list(tuple(int, int)))
"""
for s in strings:
yield list(self.span_tokenize(s))
def __iter__(self, ngrams=None):
r"""Generate a sequence of words or tokens, using a re.match iteratively through the str
TODO:
- need two different self.lower and lemmatize transforms, 1 before and 1 after nonword detection
- each of 3 nonword filters on a separate line, setting w=None when nonword "hits"
- refactor `nonwords` arg/attr to `ignore_stopwords` to be more explicit
>>> doc = "John D. Rock\n\nObjective: \n\tSeeking a position as Software --Architect-- / _Project Lead_ that can utilize my expertise and"
>>> doc += " experiences in business application development and proven records in delivering 90's software. "
>>> doc += "\n\nSummary: \n\tSoftware Architect"
>>> doc += " who has gone through several full product-delivery life cycles from requirements gathering to deployment / production, and"
>>> doc += " skilled in all areas of software development from client-side JavaScript to database modeling. With strong experiences in:"
>>> doc += " \n\tRequirements gathering and analysis."
The python splitter will produce 2 tokens that are only punctuation ("/")
>>> len([s for s in doc.split() if s])
72
The built-in nonword REGEX ignores all-punctuation words, so there are 2 less here:
>>> len(list(Tokenizer(doc, strip=False, nonwords=False)))
70
In addition, punctuation at the end of tokens is stripped so "D. Rock" doesn't tokenize to "D." but rather "D"
>>> run_together_tokens = ''.join(list(Tokenizer(doc, strip=False, nonwords=False)))
>>> '/' in run_together_tokens or ':' in ''.join(run_together_tokens)
False
But you can turn off stripping when instantiating the object.
>>> all(t in Tokenizer(doc, strip=False, nonwords=True) for t in ('D', '_Project', 'Lead_', "90's", "product-delivery"))
True
"""
ngrams = ngrams or self.ngrams
# FIXME: Improve memory efficiency by making this ngram tokenizer an actual generator
if ngrams > 1:
original_tokens = list(self.__iter__(ngrams=1))
for tok in original_tokens:
yield tok
for i in range(2, ngrams + 1):
for tok in list_ngrams(original_tokens, n=i, join=' '):
yield tok
else:
for w in self.regex.finditer(self.doc):
if w:
w = w.group()
w = w if not self.strip_chars else str_strip(w, self.strip_chars)
w = w if not self.strip else self.strip(w)
w = w if not self.stem else self.stem(w)
w = w if not self.lemmatize else self.lemmatize(w)
w = w if not self.lower else self.lower(w)
# FIXME: nonword check before and after preprossing? (lower, lemmatize, strip, stem)
# 1. check if the default nonwords REGEX filter is requested, if so, use it.
# 2. check if a customized nonwords REGES filter is provided, if so, use it.
# 3. make sure the word isn't in the provided (or empty) set of nonwords
if w and (not self.nonwords or not re.match(r'^' + RE_NONWORD + '$', w)) and (
not self.nonwords_regex or not self.nonwords_regex.match(w)) and (
w not in self.nonwords_set):
yield w
# can these all just be left to default assignments in __init__ or as class methods assigned to global `passthrough()`
def strip(self, s):
"""Strip punctuation surrounding a token"""
return s
def stem(self, s):
"""Find the lexial root of a word, e.g. convert 'running' to 'run'"""
return s
def lemmatize(self, s):
"""Find the semantic root of a word, e.g. convert 'was' to 'be'"""
return s
def __getstate__(self):
return self.__dict__
def __setstate__(self, d):
self.__dict__.update(d)
class PassageIter(object):
"""Passage (document, sentence, line, phrase) generator for files at indicated path
Walks all the text files it finds in the indicated path,
segmenting sentences and yielding them one at a time
References:
Radim's [word2vec tutorial](http://radimrehurek.com/2014/02/word2vec-tutorial/)
"""
def __init__(self, path='', ext='', level=None, dirs=False, files=True,
sentence_segmenter=generate_sentences, word_segmenter=string.split, verbosity=0):
self.file_generator = generate_files(path=path, ext='', level=None, dirs=False, files=True, verbosity=0)
def __iter__(self):
for fname in os.listdir(self.file_generator):
for line in open(os.path.join(self.dirname, fname)):
yield line.split()
| hobson/pug-nlp | pug/nlp/segmentation.py | Python | mit | 13,806 |
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.
import os
# This must be run before importing Django.
os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'
from django.core.management.base import BaseCommand
from django_rq.queues import get_failed_queue
class Command(BaseCommand):
help = "Retry failed RQ jobs."
def handle(self, **options):
failed_queue = get_failed_queue()
for job_id in failed_queue.get_job_ids():
failed_queue.requeue(job_id=job_id)
| ta2-1/pootle | pootle/apps/pootle_app/management/commands/retry_failed_jobs.py | Python | gpl-3.0 | 727 |
""" Helpers to allow vncdotool to be intergrated into other applications.
This feature is under developemental, you're help testing and
debugging is appreciated.
"""
import threading
try:
import queue
except ImportError:
import Queue as queue
import logging
from twisted.internet import reactor
from twisted.internet.defer import maybeDeferred
from twisted.python.log import PythonLoggingObserver
from twisted.python.failure import Failure
from . import command
from .client import VNCDoToolFactory
__all__ = ['connect']
log = logging.getLogger('vncdotool.api')
_THREAD = None
class VNCDoException(Exception):
pass
def connect(server, password=None):
""" Connect to a VNCServer and return a Client instance that is usable
in the main thread of non-Twisted Python Applications, EXPERIMENTAL.
>>> from vncdotool import api
>>> client = api.connect('host')
>>> client.keyPress('c')
>>> api.shutdown()
You may then call any regular VNCDoToolClient method on client from your
application code.
If you are using a GUI toolkit or other major async library please read
http://twistedmatrix.com/documents/13.0.0/core/howto/choosing-reactor.html
for a better method of intergrating vncdotool.
"""
if not reactor.running:
global _THREAD
_THREAD = threading.Thread(target=reactor.run, name='Twisted',
kwargs={'installSignalHandlers': False})
_THREAD.daemon = True
_THREAD.start()
observer = PythonLoggingObserver()
observer.start()
factory = VNCDoToolFactory()
if password is not None:
factory.password = password
host, port = command.parse_host(server)
client = ThreadedVNCClientProxy(factory)
client.connect(host, port)
return client
def shutdown():
if not reactor.running:
return
reactor.callFromThread(reactor.stop)
_THREAD.join()
class ThreadedVNCClientProxy(object):
def __init__(self, factory):
self.factory = factory
self.queue = queue.Queue()
def connect(self, host, port=5900):
reactor.callWhenRunning(reactor.connectTCP, host, port, self.factory)
def disconnect(self):
def disconnector(protocol):
protocol.transport.loseConnection()
reactor.callFromThread(self.factory.deferred.addCallback, disconnector)
def __getattr__(self, attr):
method = getattr(self.factory.protocol, attr)
def errback(reason, *args, **kwargs):
self.queue.put(Failure(reason))
def callback(protocol, *args, **kwargs):
def result_callback(result):
self.queue.put(result)
return result
d = maybeDeferred(method, protocol, *args, **kwargs)
d.addBoth(result_callback)
return d
def proxy_call(*args, **kwargs):
reactor.callFromThread(self.factory.deferred.addCallbacks,
callback, errback, args, kwargs)
result = self.queue.get(timeout=60 * 60)
if isinstance(result, Failure):
raise VNCDoException(result)
return result
return proxy_call
if __name__ == '__main__':
import sys
logging.basicConfig(level=logging.DEBUG)
server = sys.argv[1]
password = sys.argv[2]
client1 = connect(server, password)
client2 = connect(server, password)
client1.captureScreen('screenshot.png')
for key in 'username':
client2.keyPress(key)
for key in 'passw0rd':
client1.keyPress(key)
client1.disconnect()
client2.disconnect()
shutdown()
| jamtwister/vncdotool | vncdotool/api.py | Python | mit | 3,674 |
from lxml import html
from .Form import build
from artemis.handlers.HandlerRules import getHandler
from artemis.Task import buildFromURI, Task, AuthNature
import formasaurus
class FormHandler :
def __init__(self):
pass
def extract(self, url, nature ):
task = TaskFactory.buildFromURI( url, Task(auth=AuthNature.no ))
handler = getHandler(task)("*", "*/*;", None) #pas de cache
contentTypes, tmpFile, newTasks = handler.execute( task )
doc = html.document_fromstring(str(tmpFile.read()), base_url=task.url)
forms= []
for form, cl in formasaurus.extract_forms(doc):
if nature == cl :
forms.append( build( url, html.tostring(form), nature ) )
return forms
def extractOne(self, url, nature ):
task = TaskFactory.buildFromURI( url, Task(auth=AuthNature.no ))
handler = getHandler(task)("*", "*/*", None)
contentType, tmpFile, redirectionTasks = handler.execute( task )
if not tmpFile:
return None
tmpFile.seek(0)
doc = html.document_fromstring(str(tmpFile.read()), base_url=task.url)
ex = FormExtractor.load()
for form, cl in ex.extract_forms(doc):
if nature.value == cl:
return build( url, form, nature)
| athena-project/Artemis | src/accreditation/FormHandler.py | Python | gpl-2.0 | 1,176 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from importlib import import_module
from django import VERSION as DJANGO_VERSION
from django.conf import settings
# Do we support set_required and set_disabled?
# See GitHub issues 337 and 345
# TODO: Get rid of this after support for Django 1.8 LTS ends
DBS3_SET_REQUIRED_SET_DISABLED = DJANGO_VERSION[0] < 2 and DJANGO_VERSION[1] < 10
# Default settings
BOOTSTRAP3_DEFAULTS = {
'jquery_url': '//code.jquery.com/jquery.min.js',
'base_url': '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/',
'css_url': None,
'theme_url': None,
'javascript_url': None,
'javascript_in_head': False,
'include_jquery': False,
'horizontal_label_class': 'col-md-3',
'horizontal_field_class': 'col-md-9',
'set_placeholder': True,
'required_css_class': '',
'error_css_class': 'has-error',
'success_css_class': 'has-success',
'formset_renderers': {
'default': 'bootstrap3.renderers.FormsetRenderer',
},
'form_renderers': {
'default': 'bootstrap3.renderers.FormRenderer',
},
'field_renderers': {
'default': 'bootstrap3.renderers.FieldRenderer',
'inline': 'bootstrap3.renderers.InlineFieldRenderer',
},
}
if DBS3_SET_REQUIRED_SET_DISABLED:
BOOTSTRAP3_DEFAULTS.update({
'set_required': True,
'set_disabled': False,
})
# Start with a copy of default settings
BOOTSTRAP3 = BOOTSTRAP3_DEFAULTS.copy()
# Override with user settings from settings.py
BOOTSTRAP3.update(getattr(settings, 'BOOTSTRAP3', {}))
def get_bootstrap_setting(setting, default=None):
"""
Read a setting
"""
return BOOTSTRAP3.get(setting, default)
def bootstrap_url(postfix):
"""
Prefix a relative url with the bootstrap base url
"""
return get_bootstrap_setting('base_url') + postfix
def jquery_url():
"""
Return the full url to jQuery file to use
"""
return get_bootstrap_setting('jquery_url')
def javascript_url():
"""
Return the full url to the Bootstrap JavaScript file
"""
return get_bootstrap_setting('javascript_url') or \
bootstrap_url('js/bootstrap.min.js')
def css_url():
"""
Return the full url to the Bootstrap CSS file
"""
return get_bootstrap_setting('css_url') or \
bootstrap_url('css/bootstrap.min.css')
def theme_url():
"""
Return the full url to the theme CSS file
"""
return get_bootstrap_setting('theme_url')
def get_renderer(renderers, **kwargs):
layout = kwargs.get('layout', '')
path = renderers.get(layout, renderers['default'])
mod, cls = path.rsplit(".", 1)
return getattr(import_module(mod), cls)
def get_formset_renderer(**kwargs):
renderers = get_bootstrap_setting('formset_renderers')
return get_renderer(renderers, **kwargs)
def get_form_renderer(**kwargs):
renderers = get_bootstrap_setting('form_renderers')
return get_renderer(renderers, **kwargs)
def get_field_renderer(**kwargs):
renderers = get_bootstrap_setting('field_renderers')
return get_renderer(renderers, **kwargs)
| thodoris/djangoPharma | djangoPharma/env/Lib/site-packages/bootstrap3/bootstrap.py | Python | apache-2.0 | 3,125 |
#! /usr/bin/python
__author__="Ashish Hunnargikar"
__date__ ="$Jun 13, 2014 12:33:33 PM$"
import time
import random
import subprocess
import os
import uuid
import datetime
from elasticsearch.transport import Transport
from elasticsearch import (Elasticsearch, RoundRobinSelector, ImproperlyConfigured, ElasticsearchException,
SerializationError, TransportError, NotFoundError, ConflictError, RequestError, ConnectionError)
import simplejson as json
from kazoo.client import KazooClient
from kazoo.exceptions import (
KazooException
)
os.environ['DEBUG'] = 'true'
#os.environ['REGISTRY_ADDR'] = '192.168.57.101:5000'
#os.environ['ES_CLUSTER'] = 'elasticsearch'
#os.environ['ZK_ADDRESS'] = 'zookeeper1:2181,zookeeper2:2181,zookeeper3:2181'
#os.environ['ES_INDEX'] = 'docker_registry'
#os.environ['LIBPROCESS_IP'] = '192.168.57.101'
#os.environ['SIZE_RANGE_START'] = '2'
#os.environ['SIZE_RANGE_END'] = '3'
es = None
import traceback
def log(data):
"""
Print debug output
"""
if (os.environ['DEBUG'] == 'true'):
print(data + '\n')
def initiate_load_test(repository):
"""
Build a Busybox Dockerfile with dynamic layers and push the image to the Docker registry
"""
#1. Generate a random unique tag
timestamp = str(time.time())
sizeRange = str(random.randint(int(os.environ['SIZE_RANGE_START']), int(os.environ['SIZE_RANGE_END'])))
tag = timestamp + sizeRange
document = {}
document['id'] = 'paas_' + repository + '_' + tag
document['size'] = sizeRange
document['start-time'] = timestamp
document['command'] = 'docker pull ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag
#2. Create a randomly-sized file layer
create_file(repository, sizeRange)
#3. Create a new Dockerfile with random metadata
create_dockerfile(repository, tag)
#4. Build the Docker image
start = datetime.datetime.now()
document['build'] = build(repository, tag)
end = datetime.datetime.now()
document['build-time'] = (end - start).total_seconds()
#5. Push the Docker image
start = datetime.datetime.now()
#Try 3 times to push the docker image in the event of failure
for pushes in range(3):
try:
document['push'] = push(repository, tag)
if (document['push'] == 'false'):
continue
except Exception:
log("Push Exception!" + traceback.format_exc())
continue
finally:
log("Total number of Docker push attempts: " + str(pushes + 1))
break
end = datetime.datetime.now()
document['push-time'] = (end - start).total_seconds()
document['push-tries'] = pushes + 1
#6. Remove the Docker image
start = datetime.datetime.now()
document['rmi'] = rmi(repository, tag)
end = datetime.datetime.now()
document['rmi-time'] = (end - start).total_seconds()
#7. Pull the Docker image
start = datetime.datetime.now()
document['pull'] = pull(repository, tag)
end = datetime.datetime.now()
document['pull-time'] = (end - start).total_seconds()
#8. Run the Docker image
start = datetime.datetime.now()
document['run'] = run(repository, tag, sizeRange)
end = datetime.datetime.now()
document['run-time'] = (end - start).total_seconds()
#9. Clean up the generated Docker image and associated containers
cleanup(repository, tag)
#10. Verify that the index contains the image layers
start = datetime.datetime.now()
document['get'], document['get-tries'] = get_from_index(os.environ['ES_INDEX'], 'tags', document['id'])
end = datetime.datetime.now()
document['get-time'] = (end - start).total_seconds()
#11. Analytics
document['end-time'] = str(time.time())
document['host'] = os.environ['LIBPROCESS_IP']
log(json.dumps(document))
set_in_index(document, 'analytics', 'data')
def create_file(repository, range):
"""
Creates randomly sized file on disk using the system entropy
@type repository: String
@param repository: Docker image repository name
@type range: Integer
@param range: File size
"""
log('App Name : ' + repository)
log('File size : ' + range + 'MB')
command = 'dd if=/dev/urandom of=file.txt bs=' + range + 'M count=1'
subprocess.call(command, shell=True)
def create_dockerfile(repository, tag):
"""
Creates a Dockerfile and includes an ADD instruction for the randomly generated file
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
"""
metadata = get_random_metadata()
Dockerfile = open('Dockerfile', 'w')
Dockerfile.write('FROM busybox\n')
Dockerfile.write('MAINTAINER ' + metadata + '\n')
Dockerfile.write('ADD file.txt file.txt\n')
Dockerfile.close()
def build(repository, tag):
"""
Builds a new Docker image using a pre-generated Dockerfile using the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
@return: True if successful otherwise false
"""
p = subprocess.Popen(['docker build --rm -t ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag + ' .'], stdout=subprocess.PIPE, shell=True)
output, error = p.communicate()
log('BUILD OUTPUT :: ' + json.dumps(output))
if error is None and 'Successfully built' in output:
return 'true'
else:
log('BUILD OUTPUT :: ' + json.dumps(output))
log('*********BUILD ERROR :: ' + json.dumps(error))
return 'false'
def push(repository, tag):
"""
Pushes the pre-built Docker image into the Docker registry via the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
@return: True if successful otherwise false
"""
log('docker push ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag)
p = subprocess.Popen(['docker push ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag], stdout=subprocess.PIPE, shell=True)
output, error = p.communicate()
log('PUSH OUTPUT :: ' + json.dumps(output))
if error is None and 'Pushing tag for rev' in output:
return 'true'
else:
log('PUSH OUTPUT :: ' + json.dumps(output))
log('*********PUSH ERROR :: ' + json.dumps(error))
return 'false'
def rmi(repository, tag):
"""
Removes a pre-built Docker image via the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
@return: True if successful otherwise false
"""
p = subprocess.Popen(['docker rmi -f ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag], stdout=subprocess.PIPE, shell=True)
output, error = p.communicate()
log('RMI OUTPUT :: ' + json.dumps(output))
if error is None and 'Untagged' in output:
return 'true'
else:
log('RMI OUTPUT :: ' + json.dumps(output))
log('*********RMI ERROR :: ' + json.dumps(error))
return 'false'
def pull(repository, tag):
"""
Pulls a new Docker image and tag from the Docker registry via the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
@return: True if successful otherwise false
"""
p = subprocess.Popen(['docker pull ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag], stdout=subprocess.PIPE, shell=True)
output, error = p.communicate()
log('PULL OUTPUT :: ' + json.dumps(output))
if error is None and output is not None and 'Pulling repository' in output:
return 'true'
else:
log('PULL OUTPUT :: ' + json.dumps(output))
log('*********PULL ERROR :: ' + json.dumps(error))
return 'false'
def run(repository, tag, range):
"""
Runs a Docker image via the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
@return: True if successful otherwise false
"""
p = subprocess.Popen(['docker run -t ' + os.environ['REGISTRY_ADDR'] + '/paas/' + repository + ':' + tag + ' du -ms file.txt | cut -f1'], stdout=subprocess.PIPE, shell=True)
output, error = p.communicate()
log('RUN OUTPUT :: ' + json.dumps(output))
if error is None and output is not None and output != '' and int(range) == int(output.replace('\n', '')):
return 'true'
else:
log('RUN OUTPUT :: ' + json.dumps(output))
log('**********RUN ERROR :: ' + json.dumps(error))
return 'false'
def cleanup(repository, tag):
"""
Cleans up the Docker image via the Docker cli client
@type repository: String
@param repository: Docker image repository name
@type tag: String
@param tag: Docker repository tag name
"""
p = os.popen('docker rm `docker ps -a -q`')
rmi(repository, tag)
def set_in_index(document, index, type):
"""
Store the list of documents in the Elasticsearch index via HTTP APIs
@type document: List
@param document: JSON document
"""
response = None
#Try 3 times to store the document in ES, each time picking a random ES node address in case of failure
for retries in range(3):
try:
document['epoch'] = int(time.time())
log('ES Set Request :: ' + json.dumps(document) + ' : ' + index + ':' + type)
response = es.index(index=index, doc_type=type, id=document['id'], body=document)
log("ES Set Response :: " + json.dumps(response))
except ImproperlyConfigured:
log("ES ImproperlyConfigured!" + traceback.format_exc())
continue
except ElasticsearchException:
log("ES ElasticsearchException!" + traceback.format_exc())
continue
except TransportError:
log("ES TransportError!" + traceback.format_exc())
continue
except NotFoundError:
log("ES NotFoundError!" + traceback.format_exc())
continue
except ConflictError:
log("ES ConflictError!" + traceback.format_exc())
continue
except RequestError:
log("ES RequestError!" + traceback.format_exc())
continue
except SerializationError:
log("ES SerializationError!" + traceback.format_exc())
continue
except ConnectionError:
log("ES ConnectionError!" + traceback.format_exc())
continue
except Exception:
log("ES Exception!" + traceback.format_exc())
continue
finally:
log("Total number of ES write attempts: " + str(retries + 1))
#Exit for loop if ES transaction is successful otherwise pick another node and continue retrying
break
if response is None or response == '':
return 'false'
else:
return 'true'
def get_from_index(index, type, id):
"""
Get the Elasticsearch index data
@type documentList: List
@param documentList: List of image layer JSON documents
"""
response = None
#Try 3 times to read the document from ES, each time picking a random ES node address in case of failure
for retries in range(3):
try:
response = es.get(index=index, doc_type=type, id=id)
log("ES Get Response :: " + json.dumps(response))
except ImproperlyConfigured:
log("ES ImproperlyConfigured!" + traceback.format_exc())
continue
except ElasticsearchException:
log("ES ElasticsearchException!" + traceback.format_exc())
continue
except TransportError:
log("ES TransportError!" + traceback.format_exc())
continue
except NotFoundError:
log("ES NotFoundError!" + traceback.format_exc())
continue
except ConflictError:
log("ES ConflictError!" + traceback.format_exc())
continue
except RequestError:
log("ES RequestError!" + traceback.format_exc())
continue
except SerializationError:
log("ES SerializationError!" + traceback.format_exc())
continue
except ConnectionError:
log("ES ConnectionError!" + traceback.format_exc())
continue
except Exception:
log("ES Exception!" + traceback.format_exc())
continue
finally:
log("Total number of ES read attempts: " + str(retries + 1))
#Exit for loop if ES transaction is successful otherwise pick another node and continue retrying
break
if response is None or response == '':
return ('false', retries + 1)
else:
return ('true', retries + 1)
def get_es_node_addresses():
"""
Get the Elasticsearch node addresses via Zookeeper
@return List of Elasticsearch node ip addresses and ports
"""
zk = KazooClient(hosts=os.environ['ZK_ADDRESS'], timeout=10.0, randomize_hosts=True)
zk.start()
esNodes = []
try:
#Fetch the list of ES cluster node names from Zookeeper
zkPath = '/es/clusters/' + os.environ['ES_CLUSTER'] + '/json'
children = zk.get_children(zkPath)
#Retrieve the JSON metadata associated with each ephemeral ES node
for node in children:
zookeeperAddr = zkPath + '/' + node
esNodeInfo = zk.get(zookeeperAddr)
jsonData = json.loads(esNodeInfo[0])
#Collect each node ip address and port
esNodes.append(jsonData['address'] + ':' + jsonData['port'])
except KazooException:
log('Kazoo Exception: Unable to fetch Zookeeper data from ' + zkPath + ' : ' + traceback.format_exc());
zk.stop()
zk.close()
log('ES Node list retrieved from Zookeeper :: ' + json.dumps(esNodes))
return esNodes
def get_random_metadata():
"""
Generate random metadata blurb via Wikipedia
@return String containing a small paragraph of a random Wikipedia article
"""
p = os.popen('curl -L http://en.wikipedia.org/wiki/Special:Random | grep -o \'<p>.*</p>\' | sed -e \'s/<[^>]*>//g\'')
s = p.readline().replace('\n', '')
p.close()
log('######################################')
log('RANDOM METADATA :: ' + s)
log('######################################')
return s
#Overriding the default ES Sniffing mechanism with Zookeeper
class ZookeeperTransport(Transport):
def get_es_node_addresses(self):
"""
Get the Elasticsearch node addresses via Zookeeper
@return List of Elasticsearch node ip addresses and ports
"""
esNodes = []
#Initlate the Zookeeper Kazoo connection
#kz_retry = KazooRetry(max_tries=3, delay=0.5, backoff=2)
zk = KazooClient(hosts=os.environ['ZK_ADDRESS'], timeout=10.0, randomize_hosts=True)
zk.start()
try:
#Fetch the list of ES cluster node names from Zookeeper
zkPath = '/es/clusters/' + os.environ['ES_CLUSTER'] + '/json'
children = zk.get_children(zkPath)
#Retrieve the JSON metadata associated with each ephemeral ES node
for node in children:
zookeeperAddr = zkPath + '/' + node
esNodeInfo = zk.get(zookeeperAddr)
jsonData = json.loads(esNodeInfo[0])
#Collect each node ip address and port
host = {'host':jsonData['address'], 'port': int(jsonData['port'])}
esNodes.append(host)
except KazooException:
log('Kazoo Exception: Unable to fetch Zookeeper data from ' + zkPath + ' : ' + traceback.format_exc());
#Close and Zookeeper connection
zk.stop()
zk.close()
return esNodes
def sniff_hosts(self):
"""
Obtain a list of nodes from the cluster and create a new connection
pool using the information retrieved.
To extract the node connection parameters use the `nodes_to_host_callback`.
"""
previous_sniff = self.last_sniff
hosts = []
try:
# reset last_sniff timestamp
self.last_sniff = time.time()
try:
hosts = self.get_es_node_addresses()
except Exception:
raise TransportError("N/A", "Unable to sniff hosts." + traceback.format_exc())
except:
# keep the previous value on error
self.last_sniff = previous_sniff
raise
# we weren't able to get any nodes, maybe using an incompatible
# transport_schema or host_info_callback blocked all - raise error.
if not hosts:
raise TransportError("N/A", "Unable to sniff hosts - no viable hosts found." + traceback.format_exc())
self.set_connections(hosts)
if __name__ == "__main__":
#Initiate the ES connection pool
es = Elasticsearch(get_es_node_addresses(), sniff_on_start=True, sniff_on_connection_fail=True, max_retries=3, sniffer_timeout=180, selector_class=RoundRobinSelector, sniff_timeout=1, transport_class=ZookeeperTransport)
#Generate a unique namespace
repository=str(uuid.uuid4()).replace('-', '');
#initiate_load_test(repository)
#Run the Docker build-push-pull-run operation in an infinite loop
while True:
initiate_load_test(repository)
sleepInterval = random.randint(2,10)
log('Sleeping for ' + str(sleepInterval) + ' secs.....\n')
log('************************************\n')
time.sleep(sleepInterval)
| misho-kr/elasticsearchindex | loadtest/dockerpush.py | Python | apache-2.0 | 18,039 |
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
client = Client(account_sid, auth_token)
# A list of record objects with the properties described above
records = client.usage.records.list(
category="calls-inbound", start_date="2012-09-01", end_date="2012-09-30"
)
| teoreteetik/api-snippets | rest/usage-records/list-get-example-3/list-get-example-3.6.x.py | Python | mit | 472 |
# Copyright (c) 2010 OpenStack, LLC.
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# 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.
"""
Scheduler Service
"""
from oslo_config import cfg
from oslo_log import log
from oslo_service import periodic_task
from oslo_utils import excutils
from oslo_utils import importutils
from manila.common import constants
from manila import context
from manila import coordination
from manila import db
from manila import exception
from manila import manager
from manila.message import api as message_api
from manila.message import message_field
from manila import quota
from manila import rpc
from manila.share import rpcapi as share_rpcapi
LOG = log.getLogger(__name__)
scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
default='manila.scheduler.drivers.'
'filter.FilterScheduler',
help='Default scheduler driver to use.')
CONF = cfg.CONF
CONF.register_opt(scheduler_driver_opt)
# Drivers that need to change module paths or class names can add their
# old/new path here to maintain backward compatibility.
MAPPING = {
'manila.scheduler.chance.ChanceScheduler':
'manila.scheduler.drivers.chance.ChanceScheduler',
'manila.scheduler.filter_scheduler.FilterScheduler':
'manila.scheduler.drivers.filter.FilterScheduler',
'manila.scheduler.simple.SimpleScheduler':
'manila.scheduler.drivers.simple.SimpleScheduler',
}
class SchedulerManager(manager.Manager):
"""Chooses a host to create shares."""
RPC_API_VERSION = '1.8'
def __init__(self, scheduler_driver=None, service_name=None,
*args, **kwargs):
if not scheduler_driver:
scheduler_driver = CONF.scheduler_driver
if scheduler_driver in MAPPING:
msg_args = {
'old': scheduler_driver,
'new': MAPPING[scheduler_driver],
}
LOG.warning("Scheduler driver path %(old)s is deprecated, "
"update your configuration to the new path "
"%(new)s", msg_args)
scheduler_driver = MAPPING[scheduler_driver]
self.driver = importutils.import_object(scheduler_driver)
self.message_api = message_api.API()
super(self.__class__, self).__init__(*args, **kwargs)
def init_host(self):
ctxt = context.get_admin_context()
self.request_service_capabilities(ctxt)
def get_host_list(self, context):
"""Get a list of hosts from the HostManager."""
return self.driver.get_host_list()
def get_service_capabilities(self, context):
"""Get the normalized set of capabilities for this zone."""
return self.driver.get_service_capabilities()
def update_service_capabilities(self, context, service_name=None,
host=None, capabilities=None, **kwargs):
"""Process a capability update from a service node."""
if capabilities is None:
capabilities = {}
self.driver.update_service_capabilities(service_name,
host,
capabilities)
def create_share_instance(self, context, request_spec=None,
filter_properties=None):
try:
self.driver.schedule_create_share(context, request_spec,
filter_properties)
except exception.NoValidHost as ex:
self._set_share_state_and_notify(
'create_share', {'status': constants.STATUS_ERROR},
context, ex, request_spec,
message_field.Action.ALLOCATE_HOST)
except Exception as ex:
with excutils.save_and_reraise_exception():
self._set_share_state_and_notify(
'create_share', {'status': constants.STATUS_ERROR},
context, ex, request_spec)
def get_pools(self, context, filters=None):
"""Get active pools from the scheduler's cache."""
return self.driver.get_pools(context, filters)
def manage_share(self, context, share_id, driver_options, request_spec,
filter_properties=None):
"""Ensure that the host exists and can accept the share."""
def _manage_share_set_error(self, context, ex, request_spec):
# NOTE(nidhimittalhada): set size as 1 because design expects size
# to be set, it also will allow us to handle delete/unmanage
# operations properly with this errored share according to quotas.
self._set_share_state_and_notify(
'manage_share',
{'status': constants.STATUS_MANAGE_ERROR, 'size': 1},
context, ex, request_spec)
share_ref = db.share_get(context, share_id)
try:
self.driver.host_passes_filters(
context, share_ref['host'], request_spec, filter_properties)
except Exception as ex:
with excutils.save_and_reraise_exception():
_manage_share_set_error(self, context, ex, request_spec)
else:
share_rpcapi.ShareAPI().manage_share(context, share_ref,
driver_options)
def migrate_share_to_host(
self, context, share_id, host, force_host_assisted_migration,
preserve_metadata, writable, nondisruptive, preserve_snapshots,
new_share_network_id, new_share_type_id, request_spec,
filter_properties=None):
"""Ensure that the host exists and can accept the share."""
share_ref = db.share_get(context, share_id)
def _migrate_share_set_error(self, context, ex, request_spec):
instance = next((x for x in share_ref.instances
if x['status'] == constants.STATUS_MIGRATING),
None)
if instance:
db.share_instance_update(
context, instance['id'],
{'status': constants.STATUS_AVAILABLE})
self._set_share_state_and_notify(
'migrate_share_to_host',
{'task_state': constants.TASK_STATE_MIGRATION_ERROR},
context, ex, request_spec)
try:
tgt_host = self.driver.host_passes_filters(
context, host, request_spec, filter_properties)
except Exception as ex:
with excutils.save_and_reraise_exception():
_migrate_share_set_error(self, context, ex, request_spec)
else:
try:
share_rpcapi.ShareAPI().migration_start(
context, share_ref, tgt_host.host,
force_host_assisted_migration, preserve_metadata, writable,
nondisruptive, preserve_snapshots, new_share_network_id,
new_share_type_id)
except Exception as ex:
with excutils.save_and_reraise_exception():
_migrate_share_set_error(self, context, ex, request_spec)
def _set_share_state_and_notify(self, method, state, context, ex,
request_spec, action=None):
LOG.error("Failed to schedule %(method)s: %(ex)s",
{"method": method, "ex": ex})
properties = request_spec.get('share_properties', {})
share_id = request_spec.get('share_id', None)
if share_id:
db.share_update(context, share_id, state)
if action:
self.message_api.create(
context, action, context.project_id,
resource_type=message_field.Resource.SHARE,
resource_id=share_id, exception=ex)
payload = dict(request_spec=request_spec,
share_properties=properties,
share_id=share_id,
state=state,
method=method,
reason=ex)
rpc.get_notifier("scheduler").error(
context, 'scheduler.' + method, payload)
def request_service_capabilities(self, context):
share_rpcapi.ShareAPI().publish_service_capabilities(context)
def _set_share_group_error_state(self, method, context, ex,
request_spec, action=None):
LOG.warning("Failed to schedule_%(method)s: %(ex)s",
{"method": method, "ex": ex})
share_group_state = {'status': constants.STATUS_ERROR}
share_group_id = request_spec.get('share_group_id')
if share_group_id:
db.share_group_update(context, share_group_id, share_group_state)
if action:
self.message_api.create(
context, action, context.project_id,
resource_type=message_field.Resource.SHARE_GROUP,
resource_id=share_group_id, exception=ex)
@periodic_task.periodic_task(spacing=600, run_immediately=True)
def _expire_reservations(self, context):
quota.QUOTAS.expire(context)
def create_share_group(self, context, share_group_id, request_spec=None,
filter_properties=None):
try:
self.driver.schedule_create_share_group(
context, share_group_id, request_spec, filter_properties)
except exception.NoValidHost as ex:
self._set_share_group_error_state(
'create_share_group', context, ex, request_spec,
message_field.Action.ALLOCATE_HOST)
except Exception as ex:
with excutils.save_and_reraise_exception():
self._set_share_group_error_state(
'create_share_group', context, ex, request_spec)
def _set_share_replica_error_state(self, context, method, exc,
request_spec, action=None):
LOG.warning("Failed to schedule_%(method)s: %(exc)s",
{'method': method, 'exc': exc})
status_updates = {
'status': constants.STATUS_ERROR,
'replica_state': constants.STATUS_ERROR,
}
share_replica_id = request_spec.get(
'share_instance_properties').get('id')
# Set any snapshot instances to 'error'.
replica_snapshots = db.share_snapshot_instance_get_all_with_filters(
context, {'share_instance_ids': share_replica_id})
for snapshot_instance in replica_snapshots:
db.share_snapshot_instance_update(
context, snapshot_instance['id'],
{'status': constants.STATUS_ERROR})
db.share_replica_update(context, share_replica_id, status_updates)
if action:
self.message_api.create(
context, action, context.project_id,
resource_type=message_field.Resource.SHARE_REPLICA,
resource_id=share_replica_id, exception=exc)
def create_share_replica(self, context, request_spec=None,
filter_properties=None):
try:
self.driver.schedule_create_replica(context, request_spec,
filter_properties)
except exception.NoValidHost as exc:
self._set_share_replica_error_state(
context, 'create_share_replica', exc, request_spec,
message_field.Action.ALLOCATE_HOST)
except Exception as exc:
with excutils.save_and_reraise_exception():
self._set_share_replica_error_state(
context, 'create_share_replica', exc, request_spec)
@periodic_task.periodic_task(spacing=CONF.message_reap_interval,
run_immediately=True)
@coordination.synchronized('locked-clean-expired-messages')
def _clean_expired_messages(self, context):
self.message_api.cleanup_expired_messages(context)
| bswartz/manila | manila/scheduler/manager.py | Python | apache-2.0 | 12,711 |
#!/usr/bin/env python
# -*- test-case-name: calendarserver.tools.test.test_calverify -*-
##
# Copyright (c) 2011-2014 Apple 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.
##
from __future__ import print_function
"""
This tool allows data in the database to be directly inspected using a set
of simple commands.
"""
from calendarserver.tools import tables
from calendarserver.tools.cmdline import utilityMain, WorkerService
from pycalendar.datetime import DateTime
from twext.enterprise.dal.syntax import Select, Parameter, Count, Delete, \
Constant
from twext.who.idirectory import RecordType
from twisted.internet.defer import inlineCallbacks, returnValue, succeed
from twisted.python.filepath import FilePath
from twisted.python.text import wordWrap
from twisted.python.usage import Options
from twistedcaldav import caldavxml
from twistedcaldav.config import config
from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
from twistedcaldav.directory import calendaruserproxy
from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
from txdav.caldav.datastore.query.filter import Filter
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
from txdav.who.idirectory import RecordType as CalRecordType
from uuid import UUID
import os
import sys
import traceback
def usage(e=None):
if e:
print(e)
print("")
try:
DBInspectOptions().opt_help()
except SystemExit:
pass
if e:
sys.exit(64)
else:
sys.exit(0)
description = '\n'.join(
wordWrap(
"""
Usage: calendarserver_dbinspect [options] [input specifiers]\n
""",
int(os.environ.get('COLUMNS', '80'))
)
)
class DBInspectOptions(Options):
"""
Command-line options for 'calendarserver_dbinspect'
"""
synopsis = description
optFlags = [
['verbose', 'v', "Verbose logging."],
['debug', 'D', "Debug logging."],
['purging', 'p', "Enable Purge command."],
]
optParameters = [
['config', 'f', DEFAULT_CONFIG_FILE, "Specify caldavd.plist configuration path."],
]
def __init__(self):
super(DBInspectOptions, self).__init__()
self.outputName = '-'
def UserNameFromUID(txn, uid):
record = txn.directoryService().recordWithGUID(uid)
return record.shortNames[0] if record else "(%s)" % (uid,)
def UIDFromInput(txn, value):
try:
return str(UUID(value)).upper()
except (ValueError, TypeError):
pass
record = txn.directoryService().recordWithShortName(RecordType.user, value)
if record is None:
record = txn.directoryService().recordWithShortName(CalRecordType.location, value)
if record is None:
record = txn.directoryService().recordWithShortName(CalRecordType.resource, value)
if record is None:
record = txn.directoryService().recordWithShortName(RecordType.group, value)
return record.guid if record else None
class Cmd(object):
_name = None
@classmethod
def name(cls):
return cls._name
def doIt(self, txn):
raise NotImplementedError
class TableSizes(Cmd):
_name = "Show Size of each Table"
@inlineCallbacks
def doIt(self, txn):
results = []
for dbtable in schema.model.tables: #@UndefinedVariable
dbtable = getattr(schema, dbtable.name)
count = yield self.getTableSize(txn, dbtable)
results.append((dbtable.model.name, count,))
# Print table of results
table = tables.Table()
table.addHeader(("Table", "Row Count"))
for dbtable, count in sorted(results):
table.addRow((
dbtable,
count,
))
print("\n")
print("Database Tables (total=%d):\n" % (len(results),))
table.printTable()
@inlineCallbacks
def getTableSize(self, txn, dbtable):
rows = (yield Select(
[Count(Constant(1)), ],
From=dbtable,
).on(txn))
returnValue(rows[0][0])
class CalendarHomes(Cmd):
_name = "List Calendar Homes"
@inlineCallbacks
def doIt(self, txn):
uids = yield self.getAllHomeUIDs(txn)
# Print table of results
missing = 0
table = tables.Table()
table.addHeader(("Owner UID", "Short Name"))
for uid in sorted(uids):
shortname = UserNameFromUID(txn, uid)
if shortname.startswith("("):
missing += 1
table.addRow((
uid,
shortname,
))
print("\n")
print("Calendar Homes (total=%d, missing=%d):\n" % (len(uids), missing,))
table.printTable()
@inlineCallbacks
def getAllHomeUIDs(self, txn):
ch = schema.CALENDAR_HOME
rows = (yield Select(
[ch.OWNER_UID, ],
From=ch,
).on(txn))
returnValue(tuple([row[0] for row in rows]))
class CalendarHomesSummary(Cmd):
_name = "List Calendar Homes with summary information"
@inlineCallbacks
def doIt(self, txn):
uids = yield self.getCalendars(txn)
results = {}
for uid, calname, count in sorted(uids, key=lambda x: x[0]):
totalname, totalcount = results.get(uid, (0, 0,))
if calname != "inbox":
totalname += 1
totalcount += count
results[uid] = (totalname, totalcount,)
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendars", "Resources"))
totals = [0, 0, 0]
for uid in sorted(results.keys()):
shortname = UserNameFromUID(txn, uid)
table.addRow((
uid,
shortname,
results[uid][0],
results[uid][1],
))
totals[0] += 1
totals[1] += results[uid][0]
totals[2] += results[uid][1]
table.addFooter(("Total", totals[0], totals[1], totals[2]))
table.addFooter((
"Average",
"",
"%.2f" % ((1.0 * totals[1]) / totals[0] if totals[0] else 0,),
"%.2f" % ((1.0 * totals[2]) / totals[0] if totals[0] else 0,),
))
print("\n")
print("Calendars with resource count (total=%d):\n" % (len(results),))
table.printTable()
@inlineCallbacks
def getCalendars(self, txn):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
ch.OWNER_UID,
cb.CALENDAR_RESOURCE_NAME,
Count(co.RESOURCE_ID),
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="left", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
GroupBy=(ch.OWNER_UID, cb.CALENDAR_RESOURCE_NAME)
).on(txn))
returnValue(tuple(rows))
class Calendars(Cmd):
_name = "List Calendars"
@inlineCallbacks
def doIt(self, txn):
uids = yield self.getCalendars(txn)
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendar", "Resources"))
for uid, calname, count in sorted(uids, key=lambda x: (x[0], x[1])):
shortname = UserNameFromUID(txn, uid)
table.addRow((
uid,
shortname,
calname,
count
))
print("\n")
print("Calendars with resource count (total=%d):\n" % (len(uids),))
table.printTable()
@inlineCallbacks
def getCalendars(self, txn):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
ch.OWNER_UID,
cb.CALENDAR_RESOURCE_NAME,
Count(co.RESOURCE_ID),
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="left", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
GroupBy=(ch.OWNER_UID, cb.CALENDAR_RESOURCE_NAME)
).on(txn))
returnValue(tuple(rows))
class CalendarsByOwner(Cmd):
_name = "List Calendars for Owner UID/Short Name"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
uids = yield self.getCalendars(txn, uid)
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendars", "ID", "Resources"))
totals = [0, 0, ]
for uid, calname, resid, count in sorted(uids, key=lambda x: x[1]):
shortname = UserNameFromUID(txn, uid)
table.addRow((
uid if totals[0] == 0 else "",
shortname if totals[0] == 0 else "",
calname,
resid,
count,
))
totals[0] += 1
totals[1] += count
table.addFooter(("Total", "", totals[0], "", totals[1]))
print("\n")
print("Calendars with resource count (total=%d):\n" % (len(uids),))
table.printTable()
@inlineCallbacks
def getCalendars(self, txn, uid):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
ch.OWNER_UID,
cb.CALENDAR_RESOURCE_NAME,
co.CALENDAR_RESOURCE_ID,
Count(co.RESOURCE_ID),
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="left", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
Where=(ch.OWNER_UID == Parameter("UID")),
GroupBy=(ch.OWNER_UID, cb.CALENDAR_RESOURCE_NAME, co.CALENDAR_RESOURCE_ID)
).on(txn, **{"UID": uid}))
returnValue(tuple(rows))
class Events(Cmd):
_name = "List Events"
@inlineCallbacks
def doIt(self, txn):
uids = yield self.getEvents(txn)
# Print table of results
table = tables.Table()
table.addHeader(("Owner UID", "Short Name", "Calendar", "ID", "Type", "UID"))
for uid, calname, id, caltype, caluid in sorted(uids, key=lambda x: (x[0], x[1])):
shortname = UserNameFromUID(txn, uid)
table.addRow((
uid,
shortname,
calname,
id,
caltype,
caluid
))
print("\n")
print("Calendar events (total=%d):\n" % (len(uids),))
table.printTable()
@inlineCallbacks
def getEvents(self, txn):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
ch.OWNER_UID,
cb.CALENDAR_RESOURCE_NAME,
co.RESOURCE_ID,
co.ICALENDAR_TYPE,
co.ICALENDAR_UID,
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
).on(txn))
returnValue(tuple(rows))
class EventsByCalendar(Cmd):
_name = "List Events for a specific calendar"
@inlineCallbacks
def doIt(self, txn):
rid = raw_input("Resource-ID: ")
try:
int(rid)
except ValueError:
print('Resource ID must be an integer')
returnValue(None)
uids = yield self.getEvents(txn, rid)
# Print table of results
table = tables.Table()
table.addHeader(("Type", "UID", "Resource Name", "Resource ID",))
for caltype, caluid, rname, rid in sorted(uids, key=lambda x: x[1]):
table.addRow((
caltype,
caluid,
rname,
rid,
))
print("\n")
print("Calendar events (total=%d):\n" % (len(uids),))
table.printTable()
@inlineCallbacks
def getEvents(self, txn, rid):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
co.ICALENDAR_TYPE,
co.ICALENDAR_UID,
co.RESOURCE_NAME,
co.RESOURCE_ID,
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
Where=(co.CALENDAR_RESOURCE_ID == Parameter("RID")),
).on(txn, **{"RID": rid}))
returnValue(tuple(rows))
class EventDetails(Cmd):
"""
Base class for common event details commands.
"""
def printEventDetails(self, txn, details):
owner, calendar, resource_id, resource, created, modified, data = details
shortname = UserNameFromUID(txn, owner)
table = tables.Table()
table.addRow(("Owner UID:", owner,))
table.addRow(("User Name:", shortname,))
table.addRow(("Calendar:", calendar,))
table.addRow(("Resource Name:", resource))
table.addRow(("Resource ID:", resource_id))
table.addRow(("Created", created))
table.addRow(("Modified", modified))
print("\n")
table.printTable()
print(data)
@inlineCallbacks
def getEventData(self, txn, whereClause, whereParams):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
rows = (yield Select(
[
ch.OWNER_UID,
cb.CALENDAR_RESOURCE_NAME,
co.RESOURCE_ID,
co.RESOURCE_NAME,
co.CREATED,
co.MODIFIED,
co.ICALENDAR_TEXT,
],
From=ch.join(
cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
cb.BIND_MODE == _BIND_MODE_OWN)).join(
co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
Where=whereClause,
).on(txn, **whereParams))
returnValue(tuple(rows))
class Event(EventDetails):
_name = "Get Event Data by Resource-ID"
@inlineCallbacks
def doIt(self, txn):
rid = raw_input("Resource-ID: ")
try:
int(rid)
except ValueError:
print('Resource ID must be an integer')
returnValue(None)
result = yield self.getData(txn, rid)
if result:
self.printEventDetails(txn, result[0])
else:
print("Could not find resource")
def getData(self, txn, rid):
co = schema.CALENDAR_OBJECT
return self.getEventData(txn, (co.RESOURCE_ID == Parameter("RID")), {"RID": rid})
class EventsByUID(EventDetails):
_name = "Get Event Data by iCalendar UID"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("UID: ")
rows = yield self.getData(txn, uid)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, uid):
co = schema.CALENDAR_OBJECT
return self.getEventData(txn, (co.ICALENDAR_UID == Parameter("UID")), {"UID": uid})
class EventsByName(EventDetails):
_name = "Get Event Data by resource name"
@inlineCallbacks
def doIt(self, txn):
name = raw_input("Resource Name: ")
rows = yield self.getData(txn, name)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, name):
co = schema.CALENDAR_OBJECT
return self.getEventData(txn, (co.RESOURCE_NAME == Parameter("NAME")), {"NAME": name})
class EventsByOwner(EventDetails):
_name = "Get Event Data by Owner UID/Short Name"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
rows = yield self.getData(txn, uid)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, uid):
ch = schema.CALENDAR_HOME
return self.getEventData(txn, (ch.OWNER_UID == Parameter("UID")), {"UID": uid})
class EventsByOwnerCalendar(EventDetails):
_name = "Get Event Data by Owner UID/Short Name and calendar name"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("Owner UID/Name: ")
uid = UIDFromInput(txn, uid)
name = raw_input("Calendar resource name: ")
rows = yield self.getData(txn, uid, name)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, uid, name):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
return self.getEventData(txn, (ch.OWNER_UID == Parameter("UID")).And(cb.CALENDAR_RESOURCE_NAME == Parameter("NAME")), {"UID": uid, "NAME": name})
class EventsByPath(EventDetails):
_name = "Get Event Data by HTTP Path"
@inlineCallbacks
def doIt(self, txn):
path = raw_input("Path: ")
pathbits = path.split("/")
if len(pathbits) != 6:
print("Not a valid calendar object resource path")
returnValue(None)
homeName = pathbits[3]
calendarName = pathbits[4]
resourceName = pathbits[5]
rows = yield self.getData(txn, homeName, calendarName, resourceName)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, homeName, calendarName, resourceName):
ch = schema.CALENDAR_HOME
cb = schema.CALENDAR_BIND
co = schema.CALENDAR_OBJECT
return self.getEventData(
txn,
(
ch.OWNER_UID == Parameter("HOME")).And(
cb.CALENDAR_RESOURCE_NAME == Parameter("CALENDAR")).And(
co.RESOURCE_NAME == Parameter("RESOURCE")
),
{"HOME": homeName, "CALENDAR": calendarName, "RESOURCE": resourceName}
)
class EventsByContent(EventDetails):
_name = "Get Event Data by Searching its Text Data"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("Search for: ")
rows = yield self.getData(txn, uid)
if rows:
for result in rows:
self.printEventDetails(txn, result)
else:
print("Could not find icalendar data")
def getData(self, txn, text):
co = schema.CALENDAR_OBJECT
return self.getEventData(txn, (co.ICALENDAR_TEXT.Contains(Parameter("TEXT"))), {"TEXT": text})
class EventsInTimerange(Cmd):
_name = "Get Event Data within a specified time range"
@inlineCallbacks
def doIt(self, txn):
uid = raw_input("Owner UID/Name: ")
start = raw_input("Start Time (UTC YYYYMMDDTHHMMSSZ or YYYYMMDD): ")
if len(start) == 8:
start += "T000000Z"
end = raw_input("End Time (UTC YYYYMMDDTHHMMSSZ or YYYYMMDD): ")
if len(end) == 8:
end += "T000000Z"
try:
start = DateTime.parseText(start)
except ValueError:
print("Invalid start value")
returnValue(None)
try:
end = DateTime.parseText(end)
except ValueError:
print("Invalid end value")
returnValue(None)
timerange = caldavxml.TimeRange(start=start.getText(), end=end.getText())
home = yield txn.calendarHomeWithUID(uid)
if home is None:
print("Could not find calendar home")
returnValue(None)
yield self.eventsForEachCalendar(home, uid, timerange)
@inlineCallbacks
def eventsForEachCalendar(self, home, uid, timerange):
calendars = yield home.calendars()
for calendar in calendars:
if calendar.name() == "inbox":
continue
yield self.eventsInTimeRange(calendar, uid, timerange)
@inlineCallbacks
def eventsInTimeRange(self, calendar, uid, timerange):
# Create fake filter element to match time-range
filter = caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
timerange,
name=("VEVENT",),
),
name="VCALENDAR",
)
)
filter = Filter(filter)
filter.settimezone(None)
matches = yield calendar.search(filter, useruid=uid, fbtype=False)
if matches is None:
returnValue(None)
for name, _ignore_uid, _ignore_type in matches:
event = yield calendar.calendarObjectWithName(name)
ical_data = yield event.component()
ical_data = PerUserDataFilter(uid).filter(ical_data)
ical_data.stripKnownTimezones()
table = tables.Table()
table.addRow(("Calendar:", calendar.name(),))
table.addRow(("Resource Name:", name))
table.addRow(("Resource ID:", event._resourceID))
table.addRow(("Created", event.created()))
table.addRow(("Modified", event.modified()))
print("\n")
table.printTable()
print(ical_data.getTextWithTimezones(includeTimezones=False))
class Purge(Cmd):
_name = "Purge all data from tables"
@inlineCallbacks
def doIt(self, txn):
if raw_input("Do you really want to remove all data [y/n]: ")[0].lower() != 'y':
print("No data removed")
returnValue(None)
wipeout = (
# These are ordered in such a way as to ensure key constraints are not
# violated as data is removed
schema.RESOURCE_PROPERTY,
schema.CALENDAR_OBJECT_REVISIONS,
schema.CALENDAR,
#schema.CALENDAR_BIND, - cascades
#schema.CALENDAR_OBJECT, - cascades
#schema.TIME_RANGE, - cascades
#schema.TRANSPARENCY, - cascades
schema.CALENDAR_HOME,
#schema.CALENDAR_HOME_METADATA - cascades
schema.ATTACHMENT,
schema.ADDRESSBOOK_OBJECT_REVISIONS,
schema.ADDRESSBOOK_HOME,
#schema.ADDRESSBOOK_HOME_METADATA, - cascades
#schema.ADDRESSBOOK_BIND, - cascades
#schema.ADDRESSBOOK_OBJECT, - cascades
schema.NOTIFICATION_HOME,
schema.NOTIFICATION,
#schema.NOTIFICATION_OBJECT_REVISIONS - cascades,
)
for tableschema in wipeout:
yield self.removeTableData(txn, tableschema)
print("Removed rows in table %s" % (tableschema,))
if calendaruserproxy.ProxyDBService is not None:
calendaruserproxy.ProxyDBService.clean() #@UndefinedVariable
print("Removed all proxies")
else:
print("No proxy database to clean.")
fp = FilePath(config.AttachmentsRoot)
if fp.exists():
for child in fp.children():
child.remove()
print("Removed attachments.")
else:
print("No attachments path to delete.")
@inlineCallbacks
def removeTableData(self, txn, tableschema):
yield Delete(
From=tableschema,
Where=None # Deletes all rows
).on(txn)
class DBInspectService(WorkerService, object):
"""
Service which runs, exports the appropriate records, then stops the reactor.
"""
def __init__(self, store, options, reactor, config):
super(DBInspectService, self).__init__(store)
self.options = options
self.reactor = reactor
self.config = config
self.commands = []
self.commandMap = {}
def doWork(self):
"""
Start the service.
"""
# Register commands
self.registerCommand(TableSizes)
self.registerCommand(CalendarHomes)
self.registerCommand(CalendarHomesSummary)
self.registerCommand(Calendars)
self.registerCommand(CalendarsByOwner)
self.registerCommand(Events)
self.registerCommand(EventsByCalendar)
self.registerCommand(Event)
self.registerCommand(EventsByUID)
self.registerCommand(EventsByName)
self.registerCommand(EventsByOwner)
self.registerCommand(EventsByOwnerCalendar)
self.registerCommand(EventsByPath)
self.registerCommand(EventsByContent)
self.registerCommand(EventsInTimerange)
self.doDBInspect()
return succeed(None)
def postStartService(self):
"""
Don't quit right away
"""
pass
def registerCommand(self, cmd):
self.commands.append(cmd.name())
self.commandMap[cmd.name()] = cmd
@inlineCallbacks
def runCommandByPosition(self, position):
try:
yield self.runCommandByName(self.commands[position])
except IndexError:
print("Position %d not available" % (position,))
returnValue(None)
@inlineCallbacks
def runCommandByName(self, name):
try:
yield self.runCommand(self.commandMap[name])
except IndexError:
print("Unknown command: '%s'" % (name,))
@inlineCallbacks
def runCommand(self, cmd):
txn = self.store.newTransaction()
try:
yield cmd().doIt(txn)
yield txn.commit()
except Exception, e:
traceback.print_exc()
print("Command '%s' failed because of: %s" % (cmd.name(), e,))
yield txn.abort()
def printCommands(self):
print("\n<---- Commands ---->")
for ctr, name in enumerate(self.commands):
print("%d. %s" % (ctr + 1, name,))
if self.options["purging"]:
print("P. Purge\n")
print("Q. Quit\n")
@inlineCallbacks
def doDBInspect(self):
"""
Poll for commands, stopping the reactor when done.
"""
while True:
self.printCommands()
cmd = raw_input("Command: ")
if cmd.lower() == 'q':
break
if self.options["purging"] and cmd.lower() == 'p':
yield self.runCommand(Purge)
else:
try:
position = int(cmd)
except ValueError:
print("Invalid command. Try again.\n")
continue
yield self.runCommandByPosition(position - 1)
self.reactor.stop()
def stopService(self):
"""
Stop the service. Nothing to do; everything should be finished by this
time.
"""
# TODO: stopping this service mid-export should really stop the export
# loop, but this is not implemented because nothing will actually do it
# except hitting ^C (which also calls reactor.stop(), so that will exit
# anyway).
def main(argv=sys.argv, stderr=sys.stderr, reactor=None):
"""
Do the export.
"""
if reactor is None:
from twisted.internet import reactor
options = DBInspectOptions()
options.parseOptions(argv[1:])
def makeService(store):
return DBInspectService(store, options, reactor, config)
utilityMain(options['config'], makeService, reactor, verbose=options['debug'])
if __name__ == '__main__':
main()
| trevor/calendarserver | calendarserver/tools/dbinspect.py | Python | apache-2.0 | 29,245 |
__author__ = 'mramire8'
import nltk
from scipy.sparse import diags
from numpy.random import RandomState
from randomsampling import *
import random
class AALStructuredFixk(AnytimeLearner):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None):
super(AALStructuredFixk, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score_model = None
self.sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')
self._kvalues = [1]
self.sentence_separator = ' ... '
# def pick_next(self, pool=None, step_size=1):
# pass
def x_utility(self, instance, instance_text):
# for each document
# sepearte into sentences and then obtaine the k sentences
# TODO change uncertianty
# prob = self.model.predict_proba(instance)
# unc = 1 - prob.max()
unc = 1
utility = np.array([[self.score(xik, k) * unc, k] for k, xik in self.getk(instance_text)])
order = np.argsort(utility[:, 0], axis=0)[::-1] # # descending order
utility_sorted = utility[order, :]
# print format_list(utility_sorted)
if show_utilitly:
print "\t{0:.5f}".format(unc),
return utility_sorted[0, 0], utility_sorted[0, 1], unc # # return the max
def getk(self, doc_text):
'''
Get the document split into k sentences
:param doc_text: instance text (full document)
:return: first k sentences of the document
'''
sents = self.sent_detector.tokenize(doc_text) # split in sentences
# analize = self.vcn.build_tokenizer()
qk = []
lens = []
for k in self._kvalues:
ksent_text = self.sentence_separator.join(sents[:k]) ## take the first k sentences
qk.append(ksent_text)
lens.append(len(sents))
# return zip(self._kvalues, qk)
return zip(lens, qk)
def getlastk(self, doc_text):
'''
Get the document split into k sentences
:param doc_text: instance text (full document)
:return: first k sentences of the document
'''
sents = self.sent_detector.tokenize(doc_text) # split in sentences
# analize = self.vcn.build_tokenizer()
qk = []
lens = []
for k in self._kvalues:
ksent_text = self.sentence_separator.join(sents[-k:]) ## take the first k sentences
qk.append(ksent_text)
lens.append(len(sents))
# return zip(self._kvalues, qk)
return zip(lens, qk)
def score(self, instance_k, k):
'''
Compute the score of the first k sentences of the document
:param instance_k:
:param k:
:return:
'''
# # change the text to use the vectorizer
xik = self.vcn.transform([instance_k])
# neu = self.neutral_model.predict_proba(xik) if self.neutral_model is not None else [1]
neu = 1
# TODO change the neutrality
# if self.neutral_model is not None: ## if the model has been built yet
# neu = self.neutral_model.predict_proba(xik)[0, 1] # probability of being not-neutral
costk = self.predict_cost(k)
utility = neu / costk ## N(xk)*score(xk) / C(xk)
# print utility
if show_utilitly:
print "\t{0:.3f}".format(neu),
print "\t{0:.3f}".format(costk),
return utility
def set_score_model(self, model):
self.score_model = model
def set_kvalues(self, kvalues):
self._kvalues = kvalues
class AALStructured(AALStructuredFixk):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None):
super(AALStructured, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score_model = None
self.sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')
self._kvalues = [1]
# def score(self, instance_k, k):
# '''
# Compute the score of the first k sentences of the document
# :param instance_k:
# :param k:
# :return:
# '''
# ## change the text to use the vectorizer
#
# xik = self.vcn.transform([instance_k])
# # neu = self.neutral_model.predict_proba(xik) if self.neutral_model is not None else [1]
#
# neu = 1
# if self.neutral_model is not None: ## if the model has been built yet
# neu = self.neutral_model.predict_proba(xik)[0, 1] # probability of being not-neutral
#
# costk = self.predict_cost(k)
#
#
# sentence_score
#
#
# utility = neu / costk ## N(xk)*score(xk) / C(xk)
#
# # print utility
#
# if show_utilitly:
# print "\t{0:.3f}".format(neu),
# print "\t{0:.3f}".format(costk),
#
# return utility
def get_scores_sent(self, sentences):
return sentences.sum(axis=1)
def get_scores_sent_max(self, sentences):
mx = [sentences[i].max() for i in xrange(sentences.shape[0])]
mi = [sentences[i].min() for i in xrange(sentences.shape[0])]
s = [np.max([np.abs(x), np.abs(i)]) for x, i in zip(mx, mi)]
return np.array(s)
def get_scores_sent3(self, sentences):
mx = [sentences[i].max() for i in xrange(sentences.shape[0])]
mi = [sentences[i].min() for i in xrange(sentences.shape[0])]
s = [x + i for x, i in zip(mx, mi)]
return np.array(s)
def getk(self, doc_text):
'''
Get the document split into k sentences
:param doc_text: instance text (full document)
:return: first k sentences of the document
'''
mm, sents = self.sentence2values(doc_text)
# print mm.sum(axis=1)[:10]
# scores = mm.sum(axis=1)
qk = []
scores = self.get_scores_sent(mm)
order_sentences = np.argsort(np.abs(scores), axis=0)[::-1]
kscores = []
for k in self._kvalues:
topk = order_sentences[:k].A1 # top scored sentence in order of appearance in the document
topk.sort()
topk_sentences = [sents[s] for s in topk] # get text of top k sentences
# print "top scores: ",
# print np.array(scores[topk][:k].A1)
# print "%s\t" % topk,
qk.append(self.sentence_separator.join(topk_sentences))
# bot = order_sentences[-k:].A1
# bot.sort()
# bottom = [sents[s] for s in bot]
# print "===BOTTOM==="
# print "...".join(bottom)
kscores.append(scores[topk][:k].A1)
return zip(self._kvalues, qk), kscores
def getkmax(self, doc_text):
'''
Max value of the features
'''
return self.getk_sent(doc_text, self.get_scores_sent_max)
def getk3(self, doc_text):
"""
get the top k sentences by max-min
:param doc_text: raw text of the document
:return: list top k scored sentences in order of appeareance
"""
return self.getk_sent(doc_text, self.get_scores_sent3)
def getk_sent(self, doc_text, score_fn):
'''
Get the document split into k sentences
:param doc_text: instance text (full document)
:return: first k sentences of the document
'''
mm, sents = self.sentence2values(doc_text)
qk = []
scores = score_fn(mm)
order_sentences = np.argsort(np.abs(scores), axis=0)[::-1]
kscores = []
for k in self._kvalues:
topk = order_sentences[:k] # top scored sentence in order of appearance in the document
topk.sort()
topk_sentences = [sents[s] for s in topk] # get text of top k sentences
# print "%s\t" % topk,
qk.append(self.sentence_separator.join(topk_sentences))
bot = order_sentences[-k:]
bot.sort()
bottom = [sents[s] for s in bot]
kscores.append(scores[topk][:k])
return zip(self._kvalues, qk), kscores
def sentence2values(self, doc_text):
np.set_printoptions(precision=4)
sents = self.sent_detector.tokenize(doc_text)
#analize = self.vcn.build_tokenizer()
sents_feat = self.vcn.transform(sents)
coef = self.score_model.coef_[0]
dc = diags(coef, 0)
mm = sents_feat * dc # sentences feature vectors \times diagonal of coeficients. sentences by features
return mm, sents
# #######################################################################################################################
# # ANYTIME ACTIVE LEARNING: STRUCTURED UNCERTAINTY READING
########################################################################################################################
class AALStructuredReading(AnytimeLearner):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None):
super(AALStructuredReading, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score_model = None
self.sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')
self._kvalues = [1]
self.sentence_separator = ' ... '
self.sent_model = copy.copy(model)
self.base_neutral = copy.copy(model) ## we will use same for student and sentence model
self.cheating = False
self.counter = 0
self.curret_doc = None
self.score = self.score_base
self.fn_utility = self.utility_base
self.rnd_vals = RandomState(4321)
self.limit = 0
self.calibration_threshold = (.5, .5)
self.logit_scores = False
def pick_next(self, pool=None, step_size=1):
list_pool = list(pool.remaining)
indices = self.randgen.permutation(len(pool.remaining))
remaining = [list_pool[index] for index in indices]
uncertainty = []
if self.subpool is None:
self.subpool = len(pool.remaining)
sent_text = []
for i in remaining[:self.subpool]:
# data_point = candidates[i]
utility, sent_max, text, _ = self.x_utility(pool.data[i], pool.text[i])
sent_text.append(text)
uncertainty.append([utility, sent_max])
uncertainty = np.array(uncertainty)
unc_copy = uncertainty[:, 0]
sorted_ind = np.argsort(unc_copy, axis=0)[::-1]
chosen = [[remaining[x], uncertainty[x, 1]] for x in sorted_ind[:int(step_size)]] #index and k of chosen
# util = [uncertainty[x] for x in sorted_ind[:int(step_size)]]
# TODO: remove chosen_text later this is only for debugging
chosen_text = [sent_text[t] for t in sorted_ind[:int(step_size)]]
return chosen#, chosen_text
def pick_next_cal(self, pool=None, step_size=1):
from sklearn import preprocessing
import time
list_pool = list(pool.remaining)
indices = self.randgen.permutation(len(pool.remaining))
remaining = [list_pool[index] for index in indices]
if self.subpool is None:
self.subpool = len(pool.remaining)
text_sent = []
all_scores = []
all_p0 = []
docs = []
unc_utility = []
t0 = time.time()
for i in remaining[:self.subpool]:
unc_utility.append(self.fn_utility(pool.data[i]))
utilities, sent_bow, sent_txt = self.x_utility_cal(pool.data[i], pool.text[i]) # utulity for every sentences in document
all_scores.extend(utilities) ## every score
docs.append(sent_bow) ## sentences for each document list of list
text_sent.append(sent_txt) ## text sentences for each document
all_p0 = np.concatenate((all_p0, utilities))
## Calibrate scores
n = len(all_scores)
if n != len(all_p0):
raise Exception("Oops there is something wrong! We don't have the same size")
# all_p0 = np.array(all_p0)
order = all_p0.argsort()[::-1] ## descending order
## generate scores equivalent to max prob
ordered_p0 = all_p0[order]
from sys import maxint
upper = self.calibration_threshold[1]
lower = self.calibration_threshold[0]
if upper is not .5:
c0_scores = preprocessing.scale(ordered_p0[ordered_p0 >= upper])
c1_scores = -1. * preprocessing.scale(ordered_p0[ordered_p0 <= lower])
mid = len(ordered_p0) - ((ordered_p0 >= upper).sum() + (ordered_p0 <= lower).sum())
middle = np.array([-maxint]*mid)
print "Threshold:", lower, upper
print "middle:", len(middle),
a = np.concatenate((c0_scores, middle,c1_scores))
print "all:", len(a), 1.*len(middle)/len(a), len(c0_scores), len(c1_scores)
else:
c0_scores = preprocessing.scale(ordered_p0[ordered_p0 > upper])
c1_scores = -1. * preprocessing.scale(ordered_p0[ordered_p0 <= lower])
print "Threshold:", lower, upper
a = np.concatenate((c0_scores, c1_scores))
print "all:", len(a), 1.*len(c0_scores)/len(a), len(c0_scores), len(c1_scores)
new_scores = np.zeros(n)
new_scores[order] = a
cal_scores = self._reshape_scores(new_scores, docs)
# p0 = self._reshape_scores(all_p0, docs)
selected_sent = [np.argmax(row) for row in cal_scores] # get the sentence index of the highest score per document
selected = [docs[i][k] for i, k in enumerate(selected_sent)] # get the bow of the sentences with the highest score
selected_score = [np.max(row) for row in cal_scores] ## get the max utility score per document
test_sent = list_to_sparse(selected) # bow of each sentence selected
selected_text = [text_sent[i][k] for i,k in enumerate(selected_sent)]
## pick document-sentence
if self.logit_scores:
joint = np.array(unc_utility) * self._logit(selected_score)
else:
joint = np.array(unc_utility) * selected_score
final_order = joint.argsort()[::-1]
chosen = [[remaining[x], test_sent[x]] for x in final_order[:int(step_size)]] #index and k of chosen
chosen_text = [selected_text[x] for x in final_order[:int(step_size)]]
#todo: human vs simulated expert
return chosen#, chosen_text
def _calibrate_scores(self, n_scores, bounds=(.5,1)):
"""
Create an array with values uniformly distributed with int range given by bounds
:param n_scores: number of scores to generate
:param bounds: lower and upper bound of the array
:return: narray
"""
delta = 1.* (bounds[1] - bounds[0]) / (n_scores -1)
calibrated = (np.ones(n_scores)*bounds[1]) - (np.array(range(n_scores))*delta)
return calibrated
def set_calibration_threshold(self, thr):
"""
set the threshold for the calibration
:param thr: tuple
lower bound and upper bound
"""
self.calibration_threshold = thr
def _reshape_scores2(self, scores, sent_mat):
"""
Reshape scores to have the same structure as the list of list sent_mat
:param scores: one dimensional array of scores
:param sent_mat: list of lists
:return: narray : reshaped scores
"""
sr = []
i = 0
for row in sent_mat:
sc = []
for col in row:
sc.append(scores[i])
i = i+1
sr.append(sc)
return np.array(sr)
def _reshape_scores(self, scores, sent_mat):
"""
Reshape scores to have the same structure as the list of list sent_mat
:param scores: one dimensional array of scores
:param sent_mat: list of lists
:return: narray : reshaped scores
"""
sr = []
i = 0
lengths = np.array([d.shape[0] for d in sent_mat])
lengths = lengths.cumsum()
for j in lengths:
sr.append(scores[i:j])
i = j
return sr
def _logit(self, x):
return 1. / (1. + np.exp(-np.array(x)))
def utility_base(self, instance):
raise Exception("We need a utility function")
def utility_unc(self, instance):
prob = self.model.predict_proba(instance)
unc = 1 - prob.max()
return unc
def utility_rnd(self, instance):
return self.rnd_vals.rand()
# return self.randgen.random_sample()
def utility_one(self, instance):
return 1.0
def x_utility(self, instance, instance_text):
# prob = self.model.predict_proba(instance)
# unc = 1 - prob.max()
util_score = self.fn_utility(instance)
sentences_indoc, sent_text = self.getk(instance_text)
self.counter = 0
self.curret_doc = instance
utility = np.array([self.score(xik) * util_score for xik in sentences_indoc])
order = np.argsort(utility, axis=0)[::-1] ## descending order
utility_sorted = utility[order]
# print utility_sorted[0], util_score
return utility_sorted[0], sentences_indoc[order[0]], sent_text[order[0]], order[0]
def x_utility_cal(self, instance, instance_text):
sentences_indoc, sent_text = self.getk(instance_text)
self.counter = 0
self.curret_doc = instance
# utility = np.array([self.score(xik) for xik in sentences_indoc])
utility = self.score(sentences_indoc)
if len(sent_text) <=1:
utility = np.array([utility])
# order = np.argsort(utility, axis=0)[::-1] ## descending order
#
# utility_sorted = utility[order]
# return utility_sorted, sentences_indoc[order], np.array(sent_text)[order]
return utility, sentences_indoc, np.array(sent_text)
def score_base(self, sentence):
"""
Return the score for the sentences
:param sentence: feature vector of sentences
:return: confidence score
"""
raise Exception("There should be a score sentence")
def score_max(self, sentence):
"""
Return the score for the sentences, as the confidence of the sentence classifier maxprob value
:param sentence: feature vector of sentences
:return: confidence score
"""
if self.sent_model is not None: ## if the model has been built yet
pred = self.sent_model.predict_proba(sentence)
if sentence.shape[0] == 1:
return pred.max()
else:
return pred.max(axis=1)
return 1.0
def score_p0(self, sentence):
"""
Return the score for the sentences, as the confidence of the sentence classifier maxprob value
:param sentence: feature vector of sentences
:return: confidence score
"""
if self.sent_model is not None: ## if the model has been built yet
pred = self.sent_model.predict_proba(sentence)
if sentence.shape[0] == 1:
return pred[0][0]
else:
return pred[:,0]
return np.array([1.0] * sentence.shape[0])
def score_rnd(self, sentence):
if sentence.shape[0] ==1:
return self.randgen.random_sample()
else:
return self.randgen.random_sample(sentence.shape[0])
def score_fk(self, sentence):
if sentence.shape[0] ==1:
self.counter += 1
if self.counter == 1:
return 1.0
else:
return 0.0
# self.counter -= 1
# return self.counter
else:
return np.array([1] + [0]*(sentence.shape[0]-1))
def getk(self, text):
if not isinstance(text, list):
text = [text]
sents = self.sent_detector.batch_tokenize(text)
if self.limit == 0:
pass
elif self.limit > 0:
sents = [s for s in sents[0] if len(s.strip()) > self.limit]
sents = [sents] # trick to use the vectorizer properly
### do the matrix
sents_bow = self.vcn.transform(sents[0])
return sents_bow, sents[0]
def text_to_features(self, list_text):
return self.vcn.transform(list_text)
def train_all(self, train_data=None, train_labels=None, sent_train=None, sent_labels=None):
## update underlying classifier
## update sentence classifier
self.model = super(AnytimeLearner, self).train(train_data=train_data, train_labels=train_labels)
if not self.cheating:
self.sent_model = self.update_sentence(sent_train, sent_labels)
return self.model
def update_sentence(self, sent_train, sent_labels):
# try:
# clf = copy.copy(self.base_neutral)
# clf.fit(sent_train, sent_labels)
# except ValueError:
# clf = None
# return clf
if self.sent_model is None:
self.sent_model = copy.copy(self.base_neutral)
return self.sent_model.fit(sent_train, sent_labels)
def set_cheating(self, cheat):
self.cheating = cheat
def get_cheating(self):
return self.cheating
def set_score_model(self, model):
self.score_model = model
def set_sentence_model(self, model):
self.sent_model = model
def set_sent_score(self, sent_score_fn):
self.score = sent_score_fn
def score_fk_max(self, sentence):
self.counter += 1
if self.counter <= self._kvalues[0]:
if self.sent_model is not None: ## if the model has been built yet
pred = self.sent_model.predict_proba(sentence)
return pred.max()
else: # this should not happen, there should be a model for this computation
raise Exception("Oops: The sentences model is not available to compute a sentence score.")
else: ## if it is not the first sentence, return 0
return 0.0
def score_max_feat(self, sentence):
return np.max(abs(sentence.max()), abs(sentence.min()))
def score_max_sim(self, sentence):
s = sentence.dot(self.curret_doc.T).max()
return s
def __str__(self):
string = "{0}(seed={seed}".format(self.__class__.__name__, seed=self.seed)
string += ", clf = {}, utility={}, score={}".format(self.model, self.fn_utility.__name__, self.score.__name__)
string += ", sent_detector={})".format(self.sent_detector.__class__.__name__)
return string
def __repr__(self):
string = self.__class__.__name__ % "(model=" % self.current_model % ", accuracy_model=" % self.accuracy_model \
% ", budget=" % self.budget % ", seed=" % self.seed % ")"
return string
from scipy.sparse import vstack
def list_to_sparse(selected):
test_sent = []
for s in selected:
if isinstance(test_sent, list):
test_sent = s
else:
test_sent = vstack([test_sent, s], format='csr')
return test_sent
## Doc: UNC Sentence: max confidence
class AALStructuredReadingMax(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None):
super(AALStructuredReadingMax, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_unc # document score
## Doc: UNC Sentence: firstk uniform confidence
class AALStructuredReadingFirstK(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALStructuredReadingFirstK, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_fk # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
## Doc: UNC Sentence: firstk max confidence
class AALStructuredReadingFirstKMax(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALStructuredReadingFirstKMax, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_fk_max # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
# def score_fk_max(self, sentence):
# self.counter += 1
# if self.counter <= self._kvalues[0]:
# if self.sent_model is not None: ## if the model has been built yet
# pred = self.sent_model.predict_proba(sentence)
# return pred.max()
# else: # this should not happen, there should be a model for this computation
# raise Exception("Oops: The sentences model is not available to compute a sentence score.")
# else: ## if it is not the first sentence, return 0
# return 0.0
## Doc: UNC Sentence: random confidence
class AALStructuredReadingRandomK(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALStructuredReadingRandomK, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_rnd # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
########################################################################################################################
## Doc: _ Sentence: max confidence
class AALStructuredReadingMaxMax(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALStructuredReadingMaxMax, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_one # document score
self.first_k = fk
########################################################################################################################
## ANYTIME ACTIVE LEARNING: STRUCTURED RANDOM READING
########################################################################################################################
class AALRandomReadingFK(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALRandomReadingFK, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_fk # sentence score
self.fn_utility = self.utility_rnd # document score
self.first_k = fk
class AALRandomReadingMax(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALRandomReadingMax, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_rnd # document score
self.first_k = fk
class AALRandomReadingRandom(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALRandomReadingRandom, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_rnd # sentence score
self.fn_utility = self.utility_rnd # document score
self.first_k = fk
########################################################################################################################
## TOP FROM EACH
########################################################################################################################
class AALTFEStructuredReading(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALTFEStructuredReading, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
def pick_next(self, pool=None, step_size=1):
list_pool = list(pool.remaining)
indices = self.randgen.permutation(len(pool.remaining))
remaining = [list_pool[index] for index in indices]
uncertainty = []
if self.subpool is None:
self.subpool = len(pool.remaining)
sent_text = []
pred_class = []
for i in remaining[:self.subpool]:
# data_point = candidates[i]
utility, sent_max, text, _ = self.x_utility(pool.data[i], pool.text[i])
pc = self.sent_model.predict(sent_max)
# print pc
pred_class.append(pc)
sent_text.append(text)
uncertainty.append([utility, sent_max])
uncertainty = np.array(uncertainty)
unc_copy = uncertainty[:, 0]
sorted_ind = np.argsort(unc_copy, axis=0)[::-1]
chosen_0 = [[remaining[x], uncertainty[x, 1]] for x in sorted_ind if pred_class[x] == 0] #index and k of chosen
chosen_1 = [[remaining[x], uncertainty[x, 1]] for x in sorted_ind if pred_class[x] == 1] #index and k of chosen
half = int(step_size / 2)
chosen = chosen_0[:half]
chosen.extend(chosen_1[:half])
if len(chosen) < step_size:
miss = step_size - len(chosen)
if len(chosen_0) < step_size / 2:
chosen.extend(chosen_1[half: (half + miss)])
elif len(chosen_1) < step_size / 2:
chosen.extend(chosen_0[half: (half + miss)])
else:
raise Exception("Oops, we cannot get the next batch. We ran out of instances.")
# print "chosen len:", len(chosen_0), len(chosen_1)
# util = [uncertainty[x] for x in sorted_ind[:int(step_size)]]
return chosen
########################################################################################################################
class AALTFEStructuredReadingFK(AALTFEStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALTFEStructuredReadingFK, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_fk # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
# def score_fk_max(self, sentence):
# self.counter += 1
# if self.counter <= self._kvalues[0]:
# if self.sent_model is not None: ## if the model has been built yet
# pred = self.sent_model.predict_proba(sentence)
# return pred.max()
# else: # this should not happen, there should be a model for this computation
# raise Exception("Oops: The sentences model is not available to compute a sentence score.")
# else: ## if it is not the first sentence, return 0
# return 0.0
########################################################################################################################
## ANYTIME ACTIVE LEARNING: UNCERTAINTY THEN STRUCTURED READING
########################################################################################################################
## Doc: _ Sentence: max confidence
class AALUtilityThenStructuredReading(AALStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALUtilityThenStructuredReading, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
# self.score = self.score_max # sentence score
# self.fn_utility = self.utility_one # document score
self.first_k = fk
self.human_mode = False
self.calibratescores = False
def pick_next(self, pool=None, step_size=1):
list_pool = list(pool.remaining)
indices = self.randgen.permutation(len(pool.remaining))
remaining = [list_pool[index] for index in indices]
if self.subpool is None:
self.subpool = len(pool.remaining)
# Select the top based on utility
uncertainty = [self.fn_utility(pool.data[i]) for i in remaining[:self.subpool]]
uncertainty = np.array(uncertainty)
unc_copy = uncertainty[:]
sorted_ind = np.argsort(unc_copy, axis=0)[::-1]
chosen_x = [remaining[x] for x in sorted_ind[:int(step_size)]] #index and k of chosen
#After utility, pick the best sentence of each document
chosen = self.pick_next_sentence(chosen_x, pool=pool)
final = []
if self.human_mode:
for x, y in chosen[:step_size]:
final.append([x, y[1]]) # index, text
else:
for x, y in chosen[:step_size]:
final.append([x, y[0][0]]) #index, feature vector
return final
# return chosen
def pick_next_sentence(self, chosen_x, pool):
'''
After picking documents, compute the best sentence based on x_utility function
:param chosen_x:
:param pool:
:return:
'''
if not self.calibratescores:
chosen = [[index, self.x_utility(pool.data[index], pool.text[index])] for index in chosen_x]
else:
sent_chosen = self.pick_next_sentence_cal(chosen_x, pool)
chosen = [[index, sent_bow] for index, sent_bow in sent_chosen]
# chosen = [[index, sent_bow] for index, sent_bow in sent_chosen]
return chosen
def pick_next_sentence_cal(self, chosen_x, pool):
from sklearn import preprocessing
# list_pool = list(pool.remaining)
# indices = self.randgen.permutation(len(pool.remaining))
remaining = [x for x in chosen_x]
# if self.subpool is None:
# self.subpool = len(pool.remaining)
# remaining = list(set(remaining[:self.subpool]) | set(chosen_x))
text_sent = []
all_scores = []
all_p0 = []
docs = []
unc_utility = []
used_index = []
for i in remaining:
utilities, sent_bow, sent_txt = self.x_utility_cal(pool.data[i], pool.text[i]) # utulity for every sentences in document
all_scores.extend(utilities) ## every score
docs.append(sent_bow) ## sentences for each document list of list
text_sent.append(sent_txt) ## text sentences for each document
all_p0 = np.concatenate((all_p0, utilities))
## Calibrate scores
n = len(all_scores)
if n != len(all_p0):
raise Exception("Oops there is something wrong! We don't have the same size")
# all_p0 = np.array(all_p0)
order = all_p0.argsort()[::-1] ## descending order
## generate scores equivalent to max prob
ordered_p0 = all_p0[order]
from sys import maxint
upper = self.calibration_threshold[1]
lower = self.calibration_threshold[0]
if upper is not .5:
c0_scores = preprocessing.scale(ordered_p0[ordered_p0 >= upper])
c1_scores = -1. * preprocessing.scale(ordered_p0[ordered_p0 <= lower])
mid = len(ordered_p0) - ((ordered_p0 >= upper).sum() + (ordered_p0 <= lower).sum())
middle = np.array([-maxint]*mid)
print "Threshold seq:", lower, upper
print "middle:", len(middle),
a = np.concatenate((c0_scores, middle,c1_scores))
print "all:", len(a), 1.*len(middle)/len(a), len(c0_scores), len(c1_scores)
else:
c0_scores = preprocessing.scale(ordered_p0[ordered_p0 > upper])
c1_scores = -1. * preprocessing.scale(ordered_p0[ordered_p0 <= lower])
print "Threshold seq:", lower, upper
a = np.concatenate((c0_scores, c1_scores))
print "all:", len(a), 1.*len(c0_scores)/len(a), len(c0_scores), len(c1_scores)
new_scores = np.zeros(n)
new_scores[order] = a
cal_scores = self._reshape_scores(new_scores, docs)
# p0 = self._reshape_scores(all_p0, docs)
selected_sent = [np.argmax(row) for row in cal_scores] # get the sentence index of the highest score per document
selected = [docs[i][k] for i, k in enumerate(selected_sent)] # get the bow of the sentences with the highest score
selected_score = [np.max(row) for row in cal_scores] ## get the max utility score per document
test_sent = list_to_sparse(selected) # bow of each sentence selected
selected_text = [text_sent[i][k] for i,k in enumerate(selected_sent)]
## pick document-sentence
# chosen = [[remaining[x], test_sent[x]] for x in remaining if x in chosen_x]
chosen = [[x, test_sent[i]] for i, x in enumerate(remaining) if x in chosen_x]
chosen_text = [selected_text[i] for i, x in enumerate(remaining) if x in chosen_x]
#todo: human vs simulated expert
return chosen#, chosen_text
def x_utility(self, instance, instance_text):
'''
The utility of the sentences inside a document
:param instance:
:param instance_text:
:return:
'''
sentences_indoc, sent_text = self.getk(instance_text) #get subinstances
self.counter = 0
utility = np.array([self.score(xik) for xik in sentences_indoc]) # get the senteces score
order = np.argsort(utility, axis=0)[::-1] ## descending order, top scores
return [sentences_indoc[i] for i in order[:self.first_k]], [sent_text[i] for i in order[:self.first_k]]
def set_sent_score(self, sent_score_fn):
self.score = sent_score_fn
class AALUtilityThenSR_Firstk(AALUtilityThenStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALUtilityThenSR_Firstk, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_fk # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
class AALUtilityThenSR_Max(AALUtilityThenStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALUtilityThenSR_Max, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
class AALUtilityThenSR_RND(AALUtilityThenStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALUtilityThenSR_RND, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget, seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_rnd # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
class AALTFEUtilityThenSR_Max(AALUtilityThenStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALTFEUtilityThenSR_Max, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
def pick_next(self, pool=None, step_size=1):
# return all order by utility of x
chosen = super(AALTFEUtilityThenSR_Max, self).pick_next(pool=pool, step_size=self.subpool)
pred_class = []
chosen_0 = []
chosen_1 = []
for index_x, sent_x in chosen:
pc = self.sent_model.predict(sent_x[0])
pred_class.append(pc)
if pc == 0:
chosen_0.append([index_x, sent_x[0]])
else:
chosen_1.append([index_x, sent_x[0]])
half = int(step_size / 2)
chosen = chosen_0[:half]
chosen.extend(chosen_1[:half])
if len(chosen) < step_size:
miss = step_size - len(chosen)
if len(chosen_0) < step_size / 2:
chosen.extend(chosen_1[half: (half + miss)])
elif len(chosen_1) < step_size / 2:
chosen.extend(chosen_0[half: (half + miss)])
else:
raise Exception("Oops, we cannot get the next batch. We ran out of instances.")
return chosen
class AALRandomThenSR(AALUtilityThenStructuredReading):
def __init__(self, model=None, accuracy_model=None, budget=None, seed=None, vcn=None, subpool=None,
cost_model=None, fk=1):
super(AALRandomThenSR, self).__init__(model=model, accuracy_model=accuracy_model, budget=budget,
seed=seed,
cost_model=cost_model, vcn=vcn, subpool=subpool)
self.score = self.score_max # sentence score
self.fn_utility = self.utility_unc # document score
self.first_k = fk
self.human_mode = False
def pick_random(self, pool=None, step_size=1):
## version 2:
chosen_x = pool.remaining[pool.offset:(pool.offset + step_size)]
#After utility, pick the best sentence of each document
chosen = self.pick_next_sentence(chosen_x, pool=pool)
return chosen
def pick_next(self, pool=None, step_size=1):
# return all order by utility of x
chosen = self.pick_random(pool=pool, step_size=self.subpool) ## returns index, and feature vector
final = []
if self.human_mode:
for x, y in chosen[:step_size]:
final.append([x, y[1]]) # index, text
else:
try:
for x, y in chosen[:step_size]:
final.append([x, y[0][0]]) #index, feature vector
except IndexError:
print chosen[:step_size]
return final
def x_utility_cs(self, instance, instance_text):
"""
The utility of the sentences inside a document with class sensitive features
:param instance:
:param instance_text:
:return:
"""
sentences_indoc, sent_text = self.getk(instance_text) #get subinstances
self.counter = 0
pred_doc = self.model.predict(instance)
pred_probl = self.sent_model.predict_proba(sentences_indoc)
pred_y = self.sent_model.classes_[np.argmax(pred_probl, axis=1)]
order = np.argsort(pred_probl[:, pred_doc[0]], axis=0)[::-1] # descending order, top scores
best_sent = [sentences_indoc[i] for i in order]
return best_sent[:self.first_k], [sent_text[i] for i in order]
def x_utility_maj(self, instance, instance_text):
"""
The utility of the sentences inside a document with class sensitive features by majority vote of the sentence
classifier.
:param instance:
:param instance_text:
:return:
"""
sentences_indoc, sent_text = self.getk(instance_text) # get subinstances
self.counter = 0
# pred_doc = self.model.predict(instance)
pred_probl = self.sent_model.predict_proba(sentences_indoc)
pred_y = self.sent_model.classes_[np.argmax(pred_probl, axis=1)]
pred_doc = np.round(1. * pred_y.sum() / len(pred_y)) ## majority vote
# utility = np.array([self.score(xik) for xik in sentences_indoc]) # get the senteces score
order = np.argsort(pred_probl[:, pred_doc], axis=0)[::-1] ## descending order, top scores
best_sent = [sentences_indoc[i] for i in order]
# if len(best_sent) > 0:
return best_sent[:self.first_k]
def set_x_utility(self, x_util_fn):
self.x_utility = x_util_fn
def class_sensitive_utility(self):
self.set_x_utility(self.x_utility_cs)
def majority_vote_utility(self):
self.set_x_utility(self.x_utility_maj)
| mramire8/active | strategy/structured.py | Python | apache-2.0 | 47,843 |
import networkx as nx
import numpy as np
def bipartite_region_tracking(partition, optical_flow, reliability,
matching_th=0.1, reliability_th=0.2):
"""
Parameters
----------
partition: numpy array
A 3D label array where each label represents a region
optical_flow: numpy array
A 3D,2 array representing optical flow values for each frame
reliability: numpy array
A 3D array representing the flow reliability
matching_th: float, optional
matching threshold for the bipartite matching
reliability_th: float, optional
reliability threshold to stop tracking
Returns
-------
A NetworkX graph object with adjacency relations
"""
dimensions = len(partition.shape)
if dimensions != 3: # pragma: no cover
raise ValueError("Dimensions must be 3")
# link regions across frames
# perform a weighted bipartite matchings
frames = partition.shape[0]
width = partition.shape[1]
height = partition.shape[2]
new_partition = np.zeros_like(partition)
#the first frame is the same
new_partition[0,...] = partition[0,...]
current_label = np.max(np.unique(partition[0,...]))+1
for frame in range(frames-1):
labels = np.unique(new_partition[frame, ...])
labels_next = np.unique(partition[frame+1, ...])
# create a graph matching contours
bipartite = nx.Graph()
bipartite.add_nodes_from([l for l in labels])
bipartite.add_nodes_from([l for l in labels_next])
# find the correspondence of each label to the next frame
for label in labels:
px, py = np.where(new_partition[frame, ...] == label)
# find the mean reliability
rel = np.mean(reliability[frame, px, py])
if rel < reliability_th: # pragma: no cover
continue
# find where the regions projects to the next frame
npx = px + optical_flow[frame, px, py, 0]
npy = py + optical_flow[frame, px, py, 1]
#check for bounds
in_x = np.logical_and(0 <= npx, npx < width)
in_y = np.logical_and(0 <= npy, npy < height)
idx = np.logical_and(in_x, in_y)
npx = npx[idx]
npy = npy[idx]
count = np.bincount(partition[frame+1,
npx.astype(np.int),
npy.astype(np.int)].astype(np.int))
# get the count and eliminate weak correspondences
max_count = max(count)
nodes = np.nonzero(count > max_count*matching_th)[0]
weight = count[nodes]/max_count
for i, n in enumerate(nodes):
bipartite.add_edge(label, n, weight=weight[i])
# max weighted matching
matchings = nx.max_weight_matching(bipartite)
# assign propagated labels to the matchings
for a in matchings:
b = matchings[a]
#print("Match {0}-{1}".format(a,b))
if b not in labels_next:
continue
px, py = np.where(partition[frame+1, ...] == b)
new_partition[frame+1, px, py] = a
# assign new labels to non-matched regions
for n in bipartite.nodes():
if n not in labels_next:
continue
if n not in matchings:
px, py = np.where(partition[frame+1, ...] == n)
new_partition[frame+1, px, py] = current_label + 1
current_label += 1
return new_partition | guillempalou/scikit-cv | skcv/video/segmentation/region_tracking.py | Python | bsd-3-clause | 3,595 |
from typing import Tuple
from hwt.doc_markers import internal
from hwt.hdl.transPart import TransPart
from hwt.hdl.transTmpl import OneOfTransaction
@internal
def iterSort(iterators, cmpFn):
"""
Sort items from iterators(generators) by alwas selecting item
with lowest value (min first)
:return: generator of tuples (origin index, item) where origin index
is index of iterator in "iterators" from where item commes from
"""
actual = []
_iterators = []
for i, it in enumerate(iterators):
try:
a = next(it)
_iterators.append((i, it))
actual.append(a)
except StopIteration:
continue
while True:
if not _iterators:
return
elif len(_iterators) == 1:
originIndex, it = _iterators[0]
yield originIndex, actual[0]
for item in it:
yield originIndex, item
return
# select minimum and iterator from where it comes from
minimum = None
minimumIndex = None
secondMin = None
for i, val in enumerate(actual):
skipSecMinCheck = False
if minimum is None:
minimum = val
minimumIndex = i
elif cmpFn(val, minimum):
secondMin = minimum
minimum = val
minimumIndex = i
skipSecMinCheck = True
elif not skipSecMinCheck and (
secondMin is None or cmpFn(val, secondMin)):
secondMin = val
actualI, actualIt = _iterators[minimumIndex]
while not cmpFn(secondMin, minimum):
yield (actualI, minimum)
try:
minimum = next(actualIt)
except StopIteration:
minimum = None
break
# consume from actual iterator while
if minimum is None:
del _iterators[minimumIndex]
del actual[minimumIndex]
else:
# minimum is not minimum anymore
actual[minimumIndex] = minimum
class TransPartGroup(list):
"""
Abstract parent class for groups of TransParts
"""
def setIsLast(self, val: bool) -> None:
self._isLast = val
def isLastPart(self) -> bool:
"""
:return: True if this part is last in parts derived from original field
else False
"""
return self._isLast
def getBusWordBitRange(self) -> Tuple[int, int]:
"""
:return: bit range which contains data of this part on bus data signal
"""
offset = self.startOfPart % self.parent.wordWidth
return (offset + self.bit_length(), offset)
def bit_length(self):
return self.endOfPart - self.startOfPart
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__, list.__repr__(self))
class ChoicesOfFrameParts(TransPartGroup):
"""
List of ChoiceOfFrameParts
One of ChoiceOfFrameParts is used to represent the word, item depends
on context
:ivar ~.origin: OneOfTransaction instance
:ivar ~.startOfPart: bit addr of start of this group of frame parts
:ivar ~.endOfPart: bit addr of end of this group of frame parts
:ivar ~._isLast: flag which means this is the last part of original union
"""
def __init__(self, startOfPart: int, origin: OneOfTransaction):
self.origin = origin
self.startOfPart = startOfPart
self.endOfPart = None
self._isLast = False
super(ChoicesOfFrameParts, self).__init__()
def resolveEnd(self):
end = self.startOfPart
for items in self:
if items:
end = max(end, max(itm.endOfPart for itm in items))
self.endOfPart = end
class ChoiceOfFrameParts(list):
"""
:ivar ~.origin: ChoicesOfFrameParts instance
:ivar ~.tmpl: TransTmpl which was item generated from
"""
def __init__(self, origin, tmpl):
self.origin = origin
self.tmpl = tmpl
def __repr__(self):
return "<%s %s>" % (self.__class__.__name__, list.__repr__(self))
def groupIntoChoices(splitsOnWord, wordWidth: int, origin: OneOfTransaction):
"""
:param splitsOnWord: list of lists of parts (fields splited on word
boundaries)
:return: generators of ChoicesOfFrameParts for each word
which are not crossing word boundaries
"""
def cmpWordIndex(a, b):
return a.startOfPart // wordWidth < b.startOfPart // wordWidth
actual = None
itCnt = len(splitsOnWord)
for i, item in iterSort(splitsOnWord, cmpWordIndex):
_actualW = item.startOfPart // wordWidth
if actual is None:
# first pass
actual = ChoicesOfFrameParts(item.startOfPart, origin)
actual.extend(
ChoiceOfFrameParts(actual,
origin.possibleTransactions[_i])
for _i in range(itCnt))
actualW = _actualW
elif _actualW > actualW:
actual.resolveEnd()
yield actual
actual = ChoicesOfFrameParts(item.startOfPart, origin)
actual.extend(
ChoiceOfFrameParts(actual,
origin.possibleTransactions[_i])
for _i in range(itCnt))
actualW = _actualW
actual[i].append(item)
if actual is not None:
actual.setIsLast(True)
actual.resolveEnd()
yield actual
class TransTmplWordIterator():
"""
Iterator which reinterprets any structure
as generator of bits of specified width
"""
def __init__(self, wordWidth):
self.wordWidth = wordWidth
def fullWordCnt(self, start: int, end: int):
"""Count of complete words between two addresses
"""
assert end >= start, (start, end)
gap = max(0, (end - start) - (start % self.wordWidth))
return gap // self.wordWidth
def groupByWordIndex(self, transaction: 'TransTmpl', offset: int):
"""
Group transaction parts splited on words to words
:param transaction: TransTmpl instance which parts
should be grupped into words
:return: generator of tuples (wordIndex, list of transaction parts
in this word)
"""
actualW = None
partsInWord = []
wordWidth = self.wordWidth
for item in self.splitOnWords(transaction, offset):
_actualW = item.startOfPart // wordWidth
if actualW is None:
actualW = _actualW
partsInWord.append(item)
elif _actualW > actualW:
yield (actualW, partsInWord)
actualW = _actualW
partsInWord = [item, ]
else:
partsInWord.append(item)
if partsInWord:
yield (actualW, partsInWord)
@internal
def splitOnWords(self, transaction, addrOffset=0):
"""
:return: generator of TransPart instance
"""
wordWidth = self.wordWidth
end = addrOffset
for tmp in transaction.walkFlatten(offset=addrOffset):
if isinstance(tmp, OneOfTransaction):
# unions
split = [self.splitOnWords(ch, end)
for ch in tmp.possibleTransactions]
yield from groupIntoChoices(split, wordWidth, tmp)
end = addrOffset + tmp.possibleTransactions[0].bitAddrEnd
else:
# constant size types
(base, end), tmpl = tmp
startOfPart = base
while startOfPart != end:
wordIndex = startOfPart // wordWidth
endOfWord = (wordIndex + 1) * wordWidth
endOfPart = min(endOfWord, end)
inFieldOffset = startOfPart - base
yield TransPart(self, tmpl, False, startOfPart, endOfPart,
inFieldOffset)
startOfPart = endOfPart
| Nic30/HWToolkit | hwt/hdl/frameTmplUtils.py | Python | mit | 8,128 |
"""Offer time listening automation rules."""
import logging
import voluptuous as vol
from homeassistant.core import callback
from homeassistant.const import CONF_AT, CONF_PLATFORM
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.event import async_track_time_change
# mypy: allow-untyped-defs, no-check-untyped-defs
_LOGGER = logging.getLogger(__name__)
TRIGGER_SCHEMA = vol.Schema(
{vol.Required(CONF_PLATFORM): "time", vol.Required(CONF_AT): cv.time}
)
async def async_attach_trigger(hass, config, action, automation_info):
"""Listen for state changes based on configuration."""
at_time = config.get(CONF_AT)
hours, minutes, seconds = at_time.hour, at_time.minute, at_time.second
@callback
def time_automation_listener(now):
"""Listen for time changes and calls action."""
hass.async_run_job(action, {"trigger": {"platform": "time", "now": now}})
return async_track_time_change(
hass, time_automation_listener, hour=hours, minute=minutes, second=seconds
)
| joopert/home-assistant | homeassistant/components/automation/time.py | Python | apache-2.0 | 1,060 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero Public License for more details.
#
# You should have received a copy of the GNU Affero Public License
# along with this program. If not, see http://www.gnu.org/licenses.
#
# http://numenta.org/licenses/
# ----------------------------------------------------------------------
## This file defines parameters for a prediction experiment.
import os
from nupic.frameworks.opf.exp_description_helpers import importBaseDescription
# the sub-experiment configuration
config = \
{
'dataSource': 'file://' + os.path.join(os.path.dirname(__file__),
'../datasets/simple_0.csv'),
'modelParams': { 'clParams': { },
'sensorParams': { 'encoders': { }, 'verbosity': 0},
'spParams': { },
'tmParams': { }}}
mod = importBaseDescription('../base/description.py', config)
locals().update(mod.__dict__)
| ywcui1990/nupic | examples/opf/experiments/multistep/simple_0/description.py | Python | agpl-3.0 | 1,588 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Joji Doi
import argparse
import os
import json
import shutil
"""
/usr/local/bin/file_lister.py
script to list all media files in the given --media-root dir
"""
""" MEDIA_TYPES -- key is supported folder name, value is a tuple of supported file extensions """
MEDIA_TYPES = {
"documents": ('.pdf', '.txt'),
"books": ('.pdf', '.txt'),
"music": ('.mp3', '.ogg'),
"photos": ('.png', '.jpg'),
"tv": ('.mp4', '.webm'),
"videos": ('.mp4', '.webm')
}
MEDIA_FOLDERS = MEDIA_TYPES.keys()
media_filter = lambda f: f.lower() in MEDIA_FOLDERS
def create_file_list_json(output_dir, media_files):
"""
Create a media file list in json format.
Example output
"""
with open(output_dir + '/media_files_list.json', 'w') as the_file:
the_file.write(json.dumps(media_files))
def file_filter(extensions):
"""
This lambda function filters out hidden file (starts with '.') and non matched extension.
argument:
extensions -- tuple of file extensions string
"""
return lambda a_file: not a_file.startswith('.') and a_file.lower().endswith(extensions)
def list_files(media_root, dirname, filter):
"""
List files under specified directory returns filtered files.
Sort by file name.
arguments:
dirname -- directory name
filter -- file filter function
"""
all_files = os.listdir(os.path.join(media_root, dirname))
return sorted(a_file for a_file in all_files if filter(a_file))
def list_media_dirs(media_root):
"""
Returns a list of media directories (case insensitive)
"""
media_root = os.path.abspath(media_root);
all_dirs = [ dirs for dirs in os.listdir(media_root)
if os.path.isdir(os.path.join(media_root, dirs)) ]
return sorted(filter(media_filter, all_dirs))
def list_media_files(media_root, media_folders):
"""
Returns a list of media files in the given folders
arguments:
media_root -- root directory for the media_folders
media_folders -- directories to be scanned
Example output:
[{"id": "1", "title":"Tears of Steel","file_ext":"mp4","category":"videos","dir":"Videos"}]
"""
output = []
id = 0
for folder in media_folders:
lowercase_folder = folder.lower()
for media_file in list_files(media_root, folder, file_filter(MEDIA_TYPES[lowercase_folder])):
name, ext = os.path.splitext(media_file)
output.append({"id": id, "category": lowercase_folder, "title": name, "file_ext": ext, "dir": folder})
id += 1
return output
def customize_ui_background_image(media_root, web_image_dir):
"""
If background.jpg file is provided in Media root directory, use this file.
If not, then use background_default.jpg
"""
src = os.path.join(web_image_dir, 'background_default.jpg')
background_files = [ bg_file for bg_file in os.listdir(media_root)
if os.path.isfile(os.path.join(media_root, bg_file))
and bg_file.lower() == 'background.jpg' ]
if len(background_files) > 0:
custom_bg_img = background_files[0]
src = os.path.join(media_root, custom_bg_img)
dest = os.path.join(web_image_dir, 'background.jpg')
shutil.copyfile(src, dest)
os.chmod(dest, 0644)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Media File Lister script parses')
parser.add_argument('-m', '--media-root', default='/mnt', help='Media root location')
parser.add_argument('-o', '--output-dir', default='/var/www/html/data',
help='output json file')
parser.add_argument('-i', '--image-dir', default='/var/www/html/img',
help='directory for background.jpg to be created also contains background_default.jpg ')
args = parser.parse_args()
media_root = args.media_root
output_dir = args.output_dir
web_image_dir = args.image_dir
media_folders = list_media_dirs(media_root)
create_file_list_json(output_dir, list_media_files(media_root, media_folders))
customize_ui_background_image(media_root, web_image_dir)
| do-i/bansible | roles/webapp/files/file_lister.py | Python | mit | 4,213 |
#!/usr/bin/python3 -tt
from .config_agent import ConfigAgent
__all__ = ['ConfigAgent']
| techlib/adminator | adminator/config_agent/__init__.py | Python | mit | 89 |
#!/usr/bin/env python
"""Parsers for handling rekall output."""
import json
import ntpath
from grr.lib import artifact_utils
from grr.lib import parsers
from grr.lib.rdfvalues import client as rdf_client
from grr.lib.rdfvalues import paths as rdf_paths
class RekallPsListParser(parsers.RekallPluginParser):
"""Parser for Rekall PsList results."""
output_types = ["Process"]
supported_artifacts = ["RekallPsList"]
def ParseProcess(self, item):
cybox = item.get("_EPROCESS", {}).get("Cybox", {})
result = rdf_client.Process(
exe=cybox.get("Name"),
pid=cybox.get("PID"),
ppid=cybox.get("Parent_PID"),
num_threads=item.get("thread_count"),
ctime=item.get("process_create_time", {}).get("epoch"),
)
return result
def Parse(self, response, unused_knowledge_base):
"""Parse the key pslist plugin output."""
for message in json.loads(response.json_messages):
if message[0] == "r":
yield self.ParseProcess(message[1])
class RekallVADParser(parsers.RekallPluginParser):
output_types = ["PathSpec"]
supported_artifacts = ["FullVADBinaryList"]
# Required for environment variable expansion
knowledgebase_dependencies = ["environ_systemdrive", "environ_systemroot"]
def Parse(self, response, knowledge_base):
system_drive = artifact_utils.ExpandWindowsEnvironmentVariables(
"%systemdrive%", knowledge_base)
for message in json.loads(response.json_messages):
if message[0] == "r":
protection = message[1].get("protection", {}).get("enum", "")
if "EXECUTE" not in protection:
continue
filename = message[1].get("filename", "")
if filename and filename != "Pagefile-backed section":
yield rdf_paths.PathSpec(
path=ntpath.normpath(ntpath.join(system_drive, filename)),
pathtype=rdf_paths.PathSpec.PathType.OS)
| darrenbilby/grr | parsers/rekall_artifact_parser.py | Python | apache-2.0 | 1,907 |
from website.files.models.base import File, Folder, FileNode
__all__ = ('S3File', 'S3Folder', 'S3FileNode')
class S3FileNode(FileNode):
provider = 's3'
class S3Folder(S3FileNode, Folder):
pass
class S3File(S3FileNode, File):
version_identifier = 'version'
| ticklemepierce/osf.io | website/files/models/s3.py | Python | apache-2.0 | 275 |
# BEGIN_COPYRIGHT
#
# Copyright (C) 2009-2013 CRS4.
#
# This file is part of biodoop-core.
#
# biodoop-core is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# biodoop-core is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# biodoop-core. If not, see <http://www.gnu.org/licenses/>.
#
# END_COPYRIGHT
import numpy as np
def load_array(a, x):
assert isinstance(x, np.ndarray)
a.type_name = '%r' % x.dtype
a.byte_order = x.dtype.byteorder
a.dims = len(x.shape)
for d in x.shape:
a.shape.append(d)
a.data = x.tostring()
def unload_array(a):
dtype = eval('np.'+a.type_name)
x = np.fromstring(a.data, dtype=dtype)
x.shape = tuple(a.shape)
assert len(x.shape) == a.dims
return x
| crs4/biodoop-core | bl/core/messages/details/__init__.py | Python | gpl-3.0 | 1,154 |
#!/usr/bin/env python
#--------------------------------------------------------------------------
# Python to manage garage alarms and door bell
# sends notification out to Instapush
# logs CLIMATE to RRD
# Open/Close may be reversed is code started WITH THE DOOR OPEN/CLOSED
# KFREEGARD/NORTHWARKS 2016
# Version 1.0 23.06.2016
# USE AT YOUR OWN RISK - DON'T RISK/PROTECT LIFE/CRITICAL ASSESTS WITH IT!
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
#Python to manage garage alarms and door bell
#sends notification out to Instapush
#logs to RRD
# Open/Close may be reversed if code started with door(s) open
# Version 1.2 12.08.2016
#--------------------------------------------------------------------------
#External Imports
import RPi.GPIO as GPIO
import time
from time import sleep
import datetime
import Adafruit_DHT
import traceback
from threading import Thread, Event
import sys
from instapush import Instapush, App
import rrdtool
from rrdtool import update as rrd_update
import urllib2
import os
#Define Instapush App Details
app = App(appid='SOMESECRET', secret='SOMESECRET')
#Define GPIO Numbering
GPIO.setmode(GPIO.BCM)
#---------- GPIO SETUP------
#Define individual GPIO Pins
PIN_GARAGE_DOOR = 17
PIN_DOOR_BELL = 21
PIN_SHUT_DOWN = 18
PIN_WIFI_LED = 19
PIN_ALARM = 16
PIN_TEMP_HUMID = 4 #ONLY HERE AS A REMARK AS DHT Module sets GPIO as 4
#Setup GPIO Pins
GPIO.setup(PIN_GARAGE_DOOR, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set 17 as input with pull up res
GPIO.setup(PIN_DOOR_BELL, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set 21 as input with pull up res
GPIO.setup(PIN_SHUT_DOWN, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set 18 as input with pull up res
GPIO.setup(PIN_ALARM, GPIO.IN, pull_up_down=GPIO.PUD_UP) # set 16 as input with pull up res
GPIO.setup(PIN_WIFI_LED, GPIO.OUT)
#Define Variables
global OPEN_TIME
global CLOSE_TIME
global TIME_DIFF
global DOOR_TRIGGER
global WIFI_IS_UP
DOOR_TRIGGER = True
WIFI_IS_UP = False
#----------------------------
# Define a threaded callback function to
# run in another thread when events are detected
# needs GPIO.BOTH to catch both up/down (open/close)
def garage_callback(channel):
global DOOR_TRIGGER
while True:
if GPIO.input(PIN_GARAGE_DOOR): # if door is opened
if (DOOR_TRIGGER):
door_open()
DOOR_TRIGGER = False # make sure it doesn't fire again
return
if not GPIO.input(PIN_GARAGE_DOOR): # if door is closed
if not (DOOR_TRIGGER):
door_close()
DOOR_TRIGGER = True # make sure it doesn't fire again
return
#---------------------------
#Define a threaded callback to watch the doorbell
def door_callback(channel):
door_bell()
#Define a threaded callback to watch the alarm output
def alarm_callback(channel):
alarm()
#----------------------------
# function for door open
def door_open():
#get open time
global OPEN_TIME
OPEN_TIME = datetime.datetime.now().replace(microsecond=0)
ts = time.time()
timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
alertmsg = timestamp + " - Garage Door Open!"
global alert_type
alert_type = "GarageDoorAlert"
Send_Alert(alert_type, alertmsg)
#----------------------------
# function for door close
def door_close():
global CLOSE_TIME
global OPEN_TIME
CLOSE_TIME = datetime.datetime.now().replace(microsecond=0)
OPEN_DURATION = calc_time(CLOSE_TIME, OPEN_TIME)
ts = time.time()
timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
alertmsg = timestamp + " - Garage Door Closed, " + OPEN_DURATION
global alert_type
alert_type = "GarageDoorAlert"
Send_Alert(alert_type, alertmsg)
# calc_time(CLOSE_TIME, OPEN_TIME)
#---------------------------
#function for door bell
def door_bell():
ts = time.time()
timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
alertmsg = timestamp + " - Door Bell!"
global alart_type
alert_type = "DoorBell"
Send_Alert(alert_type, alertmsg)
#---------------------------
def alarm():
ts = time.time()
timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
alertmsg = timestamp + " - Alarm !"
global alart_type
alert_type = "Alarm"
Send_Alert(alert_type, alertmsg)
#---------------------------
# lets set some initial time values
# prevent a crash on initial start
def set_initial_time():
global CLOSE_TIME
global OPEN_TIME
CLOSE_TIME = datetime.datetime.now().replace(microsecond=0)
OPEN_TIME = datetime.datetime.now().replace(microsecond=0)
def calc_time(T1, T2):
difference = T1 - T2
# print ("Garage Door Open for - " + str(difference))
OPEN_FOR = ("Garage Door Was Open for - " + str(difference))
WriteAlarmLog(OPEN_FOR)
#reset times
OPEN_TIME = 0
CLOSE_TIME = 0
return OPEN_FOR
#---- send notification--------
def SendAlertMod(ALERT_TYPE, ALERT_MESSAGE):
if (app.notify(event_name= ALERT_TYPE, trackers={ 'message': ALERT_MESSAGE})) is True:
print ALERT_MESSAGE
else:
print "Error sending notification to Instapush"
#------------------------------
def WriteClimateLog(TEMPERATURE, HUMIDITY):
FILEPATH = "/home/pi/scripts/log/climate.log"
fh = open(FILEPATH, "a")
fh.write(str(TEMPERATURE))
fh.write("\n")
fh.write(str(HUMIDITY))
fh.write("\n")
fh.close
return
#------------------------------
#write to RRD file
def WriteRRD(TEMP, HUM):
FILEPATH = "/home/pi/scripts/log/garage_climate.rrd"
TEMP=float(TEMP)
HUM=float(HUM)
rrd_update(FILEPATH, 'N:%s:%s' %(TEMP, HUM))
#------------------------------
def WriteAlarmLog(ALARM):
FILEPATH = "/home/pi/scripts/log/alarm.log"
fh = open(FILEPATH, "a")
fh.write(ALARM)
fh.write("\n")
fh.close
return
#------------------------------
# Centralise alert message logging and sending
def Send_Alert(ALERT_TYPE, ALERT_MESSAGE):
app.notify(event_name= ALERT_TYPE, trackers={ 'message': ALERT_MESSAGE})
#Append alarm log
WriteAlarmLog(ALERT_MESSAGE)
print ALERT_MESSAGE
#--------------------------
# Get temp/Hum
# DHT22_PIN = GPIO4
class PeriodicThread(Thread):
def __init__(self, interval):
self.stop_event = Event()
self.interval = interval
super(PeriodicThread, self).__init__()
def run(self):
while not self.stop_event.is_set():
self.main()
# wait self.interval seconds or until the stop_event is set
self.stop_event.wait(self.interval)
def terminate(self):
self.stop_event.set()
def main(self):
print('Replaced with subclass')
class GetClimate(PeriodicThread):
def main(self):
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT22, 4)
if temperature is not None and humidity is not None:
self.temperature = timestamp + ' - Temperature: {:.1f} C'.format(temperature)
self.humidity = timestamp + ' - Humidity: {:.1f} %'.format(humidity)
WriteRRD(round(temperature,1), round(humidity,1))
# WriteClimateLog(self.temperature, self.humidity)
class GetWIFI(PeriodicThread):
def main(self):
global WIFI_IS_UP
if Internet_On() == 1 and not WIFI_IS_UP:
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
IsWIFIup = timestamp + ' - WiFi Up'
WriteAlarmLog(IsWIFIup)
WIFI_IS_UP = True
GPIO.output(PIN_WIFI_LED,True)
elif Internet_On() == 0:
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
IsWIFIup = timestamp + ' - WiFi Down!'
WriteAlarmLog(IsWIFIup)
WIFI_IS_UP = False
GPIO.output(PIN_WIFI_LED,False)
else:
pass
#Check for gateway up - do it just once.
def Internet_On():
loop_value = 1
while (loop_value == 1):
try:
response=urllib2.urlopen('http://192.168.1.1',timeout=1)
return True
except urllib2.URLError as err: pass
return False
loop_value = 0
def Shutdown(channel):
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
IsShutDown = timestamp + ' - Shutting Down AlarmPI !'
WriteAlarmLog(IsShutDown)
os.system("sudo shutdown -h now")
#----------------------------------------------
#Setup GPIO Threaded Pins
#HAS to be after the callback function
#GPIO.both Looks for both up/down (open/close door)and calls callback function with debounce(ms) to stop repeats
GPIO.add_event_detect(PIN_GARAGE_DOOR, GPIO.BOTH, callback=garage_callback, bouncetime=2000)
GPIO.add_event_detect(PIN_DOOR_BELL, GPIO.FALLING, callback=door_callback, bouncetime=2000)
GPIO.add_event_detect(PIN_SHUT_DOWN, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
GPIO.add_event_detect(PIN_ALARM, GPIO.FALLING, callback = alarm_callback, bouncetime = 2000)
#============================================================================
#Runs non-stop
# worker thread is a subclass of Periodic class, GetClimate just replaces the def main.
def main():
try:
worker = GetClimate(interval=900)#15mins
worker.start()
worker1 = GetWIFI(interval=300)#5mins
worker1.start()
set_initial_time()
print "..Ready"
while True:
time.sleep(1)
except KeyboardInterrupt:
print "Shutdown requested...exiting"
GPIO.cleanup()
worker.terminate()
worker1.terminate()
except Exception:
traceback.print_exc(file=sys.stdout)
GPIO.cleanup()
worker.terminate()
worker1.terminate()
sys.exit(0)
if __name__ == "__main__":
main()
| northwarks/AlarmPi | alarmpi.py | Python | gpl-3.0 | 9,787 |
# Copyright (c) 2013 Mirantis 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 operator
import os
import time
import flask
from flask.ext import gravatar as gravatar_ext
from oslo.config import cfg
from dashboard import decorators
from dashboard import helpers
from dashboard import parameters
from dashboard import reports
from dashboard import vault
from stackalytics.openstack.common import log as logging
from stackalytics.processor import config
from stackalytics.processor import utils
# Application objects ---------
app = flask.Flask(__name__)
app.config.from_object(__name__)
app.config.from_envvar('DASHBOARD_CONF', silent=True)
app.register_blueprint(reports.blueprint)
LOG = logging.getLogger(__name__)
conf = cfg.CONF
conf.register_opts(config.OPTS)
logging.setup('dashboard')
LOG.info('Logging enabled')
conf_file = os.getenv('STACKALYTICS_CONF')
if conf_file and os.path.isfile(conf_file):
conf(default_config_files=[conf_file])
app.config['DEBUG'] = cfg.CONF.debug
else:
LOG.warn('Conf file is empty or not exist')
# Handlers ---------
@app.route('/')
@decorators.templated()
def overview():
pass
@app.route('/widget')
def widget():
return flask.render_template('widget.html')
@app.errorhandler(404)
@decorators.templated('404.html', 404)
def page_not_found(e):
pass
# AJAX Handlers ---------
def _get_aggregated_stats(records, metric_filter, keys, param_id,
param_title=None, finalize_handler=None):
param_title = param_title or param_id
result = dict((c, {'metric': 0, 'id': c}) for c in keys)
for record in records:
metric_filter(result, record, param_id)
result[record[param_id]]['name'] = record[param_title]
if not finalize_handler:
finalize_handler = lambda x: x
response = [finalize_handler(result[r]) for r in result
if result[r]['metric']]
response.sort(key=lambda x: x['metric'], reverse=True)
return response
@app.route('/api/1.0/stats/companies')
@decorators.jsonify('stats')
@decorators.exception_handler()
@decorators.record_filter()
@decorators.aggregate_filter()
def get_companies(records, metric_filter, finalize_handler):
return _get_aggregated_stats(records, metric_filter,
vault.get_memory_storage().get_companies(),
'company_name')
@app.route('/api/1.0/stats/modules')
@decorators.jsonify('stats')
@decorators.exception_handler()
@decorators.record_filter()
@decorators.aggregate_filter()
def get_modules(records, metric_filter, finalize_handler):
return _get_aggregated_stats(records, metric_filter,
vault.get_memory_storage().get_modules(),
'module')
@app.route('/api/1.0/stats/engineers')
@decorators.jsonify('stats')
@decorators.exception_handler()
@decorators.record_filter()
@decorators.aggregate_filter()
def get_engineers(records, metric_filter, finalize_handler):
return _get_aggregated_stats(records, metric_filter,
vault.get_memory_storage().get_user_ids(),
'user_id', 'author_name',
finalize_handler=finalize_handler)
@app.route('/api/1.0/stats/distinct_engineers')
@decorators.jsonify('stats')
@decorators.exception_handler()
@decorators.record_filter()
def get_distinct_engineers(records):
result = {}
for record in records:
result[record['user_id']] = {
'author_name': record['author_name'],
'author_email': record['author_email'],
}
return result
@app.route('/api/1.0/activity')
@decorators.jsonify('activity')
@decorators.exception_handler()
@decorators.record_filter()
def get_activity_json(records):
start_record = int(flask.request.args.get('start_record') or 0)
page_size = int(flask.request.args.get('page_size') or
parameters.DEFAULT_RECORDS_LIMIT)
records_sorted = sorted(records, key=lambda x: x['date'], reverse=True)
records_sorted = records_sorted[start_record:start_record + page_size]
result = []
for record in records_sorted:
processed_record = helpers.extend_record(record)
if processed_record:
result.append(processed_record)
return result
@app.route('/api/1.0/contribution')
@decorators.jsonify('contribution')
@decorators.exception_handler()
@decorators.record_filter(ignore='metric')
def get_contribution_json(records):
return helpers.get_contribution_summary(records)
@app.route('/api/1.0/companies')
@decorators.jsonify('companies')
@decorators.exception_handler()
@decorators.record_filter(ignore='company')
def get_companies_json(records):
query = flask.request.args.get('company_name') or ''
options = set()
for record in records:
name = record['company_name']
if name in options:
continue
if name.lower().find(query.lower()) >= 0:
options.add(name)
result = [{'id': helpers.safe_encode(c.lower()), 'text': c}
for c in sorted(options)]
return result
@app.route('/api/1.0/modules')
@decorators.jsonify('modules')
@decorators.exception_handler()
@decorators.record_filter(ignore='module')
def get_modules_json(records):
module_group_index = vault.get_vault()['module_group_index']
module_id_index = vault.get_vault()['module_id_index']
modules_set = set()
for record in records:
module = record['module']
if module not in modules_set:
modules_set.add(module)
modules_groups_set = set()
for module in modules_set:
if module in module_group_index:
modules_groups_set |= module_group_index[module]
modules_set |= modules_groups_set
query = (flask.request.args.get('module_name') or '').lower()
options = []
for module in modules_set:
if module.find(query) >= 0:
options.append(module_id_index[module])
return sorted(options, key=operator.itemgetter('text'))
@app.route('/api/1.0/companies/<company_name>')
@decorators.jsonify('company')
def get_company(company_name):
memory_storage_inst = vault.get_memory_storage()
for company in memory_storage_inst.get_companies():
if company.lower() == company_name.lower():
return {
'id': company_name,
'text': memory_storage_inst.get_original_company_name(
company_name)
}
flask.abort(404)
@app.route('/api/1.0/modules/<module>')
@decorators.jsonify('module')
def get_module(module):
module_id_index = vault.get_vault()['module_id_index']
module = module.lower()
if module in module_id_index:
return module_id_index[module]
flask.abort(404)
@app.route('/api/1.0/stats/bp')
@decorators.jsonify('stats')
@decorators.exception_handler()
@decorators.record_filter()
def get_bpd(records):
result = []
for record in records:
if record['record_type'] in ['bpd', 'bpc']:
mention_date = record.get('mention_date')
if mention_date:
date = helpers.format_date(mention_date)
else:
date = 'never'
result.append({
'date': date,
'status': record['lifecycle_status'],
'metric': record.get('mention_count') or 0,
'id': record['name'],
'name': record['name'],
'link': helpers.make_blueprint_link(record['module'],
record['name'])
})
result.sort(key=lambda x: x['metric'], reverse=True)
return result
@app.route('/api/1.0/users')
@decorators.jsonify('users')
@decorators.exception_handler()
@decorators.record_filter(ignore='user_id')
def get_users_json(records):
user_name_query = flask.request.args.get('user_name') or ''
user_ids = set()
result = []
for record in records:
user_id = record['user_id']
if user_id in user_ids:
continue
user_name = record['author_name']
if user_name.lower().find(user_name_query.lower()) >= 0:
user_ids.add(user_id)
result.append({'id': user_id, 'text': user_name})
result.sort(key=lambda x: x['text'])
return result
@app.route('/api/1.0/users/<user_id>')
@decorators.jsonify('user')
def get_user(user_id):
user = vault.get_user_from_runtime_storage(user_id)
if not user:
flask.abort(404)
user = helpers.extend_user(user)
return user
@app.route('/api/1.0/releases')
@decorators.jsonify('releases')
@decorators.exception_handler()
def get_releases_json():
query = (flask.request.args.get('query') or '').lower()
return [{'id': r['release_name'], 'text': r['release_name'].capitalize()}
for r in vault.get_release_options()
if r['release_name'].find(query) >= 0]
@app.route('/api/1.0/releases/<release>')
@decorators.jsonify('release')
def get_release_json(release):
if release != 'all':
if release not in vault.get_vault()['releases']:
release = parameters.get_default('release')
return {'id': release, 'text': release.capitalize()}
@app.route('/api/1.0/metrics')
@decorators.jsonify('metrics')
@decorators.exception_handler()
def get_metrics_json():
query = (flask.request.args.get('query') or '').lower()
return sorted([{'id': m, 'text': t}
for m, t in parameters.METRIC_LABELS.iteritems()
if t.lower().find(query) >= 0],
key=operator.itemgetter('text'))
@app.route('/api/1.0/metrics/<metric>')
@decorators.jsonify('metric')
@decorators.exception_handler()
def get_metric_json(metric):
if metric not in parameters.METRIC_LABELS:
metric = parameters.get_default('metric')
return {'id': metric, 'text': parameters.METRIC_LABELS[metric]}
@app.route('/api/1.0/project_types')
@decorators.jsonify('project_types')
@decorators.exception_handler()
def get_project_types_json():
return [{'id': m, 'text': m, 'items': list(t)}
for m, t in vault.get_project_type_options().iteritems()]
@app.route('/api/1.0/project_types/<project_type>')
@decorators.jsonify('project_type')
@decorators.exception_handler()
def get_project_type_json(project_type):
if project_type != 'all':
for pt, groups in vault.get_project_type_options().iteritems():
if (project_type == pt) or (project_type in groups):
break
else:
project_type = parameters.get_default('project_type')
return {'id': project_type, 'text': project_type}
@app.route('/api/1.0/stats/timeline')
@decorators.jsonify('timeline')
@decorators.exception_handler()
@decorators.record_filter(ignore='release')
def timeline(records, **kwargs):
# find start and end dates
release_names = parameters.get_parameter(kwargs, 'release', 'releases')
releases = vault.get_vault()['releases']
if not release_names:
flask.abort(404)
if 'all' in release_names:
start_date = release_start_date = utils.timestamp_to_week(
vault.get_vault()['start_date'])
end_date = release_end_date = utils.timestamp_to_week(
vault.get_vault()['end_date'])
else:
release = releases[release_names[0]]
start_date = release_start_date = utils.timestamp_to_week(
release['start_date'])
end_date = release_end_date = utils.timestamp_to_week(
release['end_date'])
now = utils.timestamp_to_week(int(time.time())) + 1
# expand start-end to year if needed
if release_end_date - release_start_date < 52:
expansion = (52 - (release_end_date - release_start_date)) // 2
if release_end_date + expansion < now:
end_date += expansion
else:
end_date = now
start_date = end_date - 52
# empty stats for all weeks in range
weeks = range(start_date, end_date)
week_stat_loc = dict((c, 0) for c in weeks)
week_stat_commits = dict((c, 0) for c in weeks)
week_stat_commits_hl = dict((c, 0) for c in weeks)
param = parameters.get_parameter(kwargs, 'metric')
if ('commits' in param) or ('loc' in param):
handler = lambda record: record['loc']
else:
handler = lambda record: 0
# fill stats with the data
for record in records:
week = record['week']
if week in weeks:
week_stat_loc[week] += handler(record)
week_stat_commits[week] += 1
if 'all' in release_names or record['release'] in release_names:
week_stat_commits_hl[week] += 1
# form arrays in format acceptable to timeline plugin
array_loc = []
array_commits = []
array_commits_hl = []
for week in weeks:
week_str = utils.week_to_date(week)
array_loc.append([week_str, week_stat_loc[week]])
array_commits.append([week_str, week_stat_commits[week]])
array_commits_hl.append([week_str, week_stat_commits_hl[week]])
return [array_commits, array_commits_hl, array_loc]
gravatar = gravatar_ext.Gravatar(app, size=64, rating='g', default='wavatar')
def main():
app.run(cfg.CONF.listen_host, cfg.CONF.listen_port)
if __name__ == '__main__':
main()
| pabelanger/stackalytics | dashboard/web.py | Python | apache-2.0 | 13,882 |
import logging
import os
import requests
import json
from .twxthing import TWX_Thing, TWX_Property,TWX_Template
from .twxexcelparser import parseSimulatorConfig
from .helper import setup_log,parse_commandline
from .thingworx import ThingworxServer
def get_server(args):
configurationpath = args.config_path
configurationfile = args.config
testServer = ThingworxServer.fromConfigurationFile(os.path.join(configurationpath, configurationfile))
testServer.validateSSL = args.sslvalidation
#print("sslvalidation:{}".format(testServer.validateSSL))
testServer.simulatorConfigurationFile = os.path.join(configurationpath,'simulatorconfig.xlsx')
return testServer
def collections():
setup_log()
testServer = get_server(parse_commandline())
templates = parseSimulatorConfig(testServer.simulatorConfigurationFile)
# print(templates.keys())
myThings={}
for key, value in templates.items():
logging.info('{}--->{}'.format(key, value))
if not testServer.check_template(value.remoteTemplateName):
logging.info("template {} with full name {} doesn't exist, bypass.".format(key,value.remoteTemplateName))
continue
for index in range(2):
newThing = TWX_Thing(value.name + '_Simulator_{}'.format(index), value, testServer)
myThings[newThing.name] = newThing
if testServer.check_thing(newThing.name):
newThing.created = True
logging.info("Thing:{} exists on Server.".format(newThing.name))
else:
logging.info("Start to create thing:{}".format(newThing.name))
if newThing.self_create_thing():
newThing.created = True
logging.info("Thing:{} created successfully.".format(newThing.name))
else:
logging.info("Failed to Create Thing:{}".format(newThing.name))
return myThings
def main():
myThings = collections()
for index in range(2):
for key, thing in myThings.items():
print("{}->Key:{}-->{}-->Thing:{}".format(index,key,thing.created,thing))
updatedProperties = thing.next()
for propertyName, propertyValue in updatedProperties.items():
url = thing.server.get_thing_property_update_url(thing.name,propertyName)
body = {
propertyName:propertyValue
}
logging.info("Update Property:{}".format(json.dumps(body,indent=2)))
ret = requests.request("PUT",url, headers=thing.server.get_headers(),json=body, verify=thing.server.validateSSL)
logging.info("Response:{} with text:{}".format(ret.status_code, ret.text))
if __name__ == '__main__':
main() | arproio/kpitest | kpitest/restsimulator.py | Python | mit | 2,804 |
"""
Logistic Regression
"""
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# Fabian Pedregosa <f@bianp.net>
# Alexandre Gramfort <alexandre.gramfort@telecom-paristech.fr>
# Manoj Kumar <manojkumarsivaraj334@gmail.com>
import numbers
import warnings
import numpy as np
from scipy import optimize, sparse
from .base import LinearClassifierMixin, SparseCoefMixin, BaseEstimator
from ..feature_selection.from_model import _LearntSelectorMixin
from ..preprocessing import LabelEncoder
from ..svm.base import BaseLibLinear
from ..utils import check_array, check_consistent_length, compute_class_weight
from ..utils.extmath import log_logistic, safe_sparse_dot
from ..utils.optimize import newton_cg
from ..utils.validation import as_float_array, DataConversionWarning
from ..utils.fixes import expit
from ..externals.joblib import Parallel, delayed
from ..cross_validation import _check_cv
from ..externals import six
from ..metrics import SCORERS
# .. some helper functions for logistic_regression_path ..
def _intercept_dot(w, X, y):
"""Computes y * np.dot(X, w).
It takes into consideration if the intercept should be fit or not.
Parameters
----------
w : ndarray, shape (n_features,) or (n_features + 1,)
Coefficient vector.
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data.
y : ndarray, shape (n_samples,)
Array of labels.
"""
c = 0.
if w.size == X.shape[1] + 1:
c = w[-1]
w = w[:-1]
z = safe_sparse_dot(X, w) + c
return w, c, y * z
def _logistic_loss_and_grad(w, X, y, alpha, sample_weight=None):
"""Computes the logistic loss and gradient.
Parameters
----------
w : ndarray, shape (n_features,) or (n_features + 1,)
Coefficient vector.
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data.
y : ndarray, shape (n_samples,)
Array of labels.
alpha : float
Regularization parameter. alpha is equal to 1 / C.
sample_weight : ndarray, shape (n_samples,) optional
Array of weights that are assigned to individual samples.
If not provided, then each sample is given unit weight.
Returns
-------
out : float
Logistic loss.
grad : ndarray, shape (n_features,) or (n_features + 1,)
Logistic gradient.
"""
_, n_features = X.shape
grad = np.empty_like(w)
w, c, yz = _intercept_dot(w, X, y)
if sample_weight is None:
sample_weight = np.ones(y.shape[0])
# Logistic loss is the negative of the log of the logistic function.
out = -np.sum(sample_weight * log_logistic(yz)) + .5 * alpha * np.dot(w, w)
z = expit(yz)
z0 = sample_weight * (z - 1) * y
grad[:n_features] = safe_sparse_dot(X.T, z0) + alpha * w
# Case where we fit the intercept.
if grad.shape[0] > n_features:
grad[-1] = z0.sum()
return out, grad
def _logistic_loss(w, X, y, alpha, sample_weight=None):
"""Computes the logistic loss.
Parameters
----------
w : ndarray, shape (n_features,) or (n_features + 1,)
Coefficient vector.
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data.
y : ndarray, shape (n_samples,)
Array of labels.
alpha : float
Regularization parameter. alpha is equal to 1 / C.
sample_weight : ndarray, shape (n_samples,) optional
Array of weights that are assigned to individual samples.
If not provided, then each sample is given unit weight.
Returns
-------
out : float
Logistic loss.
"""
w, c, yz = _intercept_dot(w, X, y)
if sample_weight is None:
sample_weight = np.ones(y.shape[0])
# Logistic loss is the negative of the log of the logistic function.
out = -np.sum(sample_weight * log_logistic(yz)) + .5 * alpha * np.dot(w, w)
return out
def _logistic_loss_grad_hess(w, X, y, alpha, sample_weight=None):
"""Computes the logistic loss, gradient and the Hessian.
Parameters
----------
w : ndarray, shape (n_features,) or (n_features + 1,)
Coefficient vector.
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data.
y : ndarray, shape (n_samples,)
Array of labels.
alpha : float
Regularization parameter. alpha is equal to 1 / C.
sample_weight : ndarray, shape (n_samples,) optional
Array of weights that are assigned to individual samples.
If not provided, then each sample is given unit weight.
Returns
-------
out : float
Logistic loss.
grad : ndarray, shape (n_features,) or (n_features + 1,)
Logistic gradient.
Hs : callable
Function that takes the gradient as a parameter and returns the
matrix product of the Hessian and gradient.
"""
n_samples, n_features = X.shape
grad = np.empty_like(w)
fit_intercept = grad.shape[0] > n_features
w, c, yz = _intercept_dot(w, X, y)
if sample_weight is None:
sample_weight = np.ones(y.shape[0])
# Logistic loss is the negative of the log of the logistic function.
out = -np.sum(sample_weight * log_logistic(yz)) + .5 * alpha * np.dot(w, w)
z = expit(yz)
z0 = sample_weight * (z - 1) * y
grad[:n_features] = safe_sparse_dot(X.T, z0) + alpha * w
# Case where we fit the intercept.
if fit_intercept:
grad[-1] = z0.sum()
# The mat-vec product of the Hessian
d = sample_weight * z * (1 - z)
if sparse.issparse(X):
dX = safe_sparse_dot(sparse.dia_matrix((d, 0),
shape=(n_samples, n_samples)), X)
else:
# Precompute as much as possible
dX = d[:, np.newaxis] * X
if fit_intercept:
# Calculate the double derivative with respect to intercept
# In the case of sparse matrices this returns a matrix object.
dd_intercept = np.squeeze(np.array(dX.sum(axis=0)))
def Hs(s):
ret = np.empty_like(s)
ret[:n_features] = X.T.dot(dX.dot(s[:n_features]))
ret[:n_features] += alpha * s[:n_features]
# For the fit intercept case.
if fit_intercept:
ret[:n_features] += s[-1] * dd_intercept
ret[-1] = dd_intercept.dot(s[:n_features])
ret[-1] += d.sum() * s[-1]
return ret
return out, grad, Hs
def logistic_regression_path(X, y, pos_class=None, Cs=10, fit_intercept=True,
max_iter=100, tol=1e-4, verbose=0,
solver='lbfgs', coef=None, copy=True,
class_weight=None, dual=False, penalty='l2',
intercept_scaling=1.):
"""Compute a Logistic Regression model for a list of regularization
parameters.
This is an implementation that uses the result of the previous model
to speed up computations along the set of solutions, making it faster
than sequentially calling LogisticRegression for the different parameters.
Parameters
----------
X : array-like or sparse matrix, shape (n_samples, n_features)
Input data.
y : array-like, shape (n_samples,)
Input data, target values.
Cs : int | array-like, shape (n_cs,)
List of values for the regularization parameter or integer specifying
the number of regularization parameters that should be used. In this
case, the parameters will be chosen in a logarithmic scale between
1e-4 and 1e4.
pos_class : int, None
The class with respect to which we perform a one-vs-all fit.
If None, then it is assumed that the given problem is binary.
fit_intercept : bool
Whether to fit an intercept for the model. In this case the shape of
the returned array is (n_cs, n_features + 1).
max_iter : int
Maximum number of iterations for the solver.
tol : float
Stopping criterion. For the newton-cg and lbfgs solvers, the iteration
will stop when ``max{|g_i | i = 1, ..., n} <= tol``
where ``g_i`` is the i-th component of the gradient.
verbose : int
Print convergence message if True.
solver : {'lbfgs', 'newton-cg', 'liblinear'}
Numerical solver to use.
coef : array-like, shape (n_features,), default None
Initialization value for coefficients of logistic regression.
copy : bool, default True
Whether or not to produce a copy of the data. Setting this to
True will be useful in cases, when logistic_regression_path
is called repeatedly with the same data, as y is modified
along the path.
class_weight : {dict, 'auto'}, optional
Over-/undersamples the samples of each class according to the given
weights. If not given, all classes are supposed to have weight one.
The 'auto' mode selects weights inversely proportional to class
frequencies in the training set.
dual : bool
Dual or primal formulation. Dual formulation is only implemented for
l2 penalty with liblinear solver. Prefer dual=False when
n_samples > n_features.
penalty : str, 'l1' or 'l2'
Used to specify the norm used in the penalization. The newton-cg and
lbfgs solvers support only l2 penalties.
intercept_scaling : float, default 1.
This parameter is useful only when the solver 'liblinear' is used
and self.fit_intercept is set to True. In this case, x becomes
[x, self.intercept_scaling],
i.e. a "synthetic" feature with constant value equals to
intercept_scaling is appended to the instance vector.
The intercept becomes intercept_scaling * synthetic feature weight
Note! the synthetic feature weight is subject to l1/l2 regularization
as all other features.
To lessen the effect of regularization on synthetic feature weight
(and therefore on the intercept) intercept_scaling has to be increased.
Returns
-------
coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1)
List of coefficients for the Logistic Regression model. If
fit_intercept is set to True then the second dimension will be
n_features + 1, where the last item represents the intercept.
Cs : ndarray
Grid of Cs used for cross-validation.
Notes
-----
You might get slighly different results with the solver liblinear than
with the others since this uses LIBLINEAR which penalizes the intercept.
"""
if isinstance(Cs, numbers.Integral):
Cs = np.logspace(-4, 4, Cs)
X = check_array(X, accept_sparse='csc', dtype=np.float64)
y = check_array(y, ensure_2d=False, copy=copy)
check_consistent_length(X, y)
n_classes = np.unique(y)
if pos_class is None:
if (n_classes.size > 2):
raise ValueError('To fit OvA, use the pos_class argument')
# np.unique(y) gives labels in sorted order.
pos_class = n_classes[1]
# If class_weights is a dict (provided by the user), the weights
# are assigned to the original labels. If it is "auto", then
# the class_weights are assigned after masking the labels with a OvA.
sample_weight = np.ones(X.shape[0])
le = LabelEncoder()
if isinstance(class_weight, dict):
if solver == "liblinear":
if n_classes.size == 2:
# Reconstruct the weights with keys 1 and -1
temp = {}
temp[1] = class_weight[pos_class]
temp[-1] = class_weight[n_classes[0]]
class_weight = temp.copy()
else:
raise ValueError("In LogisticRegressionCV the liblinear "
"solver cannot handle multiclass with "
"class_weight of type dict. Use the lbfgs, "
"newton-cg solvers or set "
"class_weight='auto'")
else:
class_weight_ = compute_class_weight(class_weight, n_classes, y)
sample_weight = class_weight_[le.fit_transform(y)]
mask = (y == pos_class)
y[mask] = 1
y[~mask] = -1
# To take care of object dtypes
y = as_float_array(y, copy=False)
if class_weight == "auto":
class_weight_ = compute_class_weight(class_weight, [-1, 1], y)
sample_weight = class_weight_[le.fit_transform(y)]
if fit_intercept:
w0 = np.zeros(X.shape[1] + 1)
else:
w0 = np.zeros(X.shape[1])
if coef is not None:
# it must work both giving the bias term and not
if not coef.size in (X.shape[1], w0.size):
raise ValueError('Initialization coef is not of correct shape')
w0[:coef.size] = coef
coefs = list()
for C in Cs:
if solver == 'lbfgs':
func = _logistic_loss_and_grad
try:
out = optimize.fmin_l_bfgs_b(
func, w0, fprime=None,
args=(X, y, 1. / C, sample_weight),
iprint=(verbose > 0) - 1, pgtol=tol, maxiter=max_iter)
except TypeError:
# old scipy doesn't have maxiter
out = optimize.fmin_l_bfgs_b(
func, w0, fprime=None,
args=(X, y, 1. / C, sample_weight),
iprint=(verbose > 0) - 1, pgtol=tol)
w0 = out[0]
if out[2]["warnflag"] == 1:
warnings.warn("lbfgs failed to converge. Increase the number "
"of iterations.")
elif solver == 'newton-cg':
grad = lambda x, *args: _logistic_loss_and_grad(x, *args)[1]
w0 = newton_cg(_logistic_loss_grad_hess, _logistic_loss, grad, w0,
args=(X, y, 1. / C, sample_weight),
maxiter=max_iter, tol=tol)
elif solver == 'liblinear':
lr = LogisticRegression(C=C, fit_intercept=fit_intercept, tol=tol,
class_weight=class_weight, dual=dual,
penalty=penalty,
intercept_scaling=intercept_scaling)
lr.fit(X, y)
if fit_intercept:
w0 = np.concatenate([lr.coef_.ravel(), lr.intercept_])
else:
w0 = lr.coef_.ravel()
else:
raise ValueError("solver must be one of {'liblinear', 'lbfgs', "
"'newton-cg'}, got '%s' instead" % solver)
coefs.append(w0)
return coefs, np.array(Cs)
# helper function for LogisticCV
def _log_reg_scoring_path(X, y, train, test, pos_class=None, Cs=10,
scoring=None, fit_intercept=False,
max_iter=100, tol=1e-4, class_weight=None,
verbose=0, solver='lbfgs', penalty='l2',
dual=False, copy=True, intercept_scaling=1.):
"""Computes scores across logistic_regression_path
Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training data.
y : array-like, shape (n_samples,) or (n_samples, n_targets)
Target labels.
train : list of indices
The indices of the train set.
test : list of indices
The indices of the test set.
pos_class : int, None
The class with respect to which we perform a one-vs-all fit.
If None, then it is assumed that the given problem is binary.
Cs : list of floats | int
Each of the values in Cs describes the inverse of
regularization strength. If Cs is as an int, then a grid of Cs
values are chosen in a logarithmic scale between 1e-4 and 1e4.
If not provided, then a fixed set of values for Cs are used.
scoring : callable
For a list of scoring functions that can be used, look at
:mod:`sklearn.metrics`. The default scoring option used is
accuracy_score.
fit_intercept : bool
If False, then the bias term is set to zero. Else the last
term of each coef_ gives us the intercept.
max_iter : int
Maximum number of iterations for the solver.
tol : float
Tolerance for stopping criteria.
class_weight : {dict, 'auto'}, optional
Over-/undersamples the samples of each class according to the given
weights. If not given, all classes are supposed to have weight one.
The 'auto' mode selects weights inversely proportional to class
frequencies in the training set.
verbose : int
Amount of verbosity.
solver : {'lbfgs', 'newton-cg', 'liblinear'}
Decides which solver to use.
penalty : str, 'l1' or 'l2'
Used to specify the norm used in the penalization. The newton-cg and
lbfgs solvers support only l2 penalties.
dual : bool
Dual or primal formulation. Dual formulation is only implemented for
l2 penalty with liblinear solver. Prefer dual=False when
n_samples > n_features.
intercept_scaling : float, default 1.
This parameter is useful only when the solver 'liblinear' is used
and self.fit_intercept is set to True. In this case, x becomes
[x, self.intercept_scaling],
i.e. a "synthetic" feature with constant value equals to
intercept_scaling is appended to the instance vector.
The intercept becomes intercept_scaling * synthetic feature weight
Note! the synthetic feature weight is subject to l1/l2 regularization
as all other features.
To lessen the effect of regularization on synthetic feature weight
(and therefore on the intercept) intercept_scaling has to be increased.
Returns
-------
coefs : ndarray, shape (n_cs, n_features) or (n_cs, n_features + 1)
List of coefficients for the Logistic Regression model. If
fit_intercept is set to True then the second dimension will be
n_features + 1, where the last item represents the intercept.
Cs : ndarray
Grid of Cs used for cross-validation.
scores : ndarray, shape (n_cs,)
Scores obtained for each Cs.
"""
log_reg = LogisticRegression(fit_intercept=fit_intercept)
log_reg._enc = LabelEncoder()
log_reg._enc.fit_transform([-1, 1])
X_train = X[train]
X_test = X[test]
y_train = y[train]
y_test = y[test]
if pos_class is not None:
mask = (y_test == pos_class)
y_test[mask] = 1
y_test[~mask] = -1
# To deal with object dtypes, we need to convert into an array of floats.
y_test = as_float_array(y_test, copy=False)
coefs, Cs = logistic_regression_path(X_train, y_train, Cs=Cs,
fit_intercept=fit_intercept,
solver=solver,
max_iter=max_iter,
class_weight=class_weight,
copy=copy, pos_class=pos_class,
tol=tol, verbose=verbose,
dual=dual, penalty=penalty,
intercept_scaling=intercept_scaling)
scores = list()
if isinstance(scoring, six.string_types):
scoring = SCORERS[scoring]
for w in coefs:
if fit_intercept:
log_reg.coef_ = w[np.newaxis, :-1]
log_reg.intercept_ = w[-1]
else:
log_reg.coef_ = w[np.newaxis, :]
log_reg.intercept_ = 0.
if scoring is None:
scores.append(log_reg.score(X_test, y_test))
else:
scores.append(scoring(log_reg, X_test, y_test))
return coefs, Cs, np.array(scores)
class LogisticRegression(BaseLibLinear, LinearClassifierMixin,
_LearntSelectorMixin, SparseCoefMixin):
"""Logistic Regression (aka logit, MaxEnt) classifier.
In the multiclass case, the training algorithm uses a one-vs.-all (OvA)
scheme, rather than the "true" multinomial LR.
This class implements regularized logistic regression using the
`liblinear` library, newton-cg and lbfgs solvers. It can handle both
dense and sparse input. Use C-ordered arrays or CSR matrices containing
64-bit floats for optimal performance; any other input format will be
converted (and copied).
The newton-cg and lbfgs solvers support only L2 regularization with primal
formulation. The liblinear solver supports both L1 and L2 regularization,
with a dual formulation only for the L2 penalty.
Parameters
----------
penalty : str, 'l1' or 'l2'
Used to specify the norm used in the penalization. The newton-cg and
lbfgs solvers support only l2 penalties.
dual : bool
Dual or primal formulation. Dual formulation is only implemented for
l2 penalty with liblinear solver. Prefer dual=False when
n_samples > n_features.
C : float, optional (default=1.0)
Inverse of regularization strength; must be a positive float.
Like in support vector machines, smaller values specify stronger
regularization.
fit_intercept : bool, default: True
Specifies if a constant (a.k.a. bias or intercept) should be
added the decision function.
intercept_scaling : float, default: 1
when self.fit_intercept is True, instance vector x becomes
[x, self.intercept_scaling],
i.e. a "synthetic" feature with constant value equals to
intercept_scaling is appended to the instance vector.
The intercept becomes intercept_scaling * synthetic feature weight
Note! the synthetic feature weight is subject to l1/l2 regularization
as all other features.
To lessen the effect of regularization on synthetic feature weight
(and therefore on the intercept) intercept_scaling has to be increased.
class_weight : {dict, 'auto'}, optional
Over-/undersamples the samples of each class according to the given
weights. If not given, all classes are supposed to have weight one.
The 'auto' mode selects weights inversely proportional to class
frequencies in the training set.
max_iter : int
Useful only for the newton-cg and lbfgs solvers. Maximum number of
iterations taken for the solvers to converge.
random_state : int seed, RandomState instance, or None (default)
The seed of the pseudo random number generator to use when
shuffling the data.
solver : {'newton-cg', 'lbfgs', 'liblinear'}
Algorithm to use in the optimization problem.
tol : float, optional
Tolerance for stopping criteria.
Attributes
----------
coef_ : array, shape (n_classes, n_features)
Coefficient of the features in the decision function.
intercept_ : array, shape (n_classes,)
Intercept (a.k.a. bias) added to the decision function.
If `fit_intercept` is set to False, the intercept is set to zero.
n_iter_ : int
Maximum of the actual number of iterations across all classes.
Valid only for the liblinear solver.
See also
--------
SGDClassifier : incrementally trained logistic regression (when given
the parameter ``loss="log"``).
sklearn.svm.LinearSVC : learns SVM models using the same algorithm.
Notes
-----
The underlying C implementation uses a random number generator to
select features when fitting the model. It is thus not uncommon,
to have slightly different results for the same input data. If
that happens, try with a smaller tol parameter.
References:
LIBLINEAR -- A Library for Large Linear Classification
http://www.csie.ntu.edu.tw/~cjlin/liblinear/
Hsiang-Fu Yu, Fang-Lan Huang, Chih-Jen Lin (2011). Dual coordinate descent
methods for logistic regression and maximum entropy models.
Machine Learning 85(1-2):41-75.
http://www.csie.ntu.edu.tw/~cjlin/papers/maxent_dual.pdf
"""
def __init__(self, penalty='l2', dual=False, tol=1e-4, C=1.0,
fit_intercept=True, intercept_scaling=1, class_weight=None,
random_state=None, solver='liblinear', max_iter=100):
super(LogisticRegression, self).__init__(
penalty=penalty, dual=dual, loss='lr', tol=tol, C=C,
fit_intercept=fit_intercept, intercept_scaling=intercept_scaling,
class_weight=class_weight, random_state=random_state,
solver=solver, max_iter=max_iter)
def predict_proba(self, X):
"""Probability estimates.
The returned estimates for all classes are ordered by the
label of classes.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
Returns the probability of the sample for each class in the model,
where classes are ordered as they are in ``self.classes_``.
"""
return self._predict_proba_lr(X)
def predict_log_proba(self, X):
"""Log of probability estimates.
The returned estimates for all classes are ordered by the
label of classes.
Parameters
----------
X : array-like, shape = [n_samples, n_features]
Returns
-------
T : array-like, shape = [n_samples, n_classes]
Returns the log-probability of the sample for each class in the
model, where classes are ordered as they are in ``self.classes_``.
"""
return np.log(self.predict_proba(X))
class LogisticRegressionCV(LogisticRegression, BaseEstimator,
LinearClassifierMixin, _LearntSelectorMixin):
"""Logistic Regression CV (aka logit, MaxEnt) classifier.
This class implements logistic regression using liblinear, newton-cg or
LBFGS optimizer. The newton-cg and lbfgs solvers support only L2
regularization with primal formulation. The liblinear solver supports both
L1 and L2 regularization, with a dual formulation only for the L2 penalty.
For the grid of Cs values (that are set by default to be ten values in
a logarithmic scale between 1e-4 and 1e4), the best hyperparameter is
selected by the cross-validator StratifiedKFold, but it can be changed
using the cv parameter. In the case of newton-cg and lbfgs solvers,
we warm start along the path i.e guess the initial coefficients of the
present fit to be the coefficients got after convergence in the previous
fit, so in general it is supposed to be faster.
For a multiclass problem, the hyperparameters for each class are computed
using the best scores got by doing a one-vs-rest in parallel across all
folds and classes. Hence this is not the true multinomial loss.
Parameters
----------
Cs : list of floats | int
Each of the values in Cs describes the inverse of regularization
strength. If Cs is as an int, then a grid of Cs values are chosen
in a logarithmic scale between 1e-4 and 1e4.
Like in support vector machines, smaller values specify stronger
regularization.
fit_intercept : bool, default: True
Specifies if a constant (a.k.a. bias or intercept) should be
added the decision function.
class_weight : {dict, 'auto'}, optional
Over-/undersamples the samples of each class according to the given
weights. If not given, all classes are supposed to have weight one.
The 'auto' mode selects weights inversely proportional to class
frequencies in the training set.
cv : integer or cross-validation generator
The default cross-validation generator used is Stratified K-Folds.
If an integer is provided, then it is the number of folds used.
See the module :mod:`sklearn.cross_validation` module for the
list of possible cross-validation objects.
penalty : str, 'l1' or 'l2'
Used to specify the norm used in the penalization. The newton-cg and
lbfgs solvers support only l2 penalties.
dual : bool
Dual or primal formulation. Dual formulation is only implemented for
l2 penalty with liblinear solver. Prefer dual=False when
n_samples > n_features.
scoring : callabale
Scoring function to use as cross-validation criteria. For a list of
scoring functions that can be used, look at :mod:`sklearn.metrics`.
The default scoring option used is accuracy_score.
solver : {'newton-cg', 'lbfgs', 'liblinear'}
Algorithm to use in the optimization problem.
tol : float, optional
Tolerance for stopping criteria.
max_iter : int, optional
Maximum number of iterations of the optimization algorithm.
class_weight : {dict, 'auto'}, optional
Over-/undersamples the samples of each class according to the given
weights. If not given, all classes are supposed to have weight one.
The 'auto' mode selects weights inversely proportional to class
frequencies in the training set.
n_jobs : int, optional
Number of CPU cores used during the cross-validation loop. If given
a value of -1, all cores are used.
verbose : bool | int
Amount of verbosity.
refit : bool
If set to True, the scores are averaged across all folds, and the
coefs and the C that corresponds to the best score is taken, and a
final refit is done using these parameters.
Otherwise the coefs, intercepts and C that correspond to the
best scores across folds are averaged.
intercept_scaling : float, default 1.
This parameter is useful only when the solver 'liblinear' is used
and self.fit_intercept is set to True. In this case, x becomes
[x, self.intercept_scaling],
i.e. a "synthetic" feature with constant value equals to
intercept_scaling is appended to the instance vector.
The intercept becomes intercept_scaling * synthetic feature weight
Note! the synthetic feature weight is subject to l1/l2 regularization
as all other features.
To lessen the effect of regularization on synthetic feature weight
(and therefore on the intercept) intercept_scaling has to be increased.
Attributes
----------
coef_ : array, shape (1, n_features) or (n_classes, n_features)
Coefficient of the features in the decision function.
`coef_` is of shape (1, n_features) when the given problem
is binary.
`coef_` is readonly property derived from `raw_coef_` that
follows the internal memory layout of liblinear.
intercept_ : array, shape (1,) or (n_classes,)
Intercept (a.k.a. bias) added to the decision function.
It is available only when parameter intercept is set to True
and is of shape(1,) when the problem is binary.
Cs_ : array
Array of C i.e. inverse of regularization parameter values used
for cross-validation.
coefs_paths_ : array, shape (n_folds, len(Cs_), n_features) or
(n_folds, len(Cs_), n_features + 1)
dict with classes as the keys, and the path of coefficients obtained
during cross-validating across each fold and then across each Cs
after doing an OvA for the corresponding class.
Each dict value has shape (n_folds, len(Cs_), n_features) or
(n_folds, len(Cs_), n_features + 1) depending on whether the
intercept is fit or not.
scores_ : dict
dict with classes as the keys, and the values as the
grid of scores obtained during cross-validating each fold, after doing
an OvA for the corresponding class.
Each dict value has shape (n_folds, len(Cs))
C_ : array, shape (n_classes,) or (n_classes - 1,)
Array of C that maps to the best scores across every class. If refit is
set to False, then for each class, the best C is the average of the
C's that correspond to the best scores for each fold.
See also
--------
LogisticRegression
"""
def __init__(self, Cs=10, fit_intercept=True, cv=None, dual=False,
penalty='l2', scoring=None, solver='lbfgs', tol=1e-4,
max_iter=100, class_weight=None, n_jobs=1, verbose=False,
refit=True, intercept_scaling=1.):
self.Cs = Cs
self.fit_intercept = fit_intercept
self.cv = cv
self.dual = dual
self.penalty = penalty
self.scoring = scoring
self.tol = tol
self.max_iter = max_iter
self.class_weight = class_weight
self.n_jobs = n_jobs
self.verbose = verbose
self.solver = solver
self.refit = refit
self.intercept_scaling = 1.
def fit(self, X, y):
"""Fit the model according to the given training data.
Parameters
----------
X : {array-like, sparse matrix}, shape (n_samples, n_features)
Training vector, where n_samples in the number of samples and
n_features is the number of features.
y : array-like, shape (n_samples,)
Target vector relative to X.
Returns
-------
self : object
Returns self.
"""
if self.solver != 'liblinear':
if self.penalty != 'l2':
raise ValueError("newton-cg and lbfgs solvers support only "
"l2 penalties.")
if self.dual:
raise ValueError("newton-cg and lbfgs solvers support only "
"the primal form.")
X = check_array(X, accept_sparse='csc', dtype=np.float64)
y = check_array(y, ensure_2d=False)
if y.ndim == 2 and y.shape[1] == 1:
warnings.warn(
"A column-vector y was passed when a 1d array was"
" expected. Please change the shape of y to "
"(n_samples, ), for example using ravel().",
DataConversionWarning
)
y = np.ravel(y)
check_consistent_length(X, y)
# init cross-validation generator
cv = _check_cv(self.cv, X, y, classifier=True)
folds = list(cv)
self._enc = LabelEncoder()
self._enc.fit(y)
labels = self.classes_
n_classes = len(labels)
if n_classes < 2:
raise ValueError("Number of classes have to be greater than one.")
if n_classes == 2:
# OvA in case of binary problems is as good as fitting
# the higher label
n_classes = 1
labels = labels[1:]
if self.class_weight and not(isinstance(self.class_weight, dict) or
self.class_weight == 'auto'):
raise ValueError("class_weight provided should be a "
"dict or 'auto'")
path_func = delayed(_log_reg_scoring_path)
fold_coefs_ = Parallel(n_jobs=self.n_jobs, verbose=self.verbose)(
path_func(X, y, train, test, pos_class=label, Cs=self.Cs,
fit_intercept=self.fit_intercept, penalty=self.penalty,
dual=self.dual, solver=self.solver,
max_iter=self.max_iter, tol=self.tol,
class_weight=self.class_weight,
verbose=max(0, self.verbose - 1),
scoring=self.scoring,
intercept_scaling=self.intercept_scaling)
for label in labels
for train, test in folds)
coefs_paths, Cs, scores = zip(*fold_coefs_)
self.Cs_ = Cs[0]
coefs_paths = np.reshape(coefs_paths, (n_classes, len(folds),
len(self.Cs_), -1))
self.coefs_paths_ = dict(zip(labels, coefs_paths))
scores = np.reshape(scores, (n_classes, len(folds), -1))
self.scores_ = dict(zip(labels, scores))
self.C_ = list()
self.coef_ = list()
self.intercept_ = list()
for label in labels:
scores = self.scores_[label]
coefs_paths = self.coefs_paths_[label]
if self.refit:
best_index = scores.sum(axis=0).argmax()
C_ = self.Cs_[best_index]
self.C_.append(C_)
coef_init = np.mean(coefs_paths[:, best_index, :], axis=0)
w, _ = logistic_regression_path(
X, y, pos_class=label, Cs=[C_], solver=self.solver,
fit_intercept=self.fit_intercept, coef=coef_init,
max_iter=self.max_iter, tol=self.tol,
class_weight=self.class_weight,
verbose=max(0, self.verbose - 1))
w = w[0]
else:
# Take the best scores across every fold and the average of all
# coefficients corresponding to the best scores.
best_indices = np.argmax(scores, axis=1)
w = np.mean([
coefs_paths[i][best_indices[i]]
for i in range(len(folds))
], axis=0)
self.C_.append(np.mean(self.Cs_[best_indices]))
if self.fit_intercept:
self.coef_.append(w[:-1])
self.intercept_.append(w[-1])
else:
self.coef_.append(w)
self.intercept_.append(0.)
self.C_ = np.asarray(self.C_)
self.coef_ = np.asarray(self.coef_)
self.intercept_ = np.asarray(self.intercept_)
return self
| soulmachine/scikit-learn | sklearn/linear_model/logistic.py | Python | bsd-3-clause | 38,054 |
#!/usr/bin/env python
import os
import pywns.TableParser
class ProbeTypeError(Exception):
"""
Raised if not a probe of desired type
"""
pass
class Probe(object):
"""
Base class to read probes from files
"""
valueNames = ["minimum", "maximum", "trials", "mean", "variance", "relativeVariance",
"standardDeviation", "relativeStandardDeviation", "skewness",
"moment2", "moment3"]
def __init__(self, probeType, filename):
"""
Raises an error if file is not available or of desired type
"""
self.filename = filename
self.absFilename = os.path.abspath(self.filename)
self.__items = self.parseFile(self.absFilename)
self.dirname, self.filenameWithoutDir = os.path.split(self.filename)
if self.dirname == "":
self.dirname = "./"
# check if is probe file of desired type
# DISABLED: Does not work during LogEval / Moments / TimeSeries migration
# evaluation = self.getValue("Evaluation")
# if not probeType in evaluation:
# raise ProbeTypeError(str(self) + " tried to read a probe of type: " + probeType)
# This name is the name provided by the probe itself. It may
# be not unique for probe files being kept in a directory
# since it is a matter of configuration ...
self.name = self.getValue("Name")
# This name is built from the filename and therfor unique, at
# least for all probes in one directory
altName, ext = os.path.splitext(self.filenameWithoutDir)
self.altName = altName
self.description = self.getValue("Description")
self.minimum = self.getValue("Minimum")
self.maximum = self.getValue("Maximum")
self.trials = self.getValue("Trials")
self.mean = self.getValue("Mean")
self.variance = self.getValue("Variance")
self.relativeVariance = self.getValue("Relative variance")
self.standardDeviation = self.getValue("Standard deviation")
self.relativeStandardDeviation = self.getValue("Relative standard deviation")
self.skewness = self.getValue("Skewness")
self.moment2 = self.getValue("2nd moment")
self.moment3 = self.getValue("3rd moment")
self.sumOfAllValues = self.getValue("Sum of all values")
self.sumOfAllValuesSquare = self.getValue("(Sum of all values)^2")
self.sumOfAllValuesCubic = self.getValue("(Sum of all values)^3")
def parseFile(fileName):
""" parses self.filename
searches for the pattern: '# key: value', returns a dict with
the found keys and values
"""
items = {}
for line in file(fileName):
# strip spaces and newlines
line = line.strip()
if line.startswith("#"):
if ":" in line:
# strip spaces and "#" at the beginning of the line
line = line.lstrip("# ")
key, value = line.split(":")
# strip spaces and new lines around key and value
key = key.strip()
value = value.strip()
if not items.has_key(key):
items[key] = value
else:
raise Exception("Tried to add '" + key + "' but this was already found.")
else:
# when no "#" is found, we can stop parsing
break
return items
parseFile = staticmethod(parseFile)
def getValue(self, parameter):
""" Try to find the value for 'parameter'
"""
value = self.__items[parameter]
# automatic conversion
# try int, float, string (in this order)
try:
return int(value)
except ValueError:
try:
return float(value)
except ValueError:
return value
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(probeType, probeClass, dirname):
result = {}
for ff in os.listdir(dirname):
filename = os.path.join(dirname, ff)
if os.path.isfile(filename):
if filename.endswith(probeType):
try:
probe = probeClass(filename)
result[probe.filenameWithoutDir] = probe
except ProbeTypeError, e:
pass
return result
readProbes = staticmethod(readProbes)
# Moments probe specific part
class MomentsProbe(Probe):
fileNameSig = "_Moments.dat"
probeType = "Moments"
def __init__(self, filename):
super(MomentsProbe, self).__init__("Moments", filename)
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
return Probe.readProbes(MomentsProbe.fileNameSig, MomentsProbe, dirname)
readProbes = staticmethod(readProbes)
# PDF probe specific part
class PDFHistogramEntry(object):
__slots__ = ["x", "cdf", "ccdf", "pdf"]
def __init__(self, listOfValues):
self.x = float(listOfValues[0])
self.cdf = float(listOfValues[1])
self.ccdf = float(listOfValues[2])
self.pdf = float(listOfValues[3])
class PDFProbe(Probe):
fileNameSig = "_PDF.dat"
valueNames = ["P01","P05","P50","P95","P99","minX", "maxX", "numberOfBins", "underflows", "overflows"] + Probe.valueNames
histogram = None
probeType = "PDF"
def __init__(self, filename):
super(PDFProbe, self).__init__("PDF", filename)
# read Percentiles
self.P01 = self.getValue("P01")
self.P05 = self.getValue("P05")
self.P50 = self.getValue("P50")
self.P95 = self.getValue("P95")
self.P99 = self.getValue("P99")
# These parameters have not been measured but configured ...
self.minX = self.getValue("Left border of x-axis")
self.maxX = self.getValue("Right border of x-axis")
self.numberOfBins = self.getValue("Resolution of x-axis")
self.underflows = self.getValue("Underflows")
self.overflows = self.getValue("Overflows")
self.__histogram = []
self.__histogramRead = False
def __getHistogram(self):
if self.__histogramRead == False:
self.__histogram = []
for line in file(self.absFilename):
if not line.startswith('#'):
self.__histogram.append(PDFHistogramEntry(line.split()))
self.__histogramRead = True
return self.__histogram
histogram = property(__getHistogram)
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
return Probe.readProbes(PDFProbe.fileNameSig, PDFProbe, dirname)
readProbes = staticmethod(readProbes)
def __getPureHistogram(self):
# actually there is one bin more than stated in numberOfBins
if len(self.histogram) == self.numberOfBins + 3:
# underflows and overflows
return self.histogram[1:self.numberOfBins + 1]
elif len(self.histogram) == self.numberOfBins + 2:
# underflows or overflows
if self.overflows > 0:
# overflows
return self.histogram[:self.numberOfBins + 1]
elif self.underflows > 0:
# underflows
return self.histogram[1:self.numberOfBins + 2]
else:
raise "Did not expect to reach this line"
else:
# everything was fine already
return self.histogram
pureHistogram = property(__getPureHistogram)
class TimeSeriesProbe(object):
fileNameSig = "_TimeSeries.dat"
valueNames = []
filename = None
filenameWithoutDir = None
name = None
entries = None
probeType = "TimeSeries"
def __init__(self, filename):
self.filename = filename
self.dirname, self.filenameWithoutDir = os.path.split(self.filename)
if self.dirname == "":
self.dirname = "./"
# Parse the file
items = Probe.parseFile(self.filename)
self.altName = self.filenameWithoutDir.rsplit('_', 1)[0]
self.name = items["Name"]
self.description = items["Description"]
self.entries = []
for line in file(self.filename):
if not line.startswith('#'):
self.entries.append(LogEvalEntry(line.split()))
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
result = Probe.readProbes(TimeSeriesProbe.fileNameSig, TimeSeriesProbe, dirname)
return result
readProbes = staticmethod(readProbes)
# LogEval probe specific part
class LogEvalEntry(object):
__slots__ = ["x", "y"]
def __init__(self, listOfValues):
self.x = float(listOfValues[0])
self.y = float(listOfValues[1])
class LogEvalProbe(Probe):
fileNameSig = "_Log.dat"
valueNames = Probe.valueNames
entries = None
readAllValues = True
filenameEntries = None
probeType = "LogEval"
def __init__(self, filename):
super(LogEvalProbe, self).__init__("LogEval", filename)
splitFilename = filename.split(".")
splitFilename[-2] += ".log"
self.filenameEntries = str(".").join(splitFilename)
# In the renovated LogEval Probe, the header and the data are in one and the same file
# TODO: fileNameEntries can be removed when PDataBase/SortingCriterion are abandoned
if not os.path.exists(self.filenameEntries):
self.filenameEntries = filename
self.__entries = []
self.__entriesRead = False
def __getEntries(self):
if not self.readAllValues:
return []
if self.__entriesRead == False:
self.__entries = []
for line in file(self.filenameEntries):
if not line.startswith('#'):
self.__entries.append(LogEvalEntry(line.split()))
self.__entriesRead = True
return self.__entries
entries = property(__getEntries)
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
return Probe.readProbes(LogEvalProbe.fileNameSig, LogEvalProbe, dirname)
readProbes = staticmethod(readProbes)
class BatchMeansHistogramEntry:
def __init__(self, listOfValues):
self.x = float(listOfValues[1])
self.cdf = float(listOfValues[0])
self.pdf = float(listOfValues[3])
self.relativeError = float(listOfValues[2])
self.confidence = float(listOfValues[4])
if len(listOfValues) > 5:
self.numberOfTrialsPerInterval = int(listOfValues[5])
else:
self.numberOfTrialsPerInterval = 0
class BatchMeansProbe(Probe):
fileNameSig = "_BaM.dat"
valueNames = ["lowerBorder", "upperBorder", "numberOfIntervals", "intervalSize",
"sizeOfGroups", "maximumRelativeError", "evaluatedGroups", "underflows",
"overflows", "meanBm", "confidenceOfMeanAbsolute", "confidenceOfMeanPercent",
"relativeErrorMean", "varianceBm", "confidenceOfVarianceAbsolute", "confidenceOfVariancePercent",
"relativeErrorVariance", "sigma", "firstOrderCorrelationCoefficient"] + Probe.valueNames
histogram = None
probeType = "BatchMeans"
def __init__(self, filename):
super(BatchMeansProbe, self).__init__("BatchMeans", filename)
self.lowerBorder = self.getValue("lower border")
self.upperBorder = self.getValue("upper border")
self.numberOfIntervals = self.getValue("number of intervals")
self.intervalSize = self.getValue("interval size")
self.sizeOfGroups = self.getValue("size of groups")
self.maximumRelativeError = self.getValue("maximum relative error [%]")
self.evaluatedGroups = self.getValue("evaluated groups")
self.underflows = self.getValue("Underflows")
self.overflows = self.getValue("Overflows")
self.meanBm = self.getValue("mean (BM version)")
self.confidenceOfMeanAbsolute = self.getValue("confidence of mean absolute [+-]")
self.confidenceOfMeanPercent = self.getValue("confidence of mean [%]")
self.relativeErrorMean = self.getValue("relative error (Bayes Error)")
self.varianceBm = self.getValue("variance (BM version)")
self.confidenceOfVarianceAbsolute = self.getValue("confidence of variance absolute [+-]")
self.confidenceOfVariancePercent = self.getValue("confidence of variance [%]")
self.relativeErrorVariance = self.getValue("relative error")
self.sigma = self.getValue("sigma")
self.firstOrderCorrelationCoefficient = self.getValue("1st order correlation coefficient")
# read x, CDF, PDF, relative error, confidence, number of trials
self.histogram = []
for line in file(self.absFilename):
if not line.startswith("#"):
self.histogram.append(BatchMeansHistogramEntry(line.split()))
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
return Probe.readProbes(BatchMeansProbe.fileNameSig, BatchMeansProbe, dirname)
readProbes = staticmethod(readProbes)
class LreHistogramEntry(object):
def __init__(self, listOfValues):
self.ordinate = float(listOfValues[0])
self.abscissa = float(listOfValues[1])
if listOfValues[2] == 'not_available':
self.relativeError = float('nan')
else:
self.relativeError = float(listOfValues[2])
if listOfValues[3] == 'not_available':
self.meanLocalCorrelationCoefficient = float('nan')
else:
self.meanLocalCorrelationCoefficient = float(listOfValues[3])
if listOfValues[4] == 'not_available':
self.deviationFromMeanLocalCC = float('nan')
else:
self.deviationFromMeanLocalCC = float(listOfValues[4])
self.numberOfTrialsPerInterval = int(listOfValues[5])
if listOfValues[6] == 'not_available':
self.numberOfTransitionsPerInterval = float('nan')
else:
self.numberOfTransitionsPerInterval = int(listOfValues[6])
self.relativeErrorWithinLimit = listOfValues[7]
class LreProbe(Probe):
fileNameSigs = ["_LREF.dat",
"_LREF_pf.dat",
"_LREG.dat",
"_LREG_pf.dat"]
valueNames = ["lreType", "maximumRelativeError", "fMax", "fMin", "scaling",
"maximumNumberOfTrialsPerLevel", "rhoN60", "rhoN50",
"rhoN40", "rhoN30", "rhoN20", "rhoN10", "rho00",
"rhoP25", "rhoP50", "rhoP75", "rhoP90", "rhoP95", "rhoP99",
"peakNumberOfSortingElements", "resultIndexOfCurrentLevel", "numberOfLevels",
"relativeErrorMean", "relativeErrorVariance", "relativeErrorStandardDeviation",
"meanLocalCorrelationCoefficientMean", "meanLocalCorrelationCoefficientVariance",
"meanLocalCorrelationCoefficientStandardDeviation", "numberOfTrialsPerIntervalMean",
"numberOfTrialsPerIntervalVariance", "numberOfTrialsPerIntervalStandardDeviation",
"numberOfTransitionsPerIntervalMean", "numberOfTransitionsPerIntervalVariance",
"numberOfTransitionsPerIntervalStandardDeviation"] + Probe.valueNames
histogram = None
probeType = "LRE"
def __init__(self, filename):
super(LreProbe, self).__init__("LRE", filename)
self.lreType = self.getValue("Evaluation")
self.maximumRelativeError = self.getValue("Maximum relative error [%]")
self.fMax = self.getValue("F max")
self.fMin = self.getValue("F min")
self.scaling = self.getValue("Scaling")
self.maximumNumberOfTrialsPerLevel = self.getValue("Maximum number of trials per level")
self.rhoN60 = self.getValue("correlated (rho = -0.60)")
self.rhoN50 = self.getValue("correlated (rho = -0.50)")
self.rhoN40 = self.getValue("correlated (rho = -0.40)")
self.rhoN30 = self.getValue("correlated (rho = -0.30)")
self.rhoN20 = self.getValue("correlated (rho = -0.20)")
self.rhoN10 = self.getValue("correlated (rho = -0.10)")
self.rho00 = self.getValue("uncorrelated (rho = 0.00)")
self.rhoP25 = self.getValue("correlated (rho = +0.25)")
self.rhoP50 = self.getValue("correlated (rho = +0.50)")
self.rhoP75 = self.getValue("correlated (rho = +0.75)")
self.rhoP90 = self.getValue("correlated (rho = +0.90)")
self.rhoP95 = self.getValue("correlated (rho = +0.95)")
self.rhoP99 = self.getValue("correlated (rho = +0.99)")
self.peakNumberOfSortingElements = self.getValue("Peak number of sorting mem. elems.")
self.resultIndexOfCurrentLevel = self.getValue("Result memory index of current level")
self.numberOfLevels = self.getValue("Number of levels")
self.relativeErrorMean = self.getValue("Relative error (Mean)")
self.relativeErrorVariance = self.getValue("Relative error (Variance)")
self.relativeErrorStandardDeviation = self.getValue("Relative error (Standard deviation)")
self.meanLocalCorrelationCoefficientMean = self.getValue("Mean local correlation coefficient (Mean)")
self.meanLocalCorrelationCoefficientVariance = self.getValue("Mean local correlation coefficient (Variance)")
self.meanLocalCorrelationCoefficientStandardDeviation = self.getValue("Mean local correlation coefficient (Standard deviation)")
self.deviationFromMeanLocalCCMean = self.getValue("Deviation from mean local c.c.(Mean)")
self.deviationFromMeanLocalCCVariance = self.getValue("Deviation from mean local c.c.(Variance)")
self.deviationFromMeanLocalCCStandardDeviation = self.getValue("Deviation from mean local c.c.(Standard deviation)")
self.numberOfTrialsPerIntervalMean = self.getValue("Number of trials per interval (Mean)")
self.numberOfTrialsPerIntervalVariance = self.getValue("Number of trials per interval (Variance)")
self.numberOfTrialsPerIntervalStandardDeviation = self.getValue("Number of trials per interval (Standard deviation)")
self.numberOfTransitionsPerIntervalMean = self.getValue("Number of transitions per interval (Mean)")
self.numberOfTransitionsPerIntervalVariance = self.getValue("Number of transitions per interval (Variance)")
self.numberOfTransitionsPerIntervalStandardDeviation = self.getValue("Number of transitions per interval (Standard deviation)")
self.histogram = []
for line in file(self.absFilename):
if not line.startswith("#"):
self.histogram.append(LreHistogramEntry(line.split()))
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
result = {}
for suffix in LreProbe.fileNameSigs:
result.update(Probe.readProbes(suffix, LreProbe, dirname))
return result
readProbes = staticmethod(readProbes)
class DlreHistogramEntry(LreHistogramEntry):
def __init__(self, listOfValues):
super(DlreHistogramEntry, self).__init__(listOfValues)
class DlreProbe(Probe):
fileNameSigs = ["_DLREF.dat",
"_DLREG.dat",
"_DLREP.dat"]
valueNames = ["lreType", "lowerBorder", "upperBorder", "numberOfIntervals",
"intervalSize", "maximumNumberOfSamples", "maximumRelativeErrorPercent",
"evaluatedLevels", "underflows", "overflows"] + Probe.valueNames
histogram = None
probeType = "DLRE"
def __init__(self, filename):
super(DlreProbe, self).__init__("DLRE", filename)
self.dlreType = self.getValue("Evaluation")
self.lowerBorder = self.getValue("lower border")
self.upperBorder = self.getValue("upper border")
self.numberOfIntervals = self.getValue("number of intervals")
self.intervalSize = self.getValue("interval size")
self.maximumNumberOfSamples = self.getValue("maximum number of samples")
self.maximumRelativeErrorPercent = self.getValue("maximum relative error [%]")
self.evaluatedLevels = self.getValue("evaluated levels")
self.underflows = self.getValue("Underflows")
self.overflows = self.getValue("Overflows")
self.histogram = []
for line in file(self.absFilename):
if not line.startswith("#"):
self.histogram.append(DlreHistogramEntry(line.split()))
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
result = {}
for suffix in DlreProbe.fileNameSigs:
result.update(Probe.readProbes(suffix, DlreProbe, dirname))
return result
readProbes = staticmethod(readProbes)
class TableProbe:
fileNameSigs = ['_mean.dat',
'_max.dat',
'_min.dat',
'_trials.dat',
'_var.dat',
] # there are more than these, but these are the most commonly used ones.
valueNames = ["minimum", "maximum"]
tableParser = None
filename = None
filenameWithoutDir = None
name = None
probeType = "Table"
def __init__(self, filename):
self.filename = filename
self.dirname, self.filenameWithoutDir = os.path.split(self.filename)
if self.dirname == "":
self.dirname = "./"
self.name = self.filenameWithoutDir.rsplit('_', 1)[0]
self.type = self.filenameWithoutDir.rsplit('_', 1)[1]
self.tableParser = pywns.TableParser.TableParser(filename)
self.description = self.tableParser.getDescription()
self.minimum = self.tableParser.minimum
self.maximum = self.tableParser.maximum
self.trials = self.tableParser.trials
self.mean = "-"
self.variance = "-"
self.relativeVariance = "-"
self.standardDeviation = "-"
self.relativeStandardDeviation = "-"
self.skewness = "-"
self.moment2 = "-"
self.moment3 = "-"
# @staticmethod (this syntax works only for python >= 2.4)
def readProbes(dirname):
result = {}
for suffix in TableProbe.fileNameSigs:
result.update(Probe.readProbes(suffix, TableProbe, dirname))
return result
readProbes = staticmethod(readProbes)
def readAllProbes(dirname):
result = {}
result = PDFProbe.readProbes(dirname)
result.update(LogEvalProbe.readProbes(dirname))
result.update(TimeSeriesProbe.readProbes(dirname))
result.update(MomentsProbe.readProbes(dirname))
result.update(TableProbe.readProbes(dirname))
# @todo: update result dict with table probes when simcontrol can handle them
return result
def getProbeType(filename):
"""This function identifies and returns the type of a probe file"""
for probeType in [ MomentsProbe, PDFProbe, LogEvalProbe, TimeSeriesProbe ]:
if probeType.fileNameSig in filename:
return probeType
for tableSuffix in TableProbe.fileNameSigs:
if tableSuffix in filename:
return TableProbe
# if nothing was found
raise TypeError("Could not identify probe type from filename: "+fileName)
| openwns/pywns | pywns/Probe.py | Python | gpl-2.0 | 25,493 |
# -*- coding:utf-8 -*-
#!/usr/bin/env python
# Import all the things!
import sys
import os
try:
import argparse
except:
print '[!] argparse is not installed. Try "pip install argparse"'
sys.exit(0)
try:
from urllib import urlopen
from urllib import urlretrieve
from urllib import urlencode
except:
print '[!] urllib is not installed. Try "pip install urllib"'
sys.exit(0)
try:
from bs4 import BeautifulSoup
except:
print '[!] BeautifulSoup is not installed. Try "pip install beautifulsoup4"'
sys.exit(0)
try:
import re
except:
print '[!] re is not installed. Try "pip install re"'
sys.exit(0)
try:
import pycurl
except:
print '[!] pycurl is not installed. Try "pip install pycurl"'
sys.exit(0)
# Display Startup Banner
def banner():
print ""
print " _____ _ _ _ _ _"
print " / ____(_) | | | | | | |"
print "| | __ _| |_ | |__| | __ _ _ ____ _____ ___| |_ ___ _ __ "
print "| | |_ | | __| | __ |/ _` | '__\ \ / / _ \/ __| __/ _ \ '__|"
print "| |__| | | |_ | | | | (_| | | \ V / __/\__ \ || __/ | "
print " \_____|_|\__| |_| |_|\__,_|_| \_/ \___||___/\__\___|_| "
print ""
print "Version 0.7.2"
print "By: @metacortex of @dc801"
print ""
# Parse GitHub search results
def githubsearch(search, regex, order, sort):
navbarlinks = []
githubbase = 'https://github.com/search?'
githubsearchurl = {'o' : order, 'q' : search, 's' : sort, 'type' : 'Code', 'ref' : 'searchresults'}
searchurl = githubbase + str(urlencode(githubsearchurl))
if (order == 'asc'):
print '[+] Searching Github for ' + search + ' and ordering by OLDEST'
print searchurl
elif (order == 'desc'):
print '[+] Searching Github for ' + search + ' and ordering by NEWEST'
print searchurl
else:
print '[+] Searching Github for ' + search + ' and ordering by BEST MATCH'
print searchurl
searchresults = urlopen(searchurl).read()
soup = BeautifulSoup(searchresults, 'html.parser')
# Find the bottom nav bar and parse out those links
pagenav = soup.findAll('div', attrs={'class':'pagination'});
for page in pagenav:
pages = page.findAll('a')
for a in pages:
navbarlinks.append(a)
try:
totalpages = int(str(re.findall(r">.*</a>", str(navbarlinks[-2]))).strip('[').strip(']').strip('\'').strip('>').strip('</a>')) # Because I suck at code
except IndexError:
print ' [!] Search error'
sys.exit(0)
print ' [+] Returned ' + str(totalpages) + ' total pages'
# Parse each page of results
currentpage = 1
while (currentpage <= totalpages):
parseresultpage(currentpage, search, order, sort, regex)
currentpage += 1
def parseresultpage(page, search, order, sort, regex):
print ' [+] Pulling results from page ' + str(page)
githubbase = 'https://github.com/search?'
githubsearchurl = {'o' : order, 'p' : page, 'q' : search, 's' : sort, 'type' : 'Code', 'ref' : 'searchresults'}
searchurl = githubbase + str(urlencode(githubsearchurl))
pagehtml = urlopen(searchurl).read()
soup = BeautifulSoup(pagehtml, 'html.parser')
# Find GitHub div with code results
results = soup.findAll('div', attrs={'class':'code-list-item'})
# Pull url's from results and hit each of them
soup1 = BeautifulSoup(str(results), 'html.parser')
for item in soup1.findAll('p', attrs={'class':'title'}):
soup2 = BeautifulSoup(str(item), 'html.parser')
individualresult = soup2.findAll('a')[1]
individualresulturl = 'https://github.com/' + str(individualresult['href'])
individualresultpage = urlopen(individualresulturl).read()
soup3 = BeautifulSoup(str(individualresultpage), 'html.parser')
for rawlink in soup3.findAll('a', attrs={'id':'raw-url'}):
rawurl = 'https://github.com' + str(rawlink['href'])
if (args.custom_regex):
searchcode(rawurl, regex)
else:
wpsearchcode(rawurl, regex)
def searchcode(url, regex):
code = urlopen(url).read()
result = ''
try:
regexresults = re.search(regex, str(code))
result = str(regexresults.group(0))
if result is not None:
if (args.url == True):
print " " + str(url)
if (args.verbose == True):
print " [+] Found the following results"
print " " + str(result)
if args.write_file:
if (result == ''):
pass
else:
f = open(args.write_file, 'a')
f.write(str(result + '\n'))
f.close()
if args.directory:
filename = args.directory + "/" + url.replace('/', '-')
if not os.path.exists(args.directory):
os.makedirs(args.directory)
print " [+] Downloading " + filename
urlretrieve(url, filename)
fp = open(filename, 'wb')
fp.write(code)
fp.close()
else:
pass
except:
pass
#This whole function is confusing as hell FYI
def wpsearchcode(url, regex):
code = urlopen(url).read()
try:
regexdb = re.search(r"define\(\'DB_NAME.*;", str(code), re.IGNORECASE)
regexuser = re.search(r"define\(\'DB_USER.*;", str(code), re.IGNORECASE)
regexpass = re.search(r"define\(\'DB_PASSWORD.*;", str(code), re.IGNORECASE)
regexhost = re.search(r"define\(\'DB_HOST.*;", str(code), re.IGNORECASE)
db = str(regexdb.group(0)).strip('define(\'').strip('\');').replace('\', \'', ':').strip('DB_NAME:')
user = str(regexuser.group(0)).strip('define(\'').strip('\');').replace('\', \'', ':').strip('DB_USER:')
password = str(regexpass.group(0)).strip('define(\'').strip('\');').replace('\', \'', ':').strip('DB_PASSWORD:')
host = str(regexhost.group(0)).strip('define(\'').strip('\');').replace('\', \'', ':').strip('DB_HOST:')
if (db == '\', '): # Check for blank database because...shitty code
db = ''
if (user == '\', '): # Check for blank user because...shitty code
user = ''
if (password == '\', '): # Check for blank password because...shitty code
password = ''
if (host == '\', '): # Check for blank host because...shitty code
host = ''
if (args.verbose == True):
print ' [+] Found the following credentials'
if (args.url == True):
print ' ' + str(url)
print ' database: ' + db
print ' user: ' + user
print ' password: ' + password
print ' host: ' + host
if args.write_file:
f = open(args.write_file, 'a')
results = 'Database: ' + db + '\nUser: ' + user + '\nPassword: ' + password + '\nHost: ' + host + '\n---\n'
f.write(results)
f.close()
except:
pass
def main():
banner() # Brandwhore
# Parsing arguments
parser = argparse.ArgumentParser(description='This tool is used for harvesting information from GitHub. By default it looks for code with the filename of \'wp-config.php\' and pulls out auth info')
parser.add_argument('-d', action='store', dest='directory', help='Download results to a specific directory', type=str)
parser.add_argument('-o', action='store', dest='organize', help='Organize results by \'new\', \'old\', \'best\', or \'all\'', type=str)
parser.add_argument('-r', action='store', dest='custom_regex', help='Custom regex string', type=str)
parser.add_argument('-s', action='store', dest='custom_search', help='Custom GitHub search string', type=str)
parser.add_argument('-u', '--url', action='store_true', help='Output URL of found object')
parser.add_argument('-v', '--verbose', action='store_true', help='Turn verbose output on. This will output matched lines')
parser.add_argument('-w', action='store', dest='write_file', help='Write results to a file', type=str)
global args
args = parser.parse_args()
if not len(sys.argv) > 1:
args.verbose = True
if args.custom_search:
search = args.custom_search
print '[+] Custom search is: ' + str(search)
else:
search = 'filename:wp-config.php'
print '[+] Using default search'
if args.custom_regex:
regex = args.custom_regex
print '[+] Custom regex is: ' + str(regex)
else:
regex = 'regexhere'
print '[+] Using default regex'
if (args.organize == 'new'):
githubsearch(search, regex, 'desc', 'indexed')
elif (args.organize == 'old'):
githubsearch(search, regex, 'asc', 'indexed')
elif (args.organize == 'best'):
githubsearch(search, regex, '', '')
elif (args.organize == 'all'):
githubsearch(search, regex, '', '')
githubsearch(search, regex, 'desc', 'indexed')
githubsearch(search, regex, 'asc', 'indexed')
else:
githubsearch(search, regex, '', '')
print '[+] DONE'
try:
if __name__ == "__main__":
main()
except KeyboardInterrupt:
print "[!] Keyboard Interrupt. Shutting down"
| hxer/Scripts | GitHarvester/githarvester.py | Python | gpl-2.0 | 8,757 |
# -*- 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.
#
# Generated code. DO NOT EDIT!
#
# Snippet for GetFlowValidationResult
# 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-dialogflowcx
# [START dialogflow_v3_generated_Flows_GetFlowValidationResult_async]
from google.cloud import dialogflowcx_v3
async def sample_get_flow_validation_result():
# Create a client
client = dialogflowcx_v3.FlowsAsyncClient()
# Initialize request argument(s)
request = dialogflowcx_v3.GetFlowValidationResultRequest(
name="name_value",
)
# Make the request
response = await client.get_flow_validation_result(request=request)
# Handle the response
print(response)
# [END dialogflow_v3_generated_Flows_GetFlowValidationResult_async]
| googleapis/python-dialogflow-cx | samples/generated_samples/dialogflow_v3_generated_flows_get_flow_validation_result_async.py | Python | apache-2.0 | 1,525 |
"""
jobber.conf
~~~~~~~~~~~
Exposes a `_Settings_` instance with applied overrides from local.py.
"""
from jobber.conf import default as default_settings
try:
from jobber.conf import local as local_settings
except ImportError:
local_settings = None
def _make_dict(module):
"""Transforms a module into a `dict` containing all the names that the
module defines.
"""
if not module:
return {}
return {name: getattr(module, name) for name in dir(module)}
_default = _make_dict(default_settings)
_local = _make_dict(local_settings)
class _Settings(object):
"""Placeholder class for settings."""
def __init__(self, *args):
for setting in args:
if setting: self.apply(setting)
def apply(self, settings):
for key, value in settings.iteritems():
if key == key.upper():
setattr(self, key, value)
# Expose a global `settings` property.
settings = _Settings(_default, _local)
| hackcyprus/jobber | jobber/conf/__init__.py | Python | mit | 980 |
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import annotations
import hashlib
import json
from dataclasses import dataclass
from enum import Enum
from typing import Any, Callable, Iterable, Set, TypeVar
from pkg_resources import Requirement
from pants.backend.python.util_rules.interpreter_constraints import InterpreterConstraints
from pants.util.ordered_set import FrozenOrderedSet
BEGIN_LOCKFILE_HEADER = b"# --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---"
END_LOCKFILE_HEADER = b"# --- END PANTS LOCKFILE METADATA ---"
_concrete_metadata_classes: dict[int, type[LockfileMetadata]] = {}
def _lockfile_metadata_version(
version: int,
) -> Callable[[type[LockfileMetadata]], type[LockfileMetadata]]:
"""Decorator to register a Lockfile metadata version subclass with a given version number.
The class must be a frozen dataclass
"""
def _dec(cls: type[LockfileMetadata]) -> type[LockfileMetadata]:
# Only frozen dataclasses may be registered as lockfile metadata:
cls_dataclass_params = getattr(cls, "__dataclass_params__", None)
if not cls_dataclass_params or not cls_dataclass_params.frozen:
raise ValueError(
"Classes registered with `_lockfile_metadata_version` may only be "
"frozen dataclasses"
)
_concrete_metadata_classes[version] = cls
return cls
return _dec
class InvalidLockfileError(Exception):
pass
@dataclass(frozen=True)
class LockfileMetadata:
"""Base class for metadata that is attached to a given lockfiles.
This class, and provides the external API for serializing, deserializing, and validating the
contents of individual lockfiles. New versions of metadata implement a concrete subclass and
provide deserialization and validation logic, along with specialist serialization logic.
To construct an instance of the most recent concrete subclass, call `LockfileMetadata.new()`.
"""
_LockfileMetadataSubclass = TypeVar("_LockfileMetadataSubclass", bound="LockfileMetadata")
valid_for_interpreter_constraints: InterpreterConstraints
@staticmethod
def new(
valid_for_interpreter_constraints: InterpreterConstraints,
requirements: set[Requirement],
) -> LockfileMetadata:
"""Call the most recent version of the `LockfileMetadata` class to construct a concrete
instance.
This static method should be used in place of the `LockfileMetadata` constructor. This gives
calling sites a predictable method to call to construct a new `LockfileMetadata` for
writing, while still allowing us to support _reading_ older, deprecated metadata versions.
"""
return LockfileMetadataV2(valid_for_interpreter_constraints, requirements)
@staticmethod
def from_lockfile(
lockfile: bytes, lockfile_path: str | None = None, resolve_name: str | None = None
) -> LockfileMetadata:
"""Parse all relevant metadata from the lockfile's header."""
in_metadata_block = False
metadata_lines = []
for line in lockfile.splitlines():
if line == BEGIN_LOCKFILE_HEADER:
in_metadata_block = True
elif line == END_LOCKFILE_HEADER:
break
elif in_metadata_block:
metadata_lines.append(line[2:])
error_suffix = (
"To resolve this error, you will need to regenerate the lockfile by running "
"`./pants generate-lockfiles"
)
if resolve_name:
error_suffix += " --resolve={tool_name}"
error_suffix += "`."
if lockfile_path is not None and resolve_name is not None:
lockfile_description = f"the lockfile `{lockfile_path}` for `{resolve_name}`"
elif lockfile_path is not None:
lockfile_description = f"the lockfile `{lockfile_path}`"
elif resolve_name is not None:
lockfile_description = f"the lockfile for `{resolve_name}`"
else:
lockfile_description = "this lockfile"
if not metadata_lines:
raise InvalidLockfileError(
f"Could not find a Pants metadata block in {lockfile_description}. {error_suffix}"
)
try:
metadata = json.loads(b"\n".join(metadata_lines))
except json.decoder.JSONDecodeError:
raise InvalidLockfileError(
f"Metadata header in {lockfile_description} is not a valid JSON string and can't "
"be decoded. " + error_suffix
)
concrete_class = _concrete_metadata_classes[metadata["version"]]
return concrete_class._from_json_dict(metadata, lockfile_description, error_suffix)
@classmethod
def _from_json_dict(
cls: type[_LockfileMetadataSubclass],
json_dict: dict[Any, Any],
lockfile_description: str,
error_suffix: str,
) -> _LockfileMetadataSubclass:
"""Construct a `LockfileMetadata` subclass from the supplied JSON dict.
*** Not implemented. Subclasses should override. ***
`lockfile_description` is a detailed, human-readable description of the lockfile, which can
be read by the user to figure out which lockfile is broken in case of an error.
`error_suffix` is a string describing how to fix the lockfile.
"""
raise NotImplementedError(
"`LockfileMetadata._from_json_dict` should not be directly " "called."
)
def add_header_to_lockfile(self, lockfile: bytes, *, regenerate_command: str) -> bytes:
metadata_dict = self._header_dict()
metadata_json = json.dumps(metadata_dict, ensure_ascii=True, indent=2).splitlines()
metadata_as_a_comment = "\n".join(f"# {l}" for l in metadata_json).encode("ascii")
header = b"%b\n%b\n%b" % (BEGIN_LOCKFILE_HEADER, metadata_as_a_comment, END_LOCKFILE_HEADER)
regenerate_command_bytes = (
f"# This lockfile was autogenerated by Pants. To regenerate, run:\n#\n"
f"# {regenerate_command}"
).encode()
return b"%b\n#\n%b\n\n%b" % (regenerate_command_bytes, header, lockfile)
def _header_dict(self) -> dict[Any, Any]:
"""Produce a dictionary to be serialized into the lockfile header.
Subclasses should call `super` and update the resulting dictionary.
"""
version: int
for ver, cls in _concrete_metadata_classes.items():
if isinstance(self, cls):
version = ver
break
else:
raise ValueError("Trying to serialize an unregistered `LockfileMetadata` subclass.")
return {
"version": version,
"valid_for_interpreter_constraints": [
str(ic) for ic in self.valid_for_interpreter_constraints
],
}
def is_valid_for(
self,
expected_invalidation_digest: str | None,
user_interpreter_constraints: InterpreterConstraints,
interpreter_universe: Iterable[str],
user_requirements: Iterable[Requirement] | None,
) -> LockfileMetadataValidation:
"""Returns Truthy if this `LockfileMetadata` can be used in the current execution
context."""
raise NotImplementedError("call `is_valid_for` on subclasses only")
@_lockfile_metadata_version(1)
@dataclass(frozen=True)
class LockfileMetadataV1(LockfileMetadata):
requirements_invalidation_digest: str
@classmethod
def _from_json_dict(
cls: type[LockfileMetadataV1],
json_dict: dict[Any, Any],
lockfile_description: str,
error_suffix: str,
) -> LockfileMetadataV1:
metadata = _get_metadata(json_dict, lockfile_description, error_suffix)
interpreter_constraints = metadata(
"valid_for_interpreter_constraints", InterpreterConstraints, InterpreterConstraints
)
requirements_digest = metadata("requirements_invalidation_digest", str, None)
return LockfileMetadataV1(interpreter_constraints, requirements_digest)
def _header_dict(self) -> dict[Any, Any]:
d = super()._header_dict()
d["requirements_invalidation_digest"] = self.requirements_invalidation_digest
return d
def is_valid_for(
self,
expected_invalidation_digest: str | None,
user_interpreter_constraints: InterpreterConstraints,
interpreter_universe: Iterable[str],
_: Iterable[Requirement] | None, # User requirements are not used by V1
) -> LockfileMetadataValidation:
failure_reasons: set[InvalidLockfileReason] = set()
if expected_invalidation_digest is None:
return LockfileMetadataValidation(failure_reasons)
if self.requirements_invalidation_digest != expected_invalidation_digest:
failure_reasons.add(InvalidLockfileReason.INVALIDATION_DIGEST_MISMATCH)
if not self.valid_for_interpreter_constraints.contains(
user_interpreter_constraints, interpreter_universe
):
failure_reasons.add(InvalidLockfileReason.INTERPRETER_CONSTRAINTS_MISMATCH)
return LockfileMetadataValidation(failure_reasons)
@_lockfile_metadata_version(2)
@dataclass(frozen=True)
class LockfileMetadataV2(LockfileMetadata):
"""Lockfile version that permits specifying a requirements as a set rather than a digest.
Validity is tested by the set of requirements strings being the same in the user requirements as
those in the stored requirements.
"""
requirements: set[Requirement]
@classmethod
def _from_json_dict(
cls: type[LockfileMetadataV2],
json_dict: dict[Any, Any],
lockfile_description: str,
error_suffix: str,
) -> LockfileMetadataV2:
metadata = _get_metadata(json_dict, lockfile_description, error_suffix)
requirements = metadata(
"generated_with_requirements",
Set[Requirement],
lambda l: {Requirement.parse(i) for i in l},
)
interpreter_constraints = metadata(
"valid_for_interpreter_constraints", InterpreterConstraints, InterpreterConstraints
)
return LockfileMetadataV2(interpreter_constraints, requirements)
def _header_dict(self) -> dict[Any, Any]:
out = super()._header_dict()
# Requirements need to be stringified then sorted so that tests are deterministic. Sorting
# followed by stringifying does not produce a meaningful result.
out["generated_with_requirements"] = (
sorted(str(i) for i in self.requirements) if self.requirements is not None else None
)
return out
def is_valid_for(
self,
_: str | None, # Validation digests are not used by V2; this param will be deprecated
user_interpreter_constraints: InterpreterConstraints,
interpreter_universe: Iterable[str],
user_requirements: Iterable[Requirement] | None,
) -> LockfileMetadataValidation:
failure_reasons: set[InvalidLockfileReason] = set()
if user_requirements is None:
return LockfileMetadataValidation(failure_reasons)
if self.requirements != set(user_requirements):
failure_reasons.add(InvalidLockfileReason.REQUIREMENTS_MISMATCH)
if not self.valid_for_interpreter_constraints.contains(
user_interpreter_constraints, interpreter_universe
):
failure_reasons.add(InvalidLockfileReason.INTERPRETER_CONSTRAINTS_MISMATCH)
return LockfileMetadataValidation(failure_reasons)
def calculate_invalidation_digest(requirements: Iterable[str]) -> str:
"""Returns an invalidation digest for the given requirements."""
m = hashlib.sha256()
inputs = {
# `FrozenOrderedSet` deduplicates while keeping ordering, which speeds up the sorting if
# the input was already sorted.
"requirements": sorted(FrozenOrderedSet(requirements)),
}
m.update(json.dumps(inputs).encode("utf-8"))
return m.hexdigest()
class InvalidLockfileReason(Enum):
INVALIDATION_DIGEST_MISMATCH = "invalidation_digest_mismatch"
INTERPRETER_CONSTRAINTS_MISMATCH = "interpreter_constraints_mismatch"
REQUIREMENTS_MISMATCH = "requirements_mismatch"
class LockfileMetadataValidation:
"""Boolean-like value which additionally carries reasons why a validation failed."""
failure_reasons: set[InvalidLockfileReason]
def __init__(self, failure_reasons: Iterable[InvalidLockfileReason] = ()):
self.failure_reasons = set(failure_reasons)
def __bool__(self):
return not self.failure_reasons
T = TypeVar("T")
def _get_metadata(
metadata: dict[Any, Any],
lockfile_description: str,
error_suffix: str,
) -> Callable[[str, type[T], Callable[[Any], T] | None], T]:
"""Returns a function that will get a given key from the `metadata` dict, and optionally do some
verification and post-processing to return a value of the correct type."""
def get_metadata(key: str, type_: type[T], coerce: Callable[[Any], T] | None) -> T:
val: Any
try:
val = metadata[key]
except KeyError:
raise InvalidLockfileError(
f"Required key `{key}` is not present in metadata header for "
f"{lockfile_description}. {error_suffix}"
)
if not coerce:
if isinstance(val, type_):
return val
raise InvalidLockfileError(
f"Metadata value `{key}` in {lockfile_description} must "
f"be a {type(type_).__name__}. {error_suffix}"
)
else:
try:
return coerce(val)
except Exception:
raise InvalidLockfileError(
f"Metadata value `{key}` in {lockfile_description} must be able to "
f"be converted to a {type(type_).__name__}. {error_suffix}"
)
return get_metadata
| patricklaw/pants | src/python/pants/backend/python/util_rules/lockfile_metadata.py | Python | apache-2.0 | 14,210 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import vtk
import vtk.test.Testing
import math
class TestLinePlotColors(vtk.test.Testing.vtkTest):
def testLinePlot(self):
"Test if colored line plots can be built with python"
# Set up a 2D scene, add an XY chart to it
view = vtk.vtkContextView()
view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
view.GetRenderWindow().SetSize(400, 300)
chart = vtk.vtkChartXY()
view.GetScene().AddItem(chart)
# Create a table with some points in it
arrX = vtk.vtkFloatArray()
arrX.SetName("XAxis")
arrC = vtk.vtkFloatArray()
arrC.SetName("Cosine")
arrS = vtk.vtkFloatArray()
arrS.SetName("Sine")
arrS2 = vtk.vtkFloatArray()
arrS2.SetName("Sine2")
numPoints = 69
inc = 7.5 / (numPoints-1)
for i in range(numPoints):
arrX.InsertNextValue(i * inc)
arrC.InsertNextValue(math.cos(i * inc) + 0.0)
arrS.InsertNextValue(math.sin(i * inc) + 0.0)
arrS2.InsertNextValue(math.sin(i * inc) + 0.5)
table = vtk.vtkTable()
table.AddColumn(arrX)
table.AddColumn(arrC)
table.AddColumn(arrS)
table.AddColumn(arrS2)
# Generate a black-to-red lookup table with fixed alpha
lut = vtk.vtkLookupTable()
lut.SetValueRange(0.2, 1.0)
lut.SetSaturationRange(1, 1)
lut.SetHueRange(0,0)
lut.SetRampToLinear()
lut.SetRange(-1,1)
lut.SetAlpha(0.75)
lut.Build()
# Generate a black-to-blue lookup table with alpha range
lut2 = vtk.vtkLookupTable()
lut2.SetValueRange(0.2, 1.0)
lut2.SetSaturationRange(1, 1)
lut2.SetHueRange(0.6667, 0.6667)
lut2.SetAlphaRange(0.2, 0.8)
lut2.SetRampToLinear()
lut2.SetRange(-1,1)
lut2.Build()
# Add multiple line plots, setting the colors etc
line0 = chart.AddPlot(vtk.vtkChart.LINE)
line0.SetInputData(table, 0, 1)
line0.SetColor(50, 50, 50, 255)
line0.SetWidth(3.0)
line0.GetPen().SetLineType(vtk.vtkPen.SOLID_LINE)
line0.SetMarkerStyle(vtk.vtkPlotPoints.CIRCLE)
line0.SetScalarVisibility(1)
line0.SetLookupTable(lut)
line0.SelectColorArray(1)
line1 = chart.AddPlot(vtk.vtkChart.LINE)
line1.SetInputData(table, 0, 2)
line1.GetPen().SetLineType(vtk.vtkPen.NO_PEN)
line1.SetMarkerStyle(vtk.vtkPlotPoints.PLUS)
line1.SetColor(150, 100, 0, 255)
line2 = chart.AddPlot(vtk.vtkChart.LINE)
line2.SetInputData(table, 0, 3)
line2.SetColor(100, 100, 100, 255)
line2.SetWidth(3.0)
line2.GetPen().SetLineType(vtk.vtkPen.DASH_LINE)
line2.SetMarkerStyle(vtk.vtkPlotPoints.SQUARE)
line2.ScalarVisibilityOn()
line2.SetLookupTable(lut2)
line2.SelectColorArray("Sine")
chart.SetShowLegend(True)
view.GetRenderWindow().SetMultiSamples(0)
view.GetRenderWindow().Render()
img_file = "TestLinePlotColors.png"
vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25)
vtk.test.Testing.interact()
if __name__ == "__main__":
vtk.test.Testing.main([(TestLinePlotColors, 'test')])
| HopeFOAM/HopeFOAM | ThirdParty-0.1/ParaView-5.0.1/VTK/Charts/Core/Testing/Python/TestLinePlotColors.py | Python | gpl-3.0 | 3,397 |
# Copyright 2014, Brian Coca <bcoca@ansible.com>
# Copyright 2017, Ken Celenza <ken@networktocode.com>
# Copyright 2017, Jason Edelman <jason@networktocode.com>
# Copyright 2017, Ansible Project
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import collections
import itertools
import math
from jinja2.filters import environmentfilter
from ansible.errors import AnsibleFilterError
from ansible.module_utils import basic
from ansible.module_utils.six import binary_type, text_type
from ansible.module_utils.six.moves import zip, zip_longest
from ansible.module_utils._text import to_native, to_text
try:
from jinja2.filters import do_unique
HAS_UNIQUE = True
except ImportError:
HAS_UNIQUE = False
try:
from __main__ import display
except ImportError:
from ansible.utils.display import Display
display = Display()
@environmentfilter
def unique(environment, a, case_sensitive=False, attribute=None):
error = None
try:
if HAS_UNIQUE:
c = do_unique(environment, a, case_sensitive=case_sensitive, attribute=attribute)
if isinstance(a, collections.Hashable):
c = set(c)
else:
c = list(c)
except Exception as e:
if case_sensitive or attribute:
raise AnsibleFilterError("Jinja2's unique filter failed and we cannot fall back to Ansible's version "
"as it does not support the parameters supplied", orig_exc=e)
else:
display.warning('Falling back to Ansible unique filter as Jinja2 one failed: %s' % to_text(e))
error = e
if not HAS_UNIQUE or error:
# handle Jinja2 specific attributes when using Ansible's version
if case_sensitive or attribute:
raise AnsibleFilterError("Ansible's unique filter does not support case_sensitive nor attribute parameters, "
"you need a newer version of Jinja2 that provides their version of the filter.")
if isinstance(a, collections.Hashable):
c = set(a)
else:
c = []
for x in a:
if x not in c:
c.append(x)
return c
@environmentfilter
def intersect(environment, a, b):
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
c = set(a) & set(b)
else:
c = unique(environment, [x for x in a if x in b])
return c
@environmentfilter
def difference(environment, a, b):
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
c = set(a) - set(b)
else:
c = unique(environment, [x for x in a if x not in b])
return c
@environmentfilter
def symmetric_difference(environment, a, b):
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
c = set(a) ^ set(b)
else:
isect = intersect(environment, a, b)
c = [x for x in union(environment, a, b) if x not in isect]
return c
@environmentfilter
def union(environment, a, b):
if isinstance(a, collections.Hashable) and isinstance(b, collections.Hashable):
c = set(a) | set(b)
else:
c = unique(environment, a + b)
return c
def min(a):
_min = __builtins__.get('min')
return _min(a)
def max(a):
_max = __builtins__.get('max')
return _max(a)
def logarithm(x, base=math.e):
try:
if base == 10:
return math.log10(x)
else:
return math.log(x, base)
except TypeError as e:
raise AnsibleFilterError('log() can only be used on numbers: %s' % str(e))
def power(x, y):
try:
return math.pow(x, y)
except TypeError as e:
raise AnsibleFilterError('pow() can only be used on numbers: %s' % str(e))
def inversepower(x, base=2):
try:
if base == 2:
return math.sqrt(x)
else:
return math.pow(x, 1.0 / float(base))
except (ValueError, TypeError) as e:
raise AnsibleFilterError('root() can only be used on numbers: %s' % str(e))
def human_readable(size, isbits=False, unit=None):
''' Return a human readable string '''
try:
return basic.bytes_to_human(size, isbits, unit)
except Exception:
raise AnsibleFilterError("human_readable() can't interpret following string: %s" % size)
def human_to_bytes(size, default_unit=None, isbits=False):
''' Return bytes count from a human readable string '''
try:
return basic.human_to_bytes(size, default_unit, isbits)
except Exception:
raise AnsibleFilterError("human_to_bytes() can't interpret following string: %s" % size)
def rekey_on_member(data, key, duplicates='error'):
"""
Rekey a dict of dicts on another member
May also create a dict from a list of dicts.
duplicates can be one of ``error`` or ``overwrite`` to specify whether to error out if the key
value would be duplicated or to overwrite previous entries if that's the case.
"""
if duplicates not in ('error', 'overwrite'):
raise AnsibleFilterError("duplicates parameter to rekey_on_member has unknown value: {0}".format(duplicates))
new_obj = {}
if isinstance(data, collections.Mapping):
iterate_over = data.values()
elif isinstance(data, collections.Iterable) and not isinstance(data, (text_type, binary_type)):
iterate_over = data
else:
raise AnsibleFilterError("Type is not a valid list, set, or dict")
for item in iterate_over:
if not isinstance(item, collections.Mapping):
raise AnsibleFilterError("List item is not a valid dict")
try:
key_elem = item[key]
except KeyError:
raise AnsibleFilterError("Key {0} was not found".format(key))
except Exception as e:
raise AnsibleFilterError(to_native(e))
# Note: if new_obj[key_elem] exists it will always be a non-empty dict (it will at
# minimun contain {key: key_elem}
if new_obj.get(key_elem, None):
if duplicates == 'error':
raise AnsibleFilterError("Key {0} is not unique, cannot correctly turn into dict".format(key_elem))
elif duplicates == 'overwrite':
new_obj[key_elem] = item
else:
new_obj[key_elem] = item
return new_obj
class FilterModule(object):
''' Ansible math jinja2 filters '''
def filters(self):
filters = {
# general math
'min': min,
'max': max,
# exponents and logarithms
'log': logarithm,
'pow': power,
'root': inversepower,
# set theory
'unique': unique,
'intersect': intersect,
'difference': difference,
'symmetric_difference': symmetric_difference,
'union': union,
# combinatorial
'product': itertools.product,
'permutations': itertools.permutations,
'combinations': itertools.combinations,
# computer theory
'human_readable': human_readable,
'human_to_bytes': human_to_bytes,
'rekey_on_member': rekey_on_member,
# zip
'zip': zip,
'zip_longest': zip_longest,
}
return filters
| tchernomax/ansible | lib/ansible/plugins/filter/mathstuff.py | Python | gpl-3.0 | 8,117 |
import warnings as custom_warnings
# Monkeypatch the print of warning so we can customize them
def my_format_warning(message, category, *args):
"""
Override the default showwarning to customize the appearance of warnings
:return:
"""
return "\nWARNING %s: %s\n\n" % (category.__name__, message)
custom_warnings.formatwarning = my_format_warning
class ModelAssertionViolation(Exception):
pass
class ForbiddenRegionOfParameterSpace(Warning):
pass
class CppInterfaceNotAvailable(Warning):
pass
class CannotImportPlugin(Warning):
pass
class LikelihoodIsInfinite(Warning):
pass | sybenzvi/3ML | threeML/exceptions/custom_exceptions.py | Python | bsd-3-clause | 633 |
# Copyright 2016 VMware, 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.
"""
Copyright 2016 VMware, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0
"""
from . import VsphereContainerService
from . import VsphereContainerServiceImpl
| ashahi1/docker-volume-vsphere | esx_service/vmodl/VsphereContainerService__ext_init__.py | Python | apache-2.0 | 828 |
""" 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 |
from abc import ABC, abstractmethod
import logging
from humanfriendly.prompts import prepare_friendly_prompts
from adles.__about__ import __url__, __email__
class Script(ABC):
"""Base class for all CLI scripts."""
__version__ = '0.1.0'
name = ''
def __init__(self):
prepare_friendly_prompts() # Make input() more user friendly
self._log = logging.getLogger(self.name)
self._log.debug("Script name %s", self.name)
self._log.debug("Script version %s", self.__version__)
self._log.info(
'\n***** YOU RUN THIS SCRIPT AT YOUR OWN RISK *****\n'
'\n** Help and Documentation **'
'\n+ "<script> --help": flags, arguments, and usage'
'\n+ Read the latest documentation : https://adles.readthedocs.io'
'\n+ Open an issue on GitHub : %s'
'\n+ Email the script author : %s'
'\n', __url__, __email__)
@classmethod
def get_ver(cls):
return cls.name.capitalize() + ' ' + cls.__version__
@abstractmethod
def run(self):
pass
def __str__(self):
return self.__doc__
def __repr__(self):
return self.get_ver()
def __hash__(self):
return hash(repr(self))
def __eq__(self, other):
return self.name == other.name \
and self.__version__ == other.__version__
| GhostofGoes/ADLES | adles/scripts/script_base.py | Python | apache-2.0 | 1,402 |
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
engine = create_engine('sqlite:///backend.db', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()
def init_db():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
import models
Base.metadata.create_all(bind=engine)
| SecurityCompass/LabServer | database.py | Python | bsd-3-clause | 730 |
from __future__ import print_function
import unittest
import numpy as np
import pydrake
import os.path
class TestRBTCoM(unittest.TestCase):
def testCoM0(self):
r = pydrake.rbtree.RigidBodyTree(os.path.join(pydrake.getDrakePath(),
"examples/Pendulum/Pendulum.urdf"))
kinsol = r.doKinematics(np.zeros((7, 1)), np.zeros((7, 1)))
c = r.centerOfMass(kinsol)
self.assertTrue(np.allclose(c.flat, [0.0, 0.0, -0.2425], atol=1e-4))
def testCoMJacobian(self):
r = pydrake.rbtree.RigidBodyTree(os.path.join(pydrake.getDrakePath(),
"examples/Pendulum/Pendulum.urdf"))
q = r.getRandomConfiguration()
kinsol = r.doKinematics(q, np.zeros((7, 1)))
J = r.centerOfMassJacobian(kinsol)
self.assertTrue(np.shape(J) == (3, 7))
q = r.getZeroConfiguration()
kinsol = r.doKinematics(q, np.zeros((7, 1)))
J = r.centerOfMassJacobian(kinsol)
self.assertTrue(np.allclose(J.flat, [1., 0., 0., 0., -0.2425, 0., -0.25,
0., 1., 0., 0.2425, 0., 0., 0.,
0., 0., 1., 0., 0., 0., 0.], atol=1e-4))
if __name__ == '__main__':
unittest.main()
| billhoffman/drake | drake/bindings/python/pydrake/test/testRBTCoM.py | Python | bsd-3-clause | 1,228 |
# -*- coding: utf-8 -*-
from .baseaction import BaseAction
class PolyAction (BaseAction):
"""
Класс для полиморфного действия, поведение которого можно менять во
время работы
"""
def __init__(self,
application,
strid,
title,
description):
self._application = application
self._strid = strid
self._title = title
self._description = description
# Функция, которая будет вызываться из метода run(),
# если _func is not None
self._func = None
@property
def title(self):
return self._title
@property
def description(self):
return self._description
@property
def stringId(self):
return self._strid
def run(self, params):
if self._func is not None:
self._func(params)
def setFunc(self, func):
self._func = func
| unreal666/outwiker | src/outwiker/gui/polyaction.py | Python | gpl-3.0 | 1,052 |
data = (
'Zhi ', # 0x00
'Liu ', # 0x01
'Mei ', # 0x02
'Hoy ', # 0x03
'Rong ', # 0x04
'Zha ', # 0x05
'[?] ', # 0x06
'Biao ', # 0x07
'Zhan ', # 0x08
'Jie ', # 0x09
'Long ', # 0x0a
'Dong ', # 0x0b
'Lu ', # 0x0c
'Sayng ', # 0x0d
'Li ', # 0x0e
'Lan ', # 0x0f
'Yong ', # 0x10
'Shu ', # 0x11
'Xun ', # 0x12
'Shuan ', # 0x13
'Qi ', # 0x14
'Zhen ', # 0x15
'Qi ', # 0x16
'Li ', # 0x17
'Yi ', # 0x18
'Xiang ', # 0x19
'Zhen ', # 0x1a
'Li ', # 0x1b
'Su ', # 0x1c
'Gua ', # 0x1d
'Kan ', # 0x1e
'Bing ', # 0x1f
'Ren ', # 0x20
'Xiao ', # 0x21
'Bo ', # 0x22
'Ren ', # 0x23
'Bing ', # 0x24
'Zi ', # 0x25
'Chou ', # 0x26
'Yi ', # 0x27
'Jie ', # 0x28
'Xu ', # 0x29
'Zhu ', # 0x2a
'Jian ', # 0x2b
'Zui ', # 0x2c
'Er ', # 0x2d
'Er ', # 0x2e
'You ', # 0x2f
'Fa ', # 0x30
'Gong ', # 0x31
'Kao ', # 0x32
'Lao ', # 0x33
'Zhan ', # 0x34
'Li ', # 0x35
'Yin ', # 0x36
'Yang ', # 0x37
'He ', # 0x38
'Gen ', # 0x39
'Zhi ', # 0x3a
'Chi ', # 0x3b
'Ge ', # 0x3c
'Zai ', # 0x3d
'Luan ', # 0x3e
'Fu ', # 0x3f
'Jie ', # 0x40
'Hang ', # 0x41
'Gui ', # 0x42
'Tao ', # 0x43
'Guang ', # 0x44
'Wei ', # 0x45
'Kuang ', # 0x46
'Ru ', # 0x47
'An ', # 0x48
'An ', # 0x49
'Juan ', # 0x4a
'Yi ', # 0x4b
'Zhuo ', # 0x4c
'Ku ', # 0x4d
'Zhi ', # 0x4e
'Qiong ', # 0x4f
'Tong ', # 0x50
'Sang ', # 0x51
'Sang ', # 0x52
'Huan ', # 0x53
'Jie ', # 0x54
'Jiu ', # 0x55
'Xue ', # 0x56
'Duo ', # 0x57
'Zhui ', # 0x58
'Yu ', # 0x59
'Zan ', # 0x5a
'Kasei ', # 0x5b
'Ying ', # 0x5c
'Masu ', # 0x5d
'[?] ', # 0x5e
'Zhan ', # 0x5f
'Ya ', # 0x60
'Nao ', # 0x61
'Zhen ', # 0x62
'Dang ', # 0x63
'Qi ', # 0x64
'Qiao ', # 0x65
'Hua ', # 0x66
'Kuai ', # 0x67
'Jiang ', # 0x68
'Zhuang ', # 0x69
'Xun ', # 0x6a
'Suo ', # 0x6b
'Sha ', # 0x6c
'Zhen ', # 0x6d
'Bei ', # 0x6e
'Ting ', # 0x6f
'Gua ', # 0x70
'Jing ', # 0x71
'Bo ', # 0x72
'Ben ', # 0x73
'Fu ', # 0x74
'Rui ', # 0x75
'Tong ', # 0x76
'Jue ', # 0x77
'Xi ', # 0x78
'Lang ', # 0x79
'Liu ', # 0x7a
'Feng ', # 0x7b
'Qi ', # 0x7c
'Wen ', # 0x7d
'Jun ', # 0x7e
'Gan ', # 0x7f
'Cu ', # 0x80
'Liang ', # 0x81
'Qiu ', # 0x82
'Ting ', # 0x83
'You ', # 0x84
'Mei ', # 0x85
'Bang ', # 0x86
'Long ', # 0x87
'Peng ', # 0x88
'Zhuang ', # 0x89
'Di ', # 0x8a
'Xuan ', # 0x8b
'Tu ', # 0x8c
'Zao ', # 0x8d
'Ao ', # 0x8e
'Gu ', # 0x8f
'Bi ', # 0x90
'Di ', # 0x91
'Han ', # 0x92
'Zi ', # 0x93
'Zhi ', # 0x94
'Ren ', # 0x95
'Bei ', # 0x96
'Geng ', # 0x97
'Jian ', # 0x98
'Huan ', # 0x99
'Wan ', # 0x9a
'Nuo ', # 0x9b
'Jia ', # 0x9c
'Tiao ', # 0x9d
'Ji ', # 0x9e
'Xiao ', # 0x9f
'Lu ', # 0xa0
'Huan ', # 0xa1
'Shao ', # 0xa2
'Cen ', # 0xa3
'Fen ', # 0xa4
'Song ', # 0xa5
'Meng ', # 0xa6
'Wu ', # 0xa7
'Li ', # 0xa8
'Li ', # 0xa9
'Dou ', # 0xaa
'Cen ', # 0xab
'Ying ', # 0xac
'Suo ', # 0xad
'Ju ', # 0xae
'Ti ', # 0xaf
'Jie ', # 0xb0
'Kun ', # 0xb1
'Zhuo ', # 0xb2
'Shu ', # 0xb3
'Chan ', # 0xb4
'Fan ', # 0xb5
'Wei ', # 0xb6
'Jing ', # 0xb7
'Li ', # 0xb8
'Bing ', # 0xb9
'Fumoto ', # 0xba
'Shikimi ', # 0xbb
'Tao ', # 0xbc
'Zhi ', # 0xbd
'Lai ', # 0xbe
'Lian ', # 0xbf
'Jian ', # 0xc0
'Zhuo ', # 0xc1
'Ling ', # 0xc2
'Li ', # 0xc3
'Qi ', # 0xc4
'Bing ', # 0xc5
'Zhun ', # 0xc6
'Cong ', # 0xc7
'Qian ', # 0xc8
'Mian ', # 0xc9
'Qi ', # 0xca
'Qi ', # 0xcb
'Cai ', # 0xcc
'Gun ', # 0xcd
'Chan ', # 0xce
'Te ', # 0xcf
'Fei ', # 0xd0
'Pai ', # 0xd1
'Bang ', # 0xd2
'Pou ', # 0xd3
'Hun ', # 0xd4
'Zong ', # 0xd5
'Cheng ', # 0xd6
'Zao ', # 0xd7
'Ji ', # 0xd8
'Li ', # 0xd9
'Peng ', # 0xda
'Yu ', # 0xdb
'Yu ', # 0xdc
'Gu ', # 0xdd
'Hun ', # 0xde
'Dong ', # 0xdf
'Tang ', # 0xe0
'Gang ', # 0xe1
'Wang ', # 0xe2
'Di ', # 0xe3
'Xi ', # 0xe4
'Fan ', # 0xe5
'Cheng ', # 0xe6
'Zhan ', # 0xe7
'Qi ', # 0xe8
'Yuan ', # 0xe9
'Yan ', # 0xea
'Yu ', # 0xeb
'Quan ', # 0xec
'Yi ', # 0xed
'Sen ', # 0xee
'Ren ', # 0xef
'Chui ', # 0xf0
'Leng ', # 0xf1
'Qi ', # 0xf2
'Zhuo ', # 0xf3
'Fu ', # 0xf4
'Ke ', # 0xf5
'Lai ', # 0xf6
'Zou ', # 0xf7
'Zou ', # 0xf8
'Zhuo ', # 0xf9
'Guan ', # 0xfa
'Fen ', # 0xfb
'Fen ', # 0xfc
'Chen ', # 0xfd
'Qiong ', # 0xfe
'Nie ', # 0xff
)
| samuelmaudo/yepes | yepes/utils/unidecode/x068.py | Python | bsd-3-clause | 4,674 |
#!/usr/bin/env python3
# Copyright (c) 2017 The Doriancoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test logic for setting nMinimumChainWork on command line.
Nodes don't consider themselves out of "initial block download" until
their active chain has more work than nMinimumChainWork.
Nodes don't download blocks from a peer unless the peer's best known block
has more work than nMinimumChainWork.
While in initial block download, nodes won't relay blocks to their peers, so
test that this parameter functions as intended by verifying that block relay
only succeeds past a given node once its nMinimumChainWork has been exceeded.
"""
import time
from test_framework.test_framework import DoriancoinTestFramework
from test_framework.util import connect_nodes, assert_equal
# 2 hashes required per regtest block (with no difficulty adjustment)
REGTEST_WORK_PER_BLOCK = 2
class MinimumChainWorkTest(DoriancoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
self.extra_args = [[], ["-minimumchainwork=0x65"], ["-minimumchainwork=0x65"]]
self.node_min_work = [0, 101, 101]
def setup_network(self):
# This test relies on the chain setup being:
# node0 <- node1 <- node2
# Before leaving IBD, nodes prefer to download blocks from outbound
# peers, so ensure that we're mining on an outbound peer and testing
# block relay to inbound peers.
self.setup_nodes()
for i in range(self.num_nodes-1):
connect_nodes(self.nodes[i+1], i)
def run_test(self):
# Start building a chain on node0. node2 shouldn't be able to sync until node1's
# minchainwork is exceeded
starting_chain_work = REGTEST_WORK_PER_BLOCK # Genesis block's work
self.log.info("Testing relay across node %d (minChainWork = %d)", 1, self.node_min_work[1])
starting_blockcount = self.nodes[2].getblockcount()
num_blocks_to_generate = int((self.node_min_work[1] - starting_chain_work) / REGTEST_WORK_PER_BLOCK)
self.log.info("Generating %d blocks on node0", num_blocks_to_generate)
hashes = self.nodes[0].generate(num_blocks_to_generate)
self.log.info("Node0 current chain work: %s", self.nodes[0].getblockheader(hashes[-1])['chainwork'])
# Sleep a few seconds and verify that node2 didn't get any new blocks
# or headers. We sleep, rather than sync_blocks(node0, node1) because
# it's reasonable either way for node1 to get the blocks, or not get
# them (since they're below node1's minchainwork).
time.sleep(3)
self.log.info("Verifying node 2 has no more blocks than before")
self.log.info("Blockcounts: %s", [n.getblockcount() for n in self.nodes])
# Node2 shouldn't have any new headers yet, because node1 should not
# have relayed anything.
assert_equal(len(self.nodes[2].getchaintips()), 1)
assert_equal(self.nodes[2].getchaintips()[0]['height'], 0)
assert self.nodes[1].getbestblockhash() != self.nodes[0].getbestblockhash()
assert_equal(self.nodes[2].getblockcount(), starting_blockcount)
self.log.info("Generating one more block")
self.nodes[0].generate(1)
self.log.info("Verifying nodes are all synced")
# Because nodes in regtest are all manual connections (eg using
# addnode), node1 should not have disconnected node0. If not for that,
# we'd expect node1 to have disconnected node0 for serving an
# insufficient work chain, in which case we'd need to reconnect them to
# continue the test.
self.sync_all()
self.log.info("Blockcounts: %s", [n.getblockcount() for n in self.nodes])
if __name__ == '__main__':
MinimumChainWorkTest().main()
| doriancoins/doriancoin | test/functional/feature_minchainwork.py | Python | mit | 3,955 |
#
# Kivy - Crossplatform NUI toolkit
# http://kivy.org/
#
import sys
from copy import deepcopy
import os
from os.path import join, dirname, sep, exists, basename
from os import walk, environ
from distutils.core import setup
from distutils.extension import Extension
from collections import OrderedDict
if sys.version > '3':
PY3 = True
else:
PY3 = False
def getoutput(cmd):
import subprocess
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
return p.communicate()[0]
def pkgconfig(*packages, **kw):
flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
cmd = 'pkg-config --libs --cflags {}'.format(' '.join(packages))
for token in getoutput(cmd).split():
ext = token[:2].decode('utf-8')
flag = flag_map.get(ext)
if not flag:
continue
kw.setdefault(flag, []).append(token[2:].decode('utf-8'))
return kw
# -----------------------------------------------------------------------------
# Determine on which platform we are
platform = sys.platform
# Detect 32/64bit for OSX (http://stackoverflow.com/a/1405971/798575)
if sys.platform == 'darwin':
if sys.maxsize > 2 ** 32:
osx_arch = 'x86_64'
else:
osx_arch = 'i386'
# Detect Python for android project (http://github.com/kivy/python-for-android)
ndkplatform = environ.get('NDKPLATFORM')
if ndkplatform is not None and environ.get('LIBLINK'):
platform = 'android'
kivy_ios_root = environ.get('KIVYIOSROOT', None)
if kivy_ios_root is not None:
platform = 'ios'
if exists('/opt/vc/include/bcm_host.h'):
platform = 'rpi'
# -----------------------------------------------------------------------------
# Detect options
#
c_options = OrderedDict()
c_options['use_rpi'] = platform == 'rpi'
c_options['use_opengl_es2'] = True
c_options['use_opengl_debug'] = False
c_options['use_glew'] = False
c_options['use_sdl'] = False
c_options['use_ios'] = False
c_options['use_mesagl'] = False
c_options['use_x11'] = False
c_options['use_gstreamer'] = False
c_options['use_avfoundation'] = platform == 'darwin'
# now check if environ is changing the default values
for key in list(c_options.keys()):
ukey = key.upper()
if ukey in environ:
value = bool(int(environ[ukey]))
print('Environ change {0} -> {1}'.format(key, value))
c_options[key] = value
# -----------------------------------------------------------------------------
# Cython check
# on python-for-android and kivy-ios, cython usage is external
have_cython = False
if platform in ('ios', 'android'):
print('\nCython check avoided.')
else:
try:
# check for cython
from Cython.Distutils import build_ext
have_cython = True
except ImportError:
print('\nCython is missing, its required for compiling kivy !\n\n')
raise
if not have_cython:
from distutils.command.build_ext import build_ext
# -----------------------------------------------------------------------------
# Setup classes
class KivyBuildExt(build_ext):
def build_extensions(self):
print('Build configuration is:')
for opt, value in c_options.items():
print(' * {0} = {1}'.format(opt, value))
print('Generate config.h')
config_h_fn = expand('graphics', 'config.h')
config_h = '// Autogenerated file for Kivy C configuration\n'
config_h += '#define __PY3 {0}\n'.format(int(PY3))
for k, v in c_options.items():
config_h += '#define __{0} {1}\n'.format(k.upper(), int(v))
self.update_if_changed(config_h_fn, config_h)
print('Generate config.pxi')
config_pxi_fn = expand('graphics', 'config.pxi')
# update the pxi only if the content changed
config_pxi = '# Autogenerated file for Kivy Cython configuration\n'
config_pxi += 'DEF PY3 = {0}\n'.format(int(PY3))
for k, v in c_options.items():
config_pxi += 'DEF {0} = {1}\n'.format(k.upper(), int(v))
self.update_if_changed(config_pxi_fn, config_pxi)
c = self.compiler.compiler_type
print('Detected compiler is {}'.format(c))
if c != 'msvc':
for e in self.extensions:
e.extra_link_args += ['-lm']
build_ext.build_extensions(self)
def update_if_changed(self, fn, content):
need_update = True
if exists(fn):
with open(fn) as fd:
need_update = fd.read() != content
if need_update:
with open(fn, 'w') as fd:
fd.write(content)
# -----------------------------------------------------------------------------
# extract version (simulate doc generation, kivy will be not imported)
environ['KIVY_DOC_INCLUDE'] = '1'
import kivy
# extra build commands go in the cmdclass dict {'command-name': CommandClass}
# see tools.packaging.{platform}.build.py for custom build commands for
# portable packages. also e.g. we use build_ext command from cython if its
# installed for c extensions.
from kivy.tools.packaging.factory import FactoryBuild
cmdclass = {
'build_factory': FactoryBuild,
'build_ext': KivyBuildExt}
try:
# add build rules for portable packages to cmdclass
if platform == 'win32':
from kivy.tools.packaging.win32.build import WindowsPortableBuild
cmdclass['build_portable'] = WindowsPortableBuild
elif platform == 'darwin':
from kivy.tools.packaging.osx.build import OSXPortableBuild
cmdclass['build_portable'] = OSXPortableBuild
except ImportError:
print('User distribution detected, avoid portable command.')
# Detect which opengl version headers to use
if platform in ('android', 'darwin', 'ios', 'rpi'):
pass
elif platform == 'win32':
print('Windows platform detected, force GLEW usage.')
c_options['use_glew'] = True
else:
# searching GLES headers
default_header_dirs = ['/usr/include', '/usr/local/include']
found = False
for hdir in default_header_dirs:
filename = join(hdir, 'GLES2', 'gl2.h')
if exists(filename):
found = True
print('Found GLES 2.0 headers at {0}'.format(filename))
break
if not found:
print('WARNING: GLES 2.0 headers are not found')
print('Fallback to Desktop opengl headers.')
c_options['use_opengl_es2'] = False
# check if we are in a kivy-ios build
if platform == 'ios':
print('Kivy-IOS project environment detect, use it.')
print('Kivy-IOS project located at {0}'.format(kivy_ios_root))
print('Activate SDL compilation.')
c_options['use_ios'] = True
c_options['use_sdl'] = True
# detect gstreamer, only on desktop
if platform not in ('ios', 'android'):
gst_flags = pkgconfig('gstreamer-1.0')
if 'libraries' in gst_flags:
c_options['use_gstreamer'] = True
# -----------------------------------------------------------------------------
# declare flags
def get_modulename_from_file(filename):
filename = filename.replace(sep, '/')
pyx = '.'.join(filename.split('.')[:-1])
pyxl = pyx.split('/')
while pyxl[0] != 'kivy':
pyxl.pop(0)
if pyxl[1] == 'kivy':
pyxl.pop(0)
return '.'.join(pyxl)
def expand(*args):
return join(dirname(__file__), 'kivy', *args)
class CythonExtension(Extension):
def __init__(self, *args, **kwargs):
Extension.__init__(self, *args, **kwargs)
self.cython_directives = {
'c_string_encoding': 'utf-8',
'profile': 'USE_PROFILE' in environ,
'embedsignature': 'USE_EMBEDSIGNATURE' in environ}
# XXX with pip, setuptools is imported before distutils, and change
# our pyx to c, then, cythonize doesn't happen. So force again our
# sources
self.sources = args[1]
def merge(d1, *args):
d1 = deepcopy(d1)
for d2 in args:
for key, value in d2.items():
value = deepcopy(value)
if key in d1:
d1[key].extend(value)
else:
d1[key] = value
return d1
def determine_base_flags():
flags = {
'libraries': [],
'include_dirs': [],
'extra_link_args': [],
'extra_compile_args': []}
if c_options['use_ios']:
sysroot = environ.get('IOSSDKROOT', environ.get('SDKROOT'))
if not sysroot:
raise Exception('IOSSDKROOT is not set')
flags['include_dirs'] += [sysroot]
flags['extra_compile_args'] += ['-isysroot', sysroot]
flags['extra_link_args'] += ['-isysroot', sysroot]
elif platform == 'darwin':
v = os.uname()
if v[2] >= '13.0.0':
# use xcode-select to search on the right Xcode path
# XXX use the best SDK available instead of a specific one
import platform as _platform
xcode_dev = getoutput('xcode-select -p').splitlines()[0]
sdk_mac_ver = '.'.join(_platform.mac_ver()[0].split('.')[:2])
print('Xcode detected at {}, and using MacOSX{} sdk'.format(
xcode_dev, sdk_mac_ver))
sysroot = join(xcode_dev,
'Platforms/MacOSX.platform/Developer/SDKs',
'MacOSX{}.sdk'.format(sdk_mac_ver),
'System/Library/Frameworks')
else:
sysroot = ('/System/Library/Frameworks/'
'ApplicationServices.framework/Frameworks')
flags['extra_compile_args'] += ['-F%s' % sysroot]
flags['extra_link_args'] += ['-F%s' % sysroot]
return flags
def determine_gl_flags():
flags = {'libraries': []}
if platform == 'win32':
flags['libraries'] = ['opengl32']
elif platform == 'ios':
flags['libraries'] = ['GLESv2']
flags['extra_link_args'] = ['-framework', 'OpenGLES']
elif platform == 'darwin':
flags['extra_link_args'] = ['-framework', 'OpenGL', '-arch', osx_arch]
flags['extra_compile_args'] = ['-arch', osx_arch]
elif platform.startswith('freebsd'):
flags['include_dirs'] = ['/usr/local/include']
flags['extra_link_args'] = ['-L', '/usr/local/lib']
flags['libraries'] = ['GL']
elif platform.startswith('openbsd'):
flags['include_dirs'] = ['/usr/X11R6/include']
flags['extra_link_args'] = ['-L', '/usr/X11R6/lib']
flags['libraries'] = ['GL']
elif platform == 'android':
flags['include_dirs'] = [join(ndkplatform, 'usr', 'include')]
flags['extra_link_args'] = ['-L', join(ndkplatform, 'usr', 'lib')]
flags['libraries'] = ['GLESv2']
elif platform == 'rpi':
flags['include_dirs'] = ['/opt/vc/include',
'/opt/vc/include/interface/vcos/pthreads',
'/opt/vc/include/interface/vmcs_host/linux']
flags['extra_link_args'] = ['-L', '/opt/vc/lib']
flags['libraries'] = ['GLESv2']
else:
flags['libraries'] = ['GL']
if c_options['use_glew']:
if platform == 'win32':
flags['libraries'] += ['glew32']
else:
flags['libraries'] += ['GLEW']
return flags
def determine_sdl():
flags = {}
if not c_options['use_sdl']:
return flags
flags['libraries'] = ['SDL', 'SDL_ttf', 'freetype', 'z', 'bz2']
flags['include_dirs'] = []
flags['extra_link_args'] = []
flags['extra_compile_args'] = []
# Paths as per homebrew (modified formula to use hg checkout)
if c_options['use_ios']:
# Note: on IOS, SDL is already loaded by the launcher/main.m
# So if we add it here, it will just complain about duplicate
# symbol, cause libSDL.a would be included in main.m binary +
# text_sdlttf.so
# At the result, we are linking without SDL explicitly, and add
# -undefined dynamic_lookup
# (/tito)
flags['libraries'] = ['SDL_ttf', 'freetype', 'bz2']
flags['include_dirs'] += [
join(kivy_ios_root, 'build', 'include'),
join(kivy_ios_root, 'build', 'include', 'SDL'),
join(kivy_ios_root, 'build', 'include', 'freetype')]
flags['extra_link_args'] += [
'-L', join(kivy_ios_root, 'build', 'lib'),
'-undefined', 'dynamic_lookup']
else:
flags['include_dirs'] = ['/usr/local/include/SDL']
flags['extra_link_args'] += ['-L/usr/local/lib/']
if platform == 'ios':
flags['extra_link_args'] += [
'-framework', 'Foundation',
'-framework', 'UIKit',
'-framework', 'AudioToolbox',
'-framework', 'CoreGraphics',
'-framework', 'QuartzCore',
'-framework', 'MobileCoreServices',
'-framework', 'ImageIO']
elif platform == 'darwin':
flags['extra_link_args'] += [
'-framework', 'ApplicationServices']
return flags
base_flags = determine_base_flags()
gl_flags = determine_gl_flags()
# -----------------------------------------------------------------------------
# sources to compile
# all the dependencies have been found manually with:
# grep -inr -E '(cimport|include)' kivy/graphics/context_instructions.{pxd,pyx}
graphics_dependencies = {
'gl_redirect.h': ['common_subset.h'],
'c_opengl.pxd': ['config.pxi', 'gl_redirect.h'],
'buffer.pyx': ['common.pxi'],
'context.pxd': [
'instructions.pxd', 'texture.pxd', 'vbo.pxd',
'c_opengl.pxd', 'c_opengl_debug.pxd'],
'c_opengl_debug.pyx': ['common.pxi', 'c_opengl.pxd'],
'compiler.pxd': ['instructions.pxd'],
'compiler.pyx': ['context_instructions.pxd'],
'context_instructions.pxd': [
'transformation.pxd', 'instructions.pxd', 'texture.pxd'],
'fbo.pxd': ['c_opengl.pxd', 'instructions.pxd', 'texture.pxd'],
'fbo.pyx': [
'config.pxi', 'opcodes.pxi', 'transformation.pxd', 'context.pxd',
'c_opengl_debug.pxd'],
'gl_instructions.pyx': [
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
'instructions.pxd'],
'instructions.pxd': [
'vbo.pxd', 'context_instructions.pxd', 'compiler.pxd', 'shader.pxd',
'texture.pxd', '../_event.pxd'],
'instructions.pyx': [
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
'context.pxd', 'common.pxi', 'vertex.pxd', 'transformation.pxd'],
'opengl.pyx': ['config.pxi', 'common.pxi', 'c_opengl.pxd', 'gl_redirect.h'],
'opengl_utils.pyx': ['opengl_utils_def.pxi', 'c_opengl.pxd'],
'shader.pxd': ['c_opengl.pxd', 'transformation.pxd', 'vertex.pxd'],
'shader.pyx': [
'config.pxi', 'common.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd',
'vertex.pxd', 'transformation.pxd', 'context.pxd'],
'stencil_instructions.pxd': ['instructions.pxd'],
'stencil_instructions.pyx': [
'config.pxi', 'opcodes.pxi', 'c_opengl.pxd', 'c_opengl_debug.pxd'],
'texture.pxd': ['c_opengl.pxd'],
'texture.pyx': [
'config.pxi', 'common.pxi', 'opengl_utils_def.pxi', 'context.pxd',
'c_opengl.pxd', 'c_opengl_debug.pxd', 'opengl_utils.pxd'],
'vbo.pxd': ['buffer.pxd', 'c_opengl.pxd', 'vertex.pxd'],
'vbo.pyx': [
'config.pxi', 'common.pxi', 'c_opengl_debug.pxd', 'context.pxd',
'instructions.pxd', 'shader.pxd'],
'vertex.pxd': ['c_opengl.pxd'],
'vertex.pyx': ['config.pxi', 'common.pxi'],
'vertex_instructions.pyx': [
'config.pxi', 'common.pxi', 'vbo.pxd', 'vertex.pxd', 'instructions.pxd',
'c_opengl.pxd', 'c_opengl_debug.pxd', 'texture.pxd',
'vertex_instructions_line.pxi'],
'vertex_instructions_line.pxi': ['stencil_instructions.pxd']}
sources = {
'_event.pyx': base_flags,
'properties.pyx': base_flags,
'graphics/buffer.pyx': base_flags,
'graphics/context.pyx': merge(base_flags, gl_flags),
'graphics/c_opengl_debug.pyx': merge(base_flags, gl_flags),
'graphics/compiler.pyx': merge(base_flags, gl_flags),
'graphics/context_instructions.pyx': merge(base_flags, gl_flags),
'graphics/fbo.pyx': merge(base_flags, gl_flags),
'graphics/gl_instructions.pyx': merge(base_flags, gl_flags),
'graphics/instructions.pyx': merge(base_flags, gl_flags),
'graphics/opengl.pyx': merge(base_flags, gl_flags),
'graphics/opengl_utils.pyx': merge(base_flags, gl_flags),
'graphics/shader.pyx': merge(base_flags, gl_flags),
'graphics/stencil_instructions.pyx': merge(base_flags, gl_flags),
'graphics/texture.pyx': merge(base_flags, gl_flags),
'graphics/transformation.pyx': merge(base_flags, gl_flags),
'graphics/vbo.pyx': merge(base_flags, gl_flags),
'graphics/vertex.pyx': merge(base_flags, gl_flags),
'graphics/vertex_instructions.pyx': merge(base_flags, gl_flags)}
if c_options['use_sdl']:
sdl_flags = determine_sdl()
sources['core/window/sdl.pyx'] = merge(
base_flags, gl_flags, sdl_flags)
sources['core/text/text_sdlttf.pyx'] = merge(
base_flags, gl_flags, sdl_flags)
sources['core/audio/audio_sdl.pyx'] = merge(
base_flags, sdl_flags)
if platform in ('darwin', 'ios'):
# activate ImageIO provider for our core image
if platform == 'ios':
osx_flags = {'extra_link_args': [
'-framework', 'Foundation',
'-framework', 'UIKit',
'-framework', 'AudioToolbox',
'-framework', 'CoreGraphics',
'-framework', 'QuartzCore',
'-framework', 'ImageIO']}
else:
osx_flags = {'extra_link_args': [
'-framework', 'ApplicationServices']}
sources['core/image/img_imageio.pyx'] = merge(
base_flags, osx_flags)
if c_options['use_avfoundation']:
import platform as _platform
mac_ver = [int(x) for x in _platform.mac_ver()[0].split('.')[:2]]
if mac_ver >= [10, 7]:
osx_flags = {
'extra_link_args': ['-framework', 'AVFoundation'],
'extra_compile_args': ['-ObjC++'],
'depends': ['core/camera/camera_avfoundation.m']}
sources['core/camera/camera_avfoundation.pyx'] = merge(
base_flags, osx_flags)
else:
print('AVFoundation cannot be used, OSX >= 10.7 is required')
if c_options['use_rpi']:
sources['lib/vidcore_lite/egl.pyx'] = merge(
base_flags, gl_flags)
sources['lib/vidcore_lite/bcm.pyx'] = merge(
base_flags, gl_flags)
if c_options['use_x11']:
sources['core/window/window_x11.pyx'] = merge(
base_flags, gl_flags, {
'depends': [
'core/window/window_x11_keytab.c',
'core/window/window_x11_core.c'],
'libraries': ['Xrender', 'X11']})
if c_options['use_gstreamer']:
sources['lib/gstplayer/_gstplayer.pyx'] = merge(
base_flags, gst_flags, {
'depends': ['lib/gstplayer/_gstplayer.h']})
# -----------------------------------------------------------------------------
# extension modules
def get_dependencies(name, deps=None):
if deps is None:
deps = []
for dep in graphics_dependencies.get(name, []):
if dep not in deps:
deps.append(dep)
get_dependencies(dep, deps)
return deps
def resolve_dependencies(fn, depends):
fn = basename(fn)
deps = []
get_dependencies(fn, deps)
get_dependencies(fn.replace('.pyx', '.pxd'), deps)
return [expand('graphics', x) for x in deps]
def get_extensions_from_sources(sources):
ext_modules = []
if environ.get('KIVY_FAKE_BUILDEXT'):
print('Fake build_ext asked, will generate only .h/.c')
return ext_modules
for pyx, flags in sources.items():
is_graphics = pyx.startswith('graphics')
pyx = expand(pyx)
if not have_cython:
pyx = '%s.c' % pyx[:-4]
depends = []
else:
depends = [expand(x) for x in flags.pop('depends', [])]
if is_graphics:
depends = resolve_dependencies(pyx, depends)
module_name = get_modulename_from_file(pyx)
flags_clean = {'depends': depends}
for key, value in flags.items():
if len(value):
flags_clean[key] = value
ext_modules.append(CythonExtension(module_name,
[pyx], **flags_clean))
return ext_modules
ext_modules = get_extensions_from_sources(sources)
# -----------------------------------------------------------------------------
# automatically detect data files
data_file_prefix = 'share/kivy-'
examples = {}
examples_allowed_ext = ('readme', 'py', 'wav', 'png', 'jpg', 'svg', 'json',
'avi', 'gif', 'txt', 'ttf', 'obj', 'mtl', 'kv')
for root, subFolders, files in walk('examples'):
for fn in files:
ext = fn.split('.')[-1].lower()
if ext not in examples_allowed_ext:
continue
filename = join(root, fn)
directory = '%s%s' % (data_file_prefix, dirname(filename))
if not directory in examples:
examples[directory] = []
examples[directory].append(filename)
# -----------------------------------------------------------------------------
# setup !
setup(
name='Kivy',
version=kivy.__version__,
author='Kivy Crew',
author_email='kivy-dev@googlegroups.com',
url='http://kivy.org/',
license='MIT',
description=(
'A software library for rapid development of '
'hardware-accelerated multitouch applications.'),
ext_modules=ext_modules,
cmdclass=cmdclass,
packages=[
'kivy',
'kivy.adapters',
'kivy.core',
'kivy.core.audio',
'kivy.core.camera',
'kivy.core.clipboard',
'kivy.core.image',
'kivy.core.gl',
'kivy.core.spelling',
'kivy.core.text',
'kivy.core.video',
'kivy.core.window',
'kivy.effects',
'kivy.ext',
'kivy.graphics',
'kivy.input',
'kivy.input.postproc',
'kivy.input.providers',
'kivy.lib',
'kivy.lib.osc',
'kivy.lib.gstplayer',
'kivy.lib.vidcore_lite',
'kivy.modules',
'kivy.network',
'kivy.storage',
'kivy.tools',
'kivy.tools.packaging',
'kivy.tools.packaging.pyinstaller_hooks',
'kivy.tools.highlight',
'kivy.extras',
'kivy.tools.extensions',
'kivy.uix', ],
package_dir={'kivy': 'kivy'},
package_data={'kivy': [
'data/*.kv',
'data/*.json',
'data/fonts/*.ttf',
'data/images/*.png',
'data/images/*.jpg',
'data/images/*.gif',
'data/images/*.atlas',
'data/keyboards/*.json',
'data/logo/*.png',
'data/glsl/*.png',
'data/glsl/*.vs',
'data/glsl/*.fs',
'tools/highlight/*.vim',
'tools/highlight/*.el',
'tools/packaging/README.txt',
'tools/packaging/win32/kivy.bat',
'tools/packaging/win32/kivyenv.sh',
'tools/packaging/win32/README.txt',
'tools/packaging/osx/Info.plist',
'tools/packaging/osx/InfoPlist.strings',
'tools/packaging/osx/kivy.sh']},
data_files=list(examples.items()),
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: MacOS X',
'Environment :: Win32 (MS Windows)',
'Environment :: X11 Applications',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: BSD :: FreeBSD',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Artistic Software',
'Topic :: Games/Entertainment',
'Topic :: Multimedia :: Graphics :: 3D Rendering',
'Topic :: Multimedia :: Graphics :: Capture :: Digital Camera',
'Topic :: Multimedia :: Graphics :: Presentation',
'Topic :: Multimedia :: Graphics :: Viewers',
'Topic :: Multimedia :: Sound/Audio :: Players :: MP3',
'Topic :: Multimedia :: Video :: Display',
'Topic :: Scientific/Engineering :: Human Machine Interfaces',
'Topic :: Scientific/Engineering :: Visualization',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Topic :: Software Development :: User Interfaces'],
dependency_links=[
'https://github.com/kivy-garden/garden/archive/master.zip'],
install_requires=['Kivy-Garden==0.1.1'])
| JulienMcJay/eclock | windows/kivy/setup.py | Python | gpl-2.0 | 24,726 |
import yaml
import os.path
import os
import jinja2
import sys
sys.path = [os.path.join(os.path.dirname(__file__), '..')] + sys.path
import bindings.get_info
from bindings.maybe_write import maybe_write
import re
if len(sys.argv) != 2:
print("Invalid usage: do not have destination")
sys.exit(1)
print("Generating", sys.argv[1])
directory = os.path.split(os.path.abspath(__file__))[0]
all_info = bindings.get_info.get_all_info()
metadata =all_info['metadata']
#we change {{ and }} to <% and %> to avoid ambiguity when building arrays.
environment = jinja2.Environment(
variable_start_string = '<%', variable_end_string = '%>',
loader = jinja2.FileSystemLoader(directory),
undefined = jinja2.StrictUndefined,
extensions = ['jinja2.ext.loopcontrols'])
#we have to do some sanitizing for the template.
#the map we have here is actually very verbose, and can be flattened into something easily iterable.
#we can then take advantage of either std::pair or std::tuple as the keys.
joined_properties = []
for nodekey, nodeinfo in [(i, metadata['nodes'].get(i, dict())) for i in all_info['constants'].keys() if re.match("Lav_OBJTYPE(\w+_*)+_NODE", i)]:
#add everything from the object itself.
for propkey, propinfo in nodeinfo.get('properties', dict()).items():
joined_properties.append((nodekey, propkey, propinfo))
#if we're not suppressing inheritence, we follow this up with everything from lav_OBJTYPE_GENERIC.
if not nodeinfo.get('suppress_implied_inherit', False):
for propkey, propinfo in metadata['nodes']['Lav_OBJTYPE_GENERIC_NODE']['properties'].items():
joined_properties.append((nodekey, propkey, propinfo))
#this is the same logic, but for events.
joined_events = []
for nodekey, nodeinfo in [(i, metadata['nodes'].get(i, dict())) for i in all_info['constants'].keys() if re.match("Lav_OBJTYPE_(\w+_*)+_NODE", i)]:
#add everything from the object itself.
for eventkey, eventinfo in nodeinfo.get('events', dict()).items():
joined_events.append((nodekey, eventkey, eventinfo))
#if we're not suppressing inheritence, we follow this up with everything from lav_OBJTYPE_GENERIC.
if not nodeinfo.get('suppress_implied_inherit', False):
for eventkey, eventinfo in metadata['nodes']['Lav_OBJTYPE_GENERIC_NODE'].get('events', dict()).items():
joined_events.append((nodekey, eventkey, eventinfo))
#the template will convert the types into enums via judicious use of if statements-we use it like augmented c, and prefer to do refactoring only there when possible.
#each property will be crammed into a property descriptor, but some of the ranges here are currently potentially unfriendly, most notably float3 and float6.
#we are going to convert all numbers into strings, and make them valid c identifiers. Skip anything that is already a string.
def string_from_number(val, type):
if type in {'float', 'float3', 'float6', 'float_array'}:
return str(float(val))+'f'
elif type == 'double':
return str(float(val))
elif type in {'int', 'int_array', 'boolean'}:
return str(int(val))
else:
print("Warning: Unrecognized type or value with type", type, "and value", val)
print("Returning val unchanged.")
return val
#note that there is a very interesting little hack heere.
#Since the second key of every tuple is a dict, it's possible that we're marking up a property we've already marked up.
#Problem: if we just do dict(foo), and later nest dicts, we'll have hard-to-find problems.
#solution: mark the properties as we normalize them.
for propkey, propid, propinfo in joined_properties:
if propinfo.get('normalized', False):
continue
if propinfo['type'] == 'boolean':
propinfo['range'] = [0, 1]
if propinfo['type'] == 'int' and propinfo.get('read_only', False):
propinfo['range'] = [0, 0]
if propinfo['type'] == 'float' and propinfo.get('read_only', False):
propinfo['range'] = [0.0, 0.0]
if propinfo['type'] == 'double' and propinfo.get('read_only', False):
propinfo['range'] = [0.0, 0.0]
#Some int arrays are arrays of enums, i.e. FDN filter types.
if propinfo['type'] in {'int', 'int_array'} and not propinfo.get('read_only', False) and 'value_enum' in propinfo:
e = all_info['constants_by_enum'][propinfo['value_enum']]
r1 = min(e.values())
r2 = max(e.values())
propinfo['range'] = [r1, r2]
if propinfo['type'] == 'int' and propinfo.get('default', None) in all_info['constants']:
propinfo['default'] = all_info['constants'][propinfo['default']]
if propinfo.get('range', None) =='dynamic':
propinfo['range'] = [0, 0]
propinfo['is_dynamic'] = True
for i, j in enumerate(list(propinfo.get('range', []))): #if we don't have a range, this will do nothing.
if isinstance(j, str):
continue #it's either MIN_INT, MAX_INT, INFINITY, -INFINITY, or another special identifier. Pass through unchanged.
#we're not worried about float3 or float6 logic, because those aren't allowed to have traditional ranges at the moment-so this is it:
propinfo['range'][i] = string_from_number(j, propinfo['type'])
#Some array properties (see the feedback delay network) are controlled completely by their constructor.
#If this is the case, we need to give it some defaults so that the generated cpp file doesn't explode.
#The constructor later updates this information.
if propinfo['type'] in {'int_array', 'float_array'} and propinfo.get('dynamic_array', False):
propinfo['min_length'] = propinfo.get('min_length', 1)
propinfo['max_length'] = propinfo.get('max_length', 1)
#This string is handled later; we need to be careful about the type here.
#No need to duplicate code we have to do in a minute anyway.
propinfo['default'] = propinfo.get('default', 'zeros')
propinfo['range'] = propinfo.get('range', ['MIN_INT', 'MAX_INT'] if propinfo['type'] == 'int_array' else ['-INFINITY', 'INFINITY'])
#Default handling logic. If we don't have one and are int, float, or double we make it 0.
if propinfo['type'] in {'int', 'float', 'double'}:
propinfo['default'] = string_from_number(propinfo.get('default', 0), propinfo['type'])
#otherwise, if we're one of the array types, we do a loop for the same behavior.
elif propinfo['type'] in {'float3', 'float6'}:
for i, j in enumerate(list(propinfo.get('default', [0, 0, 0] if propinfo['type'] == 'float3' else [0, 0, 0, 0, 0, 0]))):
propinfo['default'][i] = string_from_number(j, propinfo['type'])
elif propinfo['type'] in {'int_array', 'float_array'}:
#As a special case, we allow the default heere to be the string "zeros".
if propinfo.get('default', None) == "zeros":
length = int(propinfo['min_length'])
propinfo['default'] = [0.0]*length
if propinfo['type'] == 'float_array':
propinfo['default'] = [int(i) for i in propinfo['default']]
for i, j in enumerate(list(propinfo.get('default', []))):
propinfo['default'][i] = string_from_number(j, propinfo['type'])
propinfo['normalized'] = True
#Sorting these makes sure maybe-write always gets the same thing.
joined_properties.sort()
joined_events.sort()
#do the render, and write to the file specified on the command line.
context = {
'joined_properties': joined_properties,
'joined_events': joined_events,
}
context.update(all_info)
template = environment.get_template('metadata.t')
result = template.render(context)
if not os.path.exists(os.path.split(os.path.abspath(sys.argv[1]))[0]):
os.makedirs(os.path.split(os.path.abspath(sys.argv[1]))[0])
maybe_write(sys.argv[1], result)
| zaolij/libaudioverse | metadata/metadata.py | Python | gpl-3.0 | 7,800 |
"""
modified from the original idea on inventingwithpython.com
added parsing of a web-page for a list of animals, as a proof of concept
built in stages with prompting by Y10 pupils
"""
from html.parser import HTMLParser
import urllib.request
import random
HANGMANPICS = ["""
+---+
| |
|
|
|
|
=========""", """
+---+
| |
O |
|
|
|
=========""", """
+---+
| |
O |
| |
|
|
=========""", """
+---+
| |
O |
/| |
|
|
=========""", """
+---+
| |
O |
/|\ |
|
|
=========""", """
+---+
| |
O |
/|\ |
/ |
|
=========""", """
+---+
| |
O |
/|\ |
/ \ |
|
========="""]
""" This next part opens a web page that contains a large list of animals
and carefully strips out only the animal names, which it puts in the
/animals/ list for us to use as the random word to guess
"""
class MyHtmlParser(HTMLParser):
def handle_starttag(self, tag, attrs):
# print("Encountered a tag:", tag, "with attributes:", attrs)
if tag == "a":
# print(tag, "=>", attrs)
if attrs[0][0] == "href" and \
attrs[0][1].startswith("/animals/") and \
not attrs[0][1].startswith("/animals/pictures/") and \
len(attrs[0][1]) > 9 and \
attrs[0][1][9:-1] not in ["scientific", "group", "location", "endangered", "favourites"]:
# print(attrs[0][1], attrs[1][1].lower())
animals.append(attrs[1][1].lower())
animals = []
parser = MyHtmlParser()
with urllib.request.urlopen("http://a-z-animals.com/animals/") as url:
parser.feed(str(url.read(), "UTF-8"))
# print(animals)
def get_random_word(words):
return words[random.randint(0, len(words))]
def draw_hangman(missed_letters):
print(HANGMANPICS[len(missed_letters)])
def draw_current_word_state(secret_word, correct_letters, missed_letters):
# print part-filled secret word
print("")
for l in secret_word:
if l in correct_letters or not l.isalpha():
print(l, end=" ")
else:
print("_", end=" ")
# print reminder of missed guesses
print("\nOther guesses: ", end="")
for l in missed_letters:
print(l, end=" ")
print("\n")
def get_guess(correct_letters, missed_letters):
guess = input("Enter guess: ")
if guess.isalpha():
if not guess in correct_letters+missed_letters:
return guess
else:
print("You've already guessed that!")
else:
print("Invalid guess; try again!")
return get_guess(correct_letters, missed_letters)
def has_guessed_secret_word(secret_word, correct_letters):
has_guessed = True
for l in secret_word:
if not (l in correct_letters or not l.isalpha()):
has_guessed = False
return has_guessed
print("H A N G M A N")
missed_letters = ""
correct_letters = ""
secret_word = get_random_word(animals)
game_over = False
# print("(I chose a >>", secret_word, "<<)")
while not game_over:
draw_hangman(missed_letters)
draw_current_word_state(secret_word, correct_letters, missed_letters)
guess = get_guess(correct_letters, missed_letters)
if guess in secret_word:
correct_letters += guess
else:
missed_letters += guess
game_over = has_guessed_secret_word(secret_word, correct_letters) or \
len(missed_letters) == len(HANGMANPICS) - 1
draw_hangman(missed_letters)
draw_current_word_state(secret_word, correct_letters, missed_letters)
if has_guessed_secret_word(secret_word, correct_letters):
print("Yay! Well done, you guessed it!")
else:
print("Oh hard luck - maybe next time?")
print("BTW, I had picked \"", secret_word, "\"", sep="") | MrHarcombe/GCSEPythonExamples | Python/hangman.py | Python | mit | 3,900 |
"""
@author: Fabio Erculiani <lxnay@sabayon.org>
@contact: lxnay@sabayon.org
@copyright: Fabio Erculiani
@license: GPL-2
B{Entropy Updates Notification Applet (Magneto) UI components module}
"""
# System imports
import os
# Qt imports
from PyQt5.QtCore import QStringListModel
from PyQt5.QtWidgets import QHBoxLayout, QListView, QLabel, QWidget, \
QVBoxLayout, QPushButton
from PyQt5.QtGui import QIcon
# Entropy imports
from entropy.i18n import _
class AppletNoticeWindow(QWidget):
def __init__(self, controller):
super(AppletNoticeWindow, self).__init__()
self.__controller = controller
self.__pkglist = []
# setup widgets
self.__vbox_up = QVBoxLayout()
self.__critical_label = QLabel()
self.__critical_label.setWordWrap(True)
self.__list_model = QStringListModel()
self.__list_view = QListView()
self.__list_view.setModel(self.__list_model)
self.__vbox_up.addWidget(self.__critical_label)
self.__vbox_up.addWidget(self.__list_view)
# bottom buttons
self.__vbox = QVBoxLayout()
self.__vbox.addLayout(self.__vbox_up)
self.__button_hbox = QHBoxLayout()
self.__close_button = QPushButton(_("Close"))
self.__launch_pm_button = QPushButton(_("Launch Application Browser"))
self.__button_hbox.addWidget(self.__launch_pm_button)
self.__button_hbox.addWidget(self.__close_button)
self.__vbox.addLayout(self.__button_hbox)
self.setLayout(self.__vbox)
# set window settings
self.resize(400, 200)
self.setWindowTitle(_("Application updates"))
self.__close_button.clicked.connect(self.on_close)
self.__launch_pm_button.clicked.connect(self.on_pm)
def closeEvent(self, event):
"""
We don't want to kill the window, since the whole app will close
otherwise.
"""
event.ignore()
self.on_close()
def on_pm(self):
self.__controller.launch_package_manager()
def on_close(self):
self.__controller.trigger_notice_window()
def populate(self, pkg_data, critical_txt):
self.__list_model.setStringList(pkg_data)
self.__critical_label.setText(critical_txt)
self.__list_view.update()
| Sabayon/entropy | magneto/src/magneto/qt5/components.py | Python | gpl-2.0 | 2,329 |
# encoding: utf-8
#
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http:# mozilla.org/MPL/2.0/.
#
# Author: Kyle Lahnakoski (kyle@lahnakoski.com)
#
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import re
from pyLibrary import convert
from mo_logs import Log
from mo_dots import coalesce, Data
from mo_times.dates import Date
true = True
false = False
null = None
EMPTY_DICT = {}
def compile_expression(source):
"""
THIS FUNCTION IS ON ITS OWN FOR MINIMAL GLOBAL NAMESPACE
:param source: PYTHON SOURCE CODE
:return: PYTHON FUNCTION
"""
# FORCE MODULES TO BE IN NAMESPACE
_ = coalesce
_ = Date
_ = convert
_ = Log
_ = Data
_ = EMPTY_DICT
_ = re
output = None
exec """
def output(row, rownum=None, rows=None):
try:
return """ + source + """
except Exception as e:
Log.error("Problem with dynamic function {{func|quote}}", func= """ + convert.value2quote(source) + """, cause=e)
"""
return output
| klahnakoski/esReplicate | pyLibrary/queries/expression_compiler.py | Python | mpl-2.0 | 1,182 |
""" feather-format compat """
from distutils.version import LooseVersion
from pandas import DataFrame, RangeIndex, Int64Index
from pandas.compat import range
def _try_import():
# since pandas is a dependency of feather
# we need to import on first use
try:
import feather
except ImportError:
# give a nice error message
raise ImportError("the feather-format library is not installed\n"
"you can install via conda\n"
"conda install feather-format -c conda-forge\n"
"or via pip\n"
"pip install feather-format\n")
try:
feather.__version__ >= LooseVersion('0.3.1')
except AttributeError:
raise ImportError("the feather-format library must be >= "
"version 0.3.1\n"
"you can install via conda\n"
"conda install feather-format -c conda-forge"
"or via pip\n"
"pip install feather-format\n")
return feather
def to_feather(df, path):
"""
Write a DataFrame to the feather-format
Parameters
----------
df : DataFrame
path : string
File path
"""
if not isinstance(df, DataFrame):
raise ValueError("feather only support IO with DataFrames")
feather = _try_import()
valid_types = {'string', 'unicode'}
# validate index
# --------------
# validate that we have only a default index
# raise on anything else as we don't serialize the index
if not isinstance(df.index, Int64Index):
raise ValueError("feather does not support serializing {} "
"for the index; you can .reset_index()"
"to make the index into column(s)".format(
type(df.index)))
if not df.index.equals(RangeIndex.from_range(range(len(df)))):
raise ValueError("feather does not support serializing a "
"non-default index for the index; you "
"can .reset_index() to make the index "
"into column(s)")
if df.index.name is not None:
raise ValueError("feather does not serialize index meta-data on a "
"default index")
# validate columns
# ----------------
# must have value column names (strings only)
if df.columns.inferred_type not in valid_types:
raise ValueError("feather must have string column names")
feather.write_dataframe(df, path)
def read_feather(path):
"""
Load a feather-format object from the file path
.. versionadded 0.20.0
Parameters
----------
path : string
File path
Returns
-------
type of object stored in file
"""
feather = _try_import()
return feather.read_dataframe(path)
| mbayon/TFG-MachineLearning | venv/lib/python3.6/site-packages/pandas/io/feather_format.py | Python | mit | 2,938 |
import os
import json
from Tkinter import *
from ttk import *
from subprocess import Popen, PIPE
VERSION = "0.1"
# default config
CONFIG = dict(
settings=dict(
terminal="Terminal",
sshbin="/usr/bin/ssh",
window_width=400,
window_height=40,
item_display="%(host)s as user %(user)s"
),
hosts=[
dict(
host="host.example.com",
user="root",
title="use title instead of host; optional"
),
dict(
host="host2.example.com",
user="other_user",
),
]
)
class AppScript(object):
MAIN_SCRIPT = """
tell application "%(app)s"
%(prog)s
end tell
"""
def __init__(self, app):
self._app = app
def call(self, prog):
cmd = Popen(["osascript"], stdin=PIPE)
cmd.communicate(self.MAIN_SCRIPT % dict(
app=self._app,
prog=prog
))
class Terminal(object):
MAC_TERMINAL_SCRIPT = """
do script "%(sshbin)s %(host)s"
activate
"""
MAC_ITERM_SCRIPT = """
activate
set newterm to (make new terminal)
tell newterm
set newsession to (make new session)
tell newsession
exec command "%(sshbin)s %(host)s"
end tell
end tell
"""
def __init__(self):
self._app = CONFIG["settings"]["terminal"]
def ssh(self, host):
if sys.platform == 'darwin':
if self._app == "Terminal":
SCRIPT = self.MAC_TERMINAL_SCRIPT
elif self._app == "iTerm":
SCRIPT = self.MAC_ITERM_SCRIPT
else:
raise Exception("unknown terminal")
AppScript(app=self._app).call(SCRIPT % dict(sshbin=CONFIG["settings"]["sshbin"], host=host))
elif sys.platform.startswith("linux"):
if self._app == "Terminal":
CMD = "gnome-terminal"
else:
raise Exception("unknown linux terminal; 'Terminal' is the only supported linux terminal at the moment")
cmd = Popen([CMD, '-e', "%s %s" % (CONFIG["settings"]["sshbin"], host)])
cmd.communicate()
else:
raise Exception("unsupported platform")
class Hosts(Treeview):
def __init__(self, parent, **kwargs):
Treeview.__init__(self, parent, selectmode="browse", show="tree", **kwargs)
self.bind('<Double-Button-1>', self.call)
self.bind('<KeyRelease>', self.call)
self.column("#0", width=CONFIG["settings"]["window_width"] - 10)
def call(self, event=None):
""" execute the highlighted item
"""
if not event or event.type == "4" or event.keysym in ["Return", "KP_Enter"]:
host = self.focus()
Terminal().ssh(host)
def _select(self, direction):
select_item = self.focus() if self.focus() else self.get_children()[0]
i = self.index(select_item)
childs = self.get_children()
new_selected_item = childs[(i + direction) % len(childs)]
self.focus(new_selected_item)
self.selection_set(new_selected_item)
self.see(new_selected_item)
def select_next(self):
self._select(direction=1)
def select_prev(self):
self._select(direction=-1)
def add(self, obj):
""" add host item and select the first one
"""
title = obj["title"] if "title" in obj else obj["host"]
self.insert('', 'end', "%s@%s" % (obj["user"], obj["host"]), text=CONFIG["settings"]["item_display"] % dict(host=title, user=obj["user"]))
self.focus(self.get_children()[0])
self.selection_set(self.get_children()[0])
self["height"] = len(self.get_children()) if len(self.get_children()) <= 10 else 10
def clear(self):
for item in self.get_children():
self.delete(item)
class App(object):
def __init__(self, parent, std_message=""):
self.parent = parent
frame = Frame(parent)
frame.pack(padx=0, pady=5)
self.search = Entry(frame, width=int(CONFIG["settings"]["window_width"] / 8.3))
self.search.insert(0, std_message)
self.search.grid(row=0)
self.search.focus_force()
self.search.bind('<KeyRelease>', self.search_callback)
self.result = Hosts(frame)
self.result.grid(row=1)
self.result.grid_remove()
self.hosts = CONFIG["hosts"]
def quit(self):
sys.exit(0)
def search_callback(self, event=None):
if event.keysym == "Down":
self.result.select_next()
elif event.keysym == "Up":
self.result.select_prev()
elif event.keysym in ["Return", "KP_Enter"]:
self.result.call()
self.quit()
elif event.keysym == "Escape":
self.quit()
else:
# remove results
self.result.clear()
self.result.grid_remove()
# parse input
query = self.search.get().strip().split()
if not query:
# search is empty
center_window(self.parent)
return
# layout results
self.result.grid()
# search for query
for host in self.hosts:
field = host["host"]
if "title" in host:
field = host["title"]
if field.lower().find(query[0].lower()) > -1:
self.result.add(host)
# split query; first is host, second is use
host = query[0]
user = "root"
if len(query) > 1:
user = query[1]
# add query as host too
self.result.add({
"host": host,
"title": host,
"user": user,
})
# resize main window
window_height = CONFIG["settings"]["window_height"] + len(self.result.get_children()) * 20
if window_height > 230:
window_height = 230
center_window(self.parent, height=window_height)
def center_window(root, width=None, height=None):
if not width:
width = CONFIG["settings"]["window_width"]
if not height:
height = CONFIG["settings"]["window_height"]
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# center the window
x = int(screen_width / 2 - width / 2)
y = int(screen_height / 4)
root.geometry('%dx%d+%d+%d' % (width, height, x, y))
def main():
CFG = os.path.join(os.environ["HOME"], ".quick_ssh.json")
global CONFIG
if not os.path.exists(CFG):
# write default config file
open(CFG, "w").write(json.dumps(CONFIG, indent=2))
error_msg = ""
try:
CONFIG = json.loads(open(CFG).read())
except:
# read config failed
error_msg = "unable to read config file; json decode error"
root = Tk()
root.title('QuickSSH')
root.resizable(0, 0)
center_window(root)
App(root, std_message=error_msg)
root.mainloop()
if __name__ == '__main__':
main()
| chassing/QuickSSH | quickssh/main.py | Python | mit | 6,381 |
"""Support for device connected via Lightwave WiFi-link hub."""
from lightwave.lightwave import LWLink
import voluptuous as vol
from homeassistant.const import CONF_HOST, CONF_LIGHTS, CONF_NAME, CONF_SWITCHES
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
LIGHTWAVE_LINK = "lightwave_link"
DOMAIN = "lightwave"
CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.Schema(
vol.All(
cv.has_at_least_one_key(CONF_LIGHTS, CONF_SWITCHES),
{
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_LIGHTS, default={}): {
cv.string: vol.Schema({vol.Required(CONF_NAME): cv.string})
},
vol.Optional(CONF_SWITCHES, default={}): {
cv.string: vol.Schema({vol.Required(CONF_NAME): cv.string})
},
},
)
)
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
"""Try to start embedded Lightwave broker."""
host = config[DOMAIN][CONF_HOST]
hass.data[LIGHTWAVE_LINK] = LWLink(host)
lights = config[DOMAIN][CONF_LIGHTS]
if lights:
hass.async_create_task(
async_load_platform(hass, "light", DOMAIN, lights, config)
)
switches = config[DOMAIN][CONF_SWITCHES]
if switches:
hass.async_create_task(
async_load_platform(hass, "switch", DOMAIN, switches, config)
)
return True
| leppa/home-assistant | homeassistant/components/lightwave/__init__.py | Python | apache-2.0 | 1,567 |
"""
Generators for geometric graphs.
"""
# Copyright (C) 2004-2008 by
# Aric Hagberg <hagberg@lanl.gov>
# Dan Schult <dschult@colgate.edu>
# Pieter Swart <swart@lanl.gov>
# All rights reserved.
# BSD license.
from __future__ import print_function
__author__ ="""Aric Hagberg (hagberg@lanl.gov)\nPieter Swart (swart@lanl.gov)"""
__all__ = ['random_geometric_graph']
import networkx
import random,sys
from functools import reduce
#---------------------------------------------------------------------------
# Random Geometric Graphs
#---------------------------------------------------------------------------
def random_geometric_graph(n, radius, create_using=None, repel=0.0, verbose=False, dim=2):
"""Random geometric graph in the unit cube.
Returned Graph has added attribute G.pos which is a
dict keyed by node to the position tuple for the node.
"""
if create_using is None:
G=networkx.Graph()
else:
G=create_using
G.clear()
G.name="Random Geometric Graph"
G.add_nodes_from([v for v in range(n)]) # add n nodes
# position them randomly in the unit cube in n dimensions
# but not any two within "repel" distance of each other
# pick n random positions
positions=[]
while(len(positions)< n):
pnew=[]
[pnew.append(random.random()) for i in range(0,dim)]
reject=False
# avoid existing nodes
if repel > 0.0 :
for pold in positions:
m2=map(lambda x,y: (x-y)**2, pold,pnew)
r2=reduce(lambda x, y: x+y, m2, 0.)
if r2 < repel**2 :
reject=True
print("rejecting", len(positions),pnew, file = sys.stderr)
break
if(reject):
reject=False
continue
if(verbose):
print("accepting", len(positions),pnew, file = sys.stderr)
positions.append(pnew)
# add positions to nodes
G.pos={}
for v in G.nodes():
G.pos[v]=positions.pop()
# connect nodes within "radius" of each other
# n^2 algorithm, oh well, should work in n dimensions anyway...
for u in G.nodes():
p1=G.pos[u]
for v in G.nodes():
if u==v: # no self loops
continue
p2=G.pos[v]
m2=map(lambda x,y: (x-y)**2, p1,p2)
r2=reduce(lambda x, y: x+y, m2, 0.)
if r2 < radius**2 :
G.add_edge(u,v)
return G
| rainest/dance-partner-matching | networkx/generators/geometric.py | Python | bsd-2-clause | 2,543 |
# -*- coding: utf-8 -*-
import logging
import cgi
import re
import widgets
from . import convs
from ..utils import cached_property
from collections import OrderedDict
from .perms import FieldPerm
logger = logging.getLogger(__name__)
__all__ = ['BaseField', 'Field', 'FieldBlock', 'FieldSet', 'FieldList', 'FileField']
class BaseField(object):
'''
Simple container class which ancestors represents various parts of Form.
Encapsulates converter, various fields attributes, methods for data
access control
'''
# obsolete parameters from previous versions
_obsolete = frozenset(['default', 'get_default', 'template', 'media',
'render_type', 'render', 'required'])
#: :class:`FieldPerm` instance determining field's access permissions.
#: Can be set by field inheritance or throught constructor.
perm_getter = FieldPerm()
# defaults
#: :class:`Converter` instance determining field's convertation method
conv = convs.Char()
#: :class:`Widget` instance determining field's render method
widget = widgets.TextInput
#: Unicode label of the field
label = None
#: Short description of the field
hint = None
def __init__(self, name, conv=None, parent=None, permissions=None, **kwargs):
if self._obsolete & set(kwargs):
raise TypeError(
'Obsolete parameters are used: {}'.format(
list(self._obsolete & set(kwargs))))
kwargs.update(
parent=parent,
name=name,
conv=(conv or self.conv)(field=self),
widget=(kwargs.get('widget') or self.widget)(field=self),
)
if permissions is not None:
kwargs['perm_getter'] = FieldPerm(permissions)
self._init_kwargs = kwargs
self.__dict__.update(kwargs)
def __call__(self, **kwargs):
'''
Creates current object's copy with extra constructor arguments passed.
'''
params = dict(self._init_kwargs, **kwargs)
return self.__class__(**params)
@property
def multiple(self):
return self.conv.multiple
@property
def env(self):
return self.parent.env
@property
def form(self):
return self.parent.form
@property
def input_name(self):
'''
Name of field's input element generated in account to possible
nesting of fields. The input name is to be used in templates as value
of Input (Select, etc) element's Name attribute and Label element's For
attribute.
'''
return self.parent.prefix + self.name
@property
def error(self):
'''
String description of validation error in this field during last accept.
`None` if there is no error.
'''
return self.form.errors.get(self.input_name)
@cached_property
def clean_value(self):
'''
Current field's converted value from form's python_data.
'''
# XXX cached_property is used only for set initial state
# this property should be set every time field data
# has been changed, for instance, in accept method
python_data = self.parent.python_data
if self.name in python_data:
return python_data[self.name]
return self.get_initial()
@property
def id(self):
if self.form.id:
# We use template names in list to replace, so we must use it here to
# insure unique IDs.
return '{}-{}'.format(self.form.id, self.input_name)
return self.input_name
def from_python(self, value):
return self.conv.from_python(value)
@cached_property
def permissions(self):
'''
Field's access permissions. By default, is filled from perm_getter.
'''
return self.perm_getter.get_perms(self)
@cached_property
def writable(self):
return 'w' in self.permissions
@cached_property
def readable(self):
return 'r' in self.permissions
@cached_property
def field_names(self):
return [self.name]
def load_initial(self, initial, raw_data):
value = initial.get(self.name, self.get_initial())
self.set_raw_value(raw_data,
self.from_python(value))
return {self.name: value}
def __repr__(self):
args = ', '.join([k+'='+repr(v)
for k, v in self._init_kwargs.items()
if k not in ['widget', 'conv', 'parent']])
return '{}({})'.format(self.__class__.__name__, args)
class Field(BaseField):
'''
Atomic field
'''
conv = convs.Char()
_null_value = ''
def get_initial(self):
if hasattr(self, 'initial'):
return self.initial
if self.multiple:
return []
return None
@property
def raw_value(self):
if self.multiple:
return self.form.raw_data.getall(self.input_name)
else:
return self.form.raw_data.get(self.input_name, '')
def set_raw_value(self, raw_data, value):
if self.multiple:
try:
del raw_data[self.input_name]
except KeyError:
pass
for v in value:
raw_data.add(self.input_name, v)
else:
raw_data[self.input_name] = value
def _check_value_type(self, values):
if not self.multiple:
values = [values]
for value in values:
if not isinstance(value, basestring):
self.form.errors[self.input_name] = 'Given value has incompatible type'
return False
return True
def accept(self):
'''Extracts raw value from form's raw data and passes it to converter'''
value = self.raw_value
if not self._check_value_type(value):
# XXX should this be silent or TypeError?
value = [] if self.multiple else self._null_value
self.clean_value = self.conv.accept(value)
return {self.name: self.clean_value}
class AggregateField(BaseField):
@property
def python_data(self):
'''Representation of aggregate value as dictionary.'''
try:
value = self.clean_value
except LookupError:
# XXX is this necessary?
value = self.get_initial()
return self.from_python(value)
class FieldSet(AggregateField):
'''
Container field aggregating a couple of other different fields
'''
conv = convs.Converter()
widget = widgets.FieldSetWidget()
fields = []
def __init__(self, name, conv=None, fields=None, **kwargs):
fields = fields if fields is not None else self.fields
if kwargs.get('parent'):
conv = (conv or self.conv)(field=self)
fields = [field(parent=self) for field in fields]
kwargs.update(
name=name,
conv=conv,
fields=fields,
)
BaseField.__init__(self, **kwargs)
@property
def prefix(self):
return self.input_name+'.'
def get_field(self, name):
names = name.split('.', 1)
for field in self.fields:
if isinstance(field, FieldBlock):
result = field.get_field(name)
if result is not None:
return result
if field.name == names[0]:
if len(names) > 1:
return field.get_field(names[1])
return field
return None
def get_initial(self):
field_names = sum([x.field_names for x in self.fields], [])
result = dict((name, self.get_field(name).get_initial())
for name in field_names)
return self.conv.accept(result, silent=True)
def set_raw_value(self, raw_data, value):
# fills in raw_data multidict, resulting keys are field's absolute names
assert isinstance(value, dict), \
'To set raw value on {!r} need dict, got {!r}'\
.format(self.input_name, value)
if not value:
# Field set can be optional
return
field_names = sum([x.field_names for x in self.fields], [])
for field_name in field_names:
subvalue = value[field_name]
field = self.get_field(field_name)
field.set_raw_value(raw_data, field.from_python(subvalue))
def accept(self):
'''
Accepts all children fields, collects resulting values into dict and
passes that dict to converter.
Returns result of converter as separate value in parent `python_data`
'''
result = dict(self.python_data)
for field in self.fields:
if field.writable:
result.update(field.accept())
else:
# readonly field
field.set_raw_value(self.form.raw_data,
field.from_python(result[field.name]))
self.clean_value = self.conv.accept(result)
return {self.name: self.clean_value}
class FieldBlock(FieldSet):
'''
Anonymous FieldSet, values of one are accepted as they are children
of FieldBlock's parent.
FieldBlock is used to logically organize fields and do validation
of group of fields without naming that group and without dedicating
result of accept to separate object.
'''
conv = convs.FieldBlockConv()
widget = widgets.FieldBlockWidget()
prefix = ''
def __init__(self, title, fields=[], **kwargs):
kwargs.update(
title=title,
fields=fields,
)
kwargs.setdefault('name', '') # XXX generate unique name
FieldSet.__init__(self, **kwargs)
@cached_property
def prefix(self):
return self.parent.prefix
def accept(self):
'''
Acts as `Field.accepts` but returns result of every child field
as value in parent `python_data`.
'''
result = FieldSet.accept(self)
self.clean_value = result[self.name]
return self.clean_value
def load_initial(self, initial, raw_data):
result = {}
for field in self.fields:
result.update(field.load_initial(initial, raw_data))
return result
@cached_property
def field_names(self):
result = []
for field in self.fields:
result += field.field_names
return result
@property
def python_data(self):
# we need only subfield values in python data
result = {}
for field_name in self.field_names:
if field_name in self.parent.python_data:
result[field_name] = self.parent.python_data[field_name]
return result
class FieldList(AggregateField):
'''
Container aggregating an ordered set of similar fields
'''
order = True
conv = convs.List()
widget = widgets.FieldListWidget()
_digit_re = re.compile('\d+$')
def __init__(self, name, conv=None, field=Field(None),
parent=None, **kwargs):
if parent:
conv = (conv or self.conv)(field=self)
field = field(parent=self)
kwargs.update(
parent=parent,
name=name,
conv=conv,
field=field,
)
BaseField.__init__(self, **kwargs)
@property
def prefix(self):
# NOTE: There was '-' instead of '.' and get_field('list-1') was broken
return self.input_name+'.'
def get_initial(self):
return []
def get_field(self, name):
names = name.split('.', 1)
if not self._digit_re.match(names[0]):
# XXX is this needed?
return None
field = self.field(name=names[0])
if len(names) > 1:
return field.get_field(names[1])
return field
@property
def indices_input_name(self):
return self.input_name+'-indices'
def accept(self):
old = self.python_data
result = OrderedDict()
for index in self.form.raw_data.getall(self.indices_input_name):
try:
#XXX: we do not convert index to int, just check it.
# is it good idea?
int(index)
except ValueError:
logger.warning('Got incorrect index from form: %r', index)
continue
#TODO: describe this
field = self.field(name=str(index))
if not field.writable:
# readonly field
if index in old:
result[field.name] = old[field.name]
else:
result.update(field.accept())
self.clean_value = self.conv.accept(result)
return {self.name: self.clean_value}
def set_raw_value(self, raw_data, value):
indices = []
for index in range(1, len(value)+1):
index = str(index)
subvalue = value[index]
subfield = self.field(name=index)
subfield.set_raw_value(raw_data, subfield.from_python(subvalue))
indices.append(index)
try:
del raw_data[self.indices_input_name]
except KeyError:
pass
for index in indices:
raw_data.add(self.indices_input_name, index)
class FileField(Field):
'''
The simpliest file field
'''
_null_value = None
conv = convs.SimpleFile()
def set_raw_value(self, raw_data, value):
pass
def _check_value_type(self, values):
if not self.multiple:
values = [values]
for value in values:
if value and \
not isinstance(value, cgi.FieldStorage) and \
not hasattr(value, 'read'): # XXX is this right?
self.form.errors[self.input_name] = 'Given value is not file'
return False
return True
| oas89/iktomi | iktomi/forms/fields.py | Python | mit | 14,070 |
# -*- coding: utf-8 -*-
#
# ncclient documentation build configuration file, created by
# sphinx-quickstart on Fri Sep 18 17:32:15 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.append(os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.ifconfig']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'ncclient'
copyright = u'2009, Shikhar Bhushan'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.2'
# The full version, including alpha/beta/rc tags.
release = '0.2a'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = []
# The reST default role (used for this markup: `text`) to use for all documents.
default_role = 'class'
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
modindex_common_prefix = ["ncclient."]
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "_static/logo.png"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_use_modindex = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'ncclientdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
latex_paper_size = 'a4'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'ncclient.tex', u'ncclient Documentation',
u'Shikhar Bhushan', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
latex_logo = "_static/logo.png"
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}
| travelping/ncclient | docs/source/conf.py | Python | apache-2.0 | 6,621 |
from django.contrib.contenttypes.models import ContentType
from django.utils import simplejson as json
from hyperadmin.mediatypes.json import JSON, JSONP
from common import MediaTypeTestCase
class JsonTestCase(MediaTypeTestCase):
def get_adaptor(self):
self.api_request = self.get_api_request()
return JSON(self.api_request)
def test_queryset_serialize(self):
endpoint = self.resource.endpoints['list']
endpoint = endpoint.fork(api_request=self.api_request)
link = endpoint.link_prototypes['list'].get_link()
state = endpoint.state
response = self.adaptor.serialize(content_type='application/json', link=link, state=state)
data = json.loads(response.content)
self.assertEqual(len(data), ContentType.objects.count())
def test_model_instance_serialize(self):
instance = ContentType.objects.all()[0]
endpoint = self.resource.endpoints['detail']
endpoint = endpoint.fork(api_request=self.api_request)
endpoint.state.item = item = endpoint.get_resource_item(instance)
link = item.get_link()
state = endpoint.state
response = self.adaptor.serialize(content_type='application/json', link=link, state=state)
data = json.loads(response.content)
assert data, str(data)
#self.assertEqual(len(json_items), 1)
class JsonpTestCase(MediaTypeTestCase):
def get_adaptor(self):
self.api_request = self.get_api_request(params={'callback':'jscallback'})
return JSONP(self.api_request)
def test_queryset_serialize(self):
endpoint = self.resource.endpoints['list']
endpoint = endpoint.fork(api_request=self.api_request)
link = endpoint.link_prototypes['list'].get_link()
state = endpoint.state
response = self.adaptor.serialize(content_type='text/javascript', link=link, state=state)
self.assertTrue(response.content.startswith('jscallback('))
#data = json.loads(response.content)
#self.assertEqual(len(data), len(items))
def test_model_instance_serialize(self):
instance = ContentType.objects.all()[0]
endpoint = self.resource.endpoints['detail']
endpoint = endpoint.fork(api_request=self.api_request)
endpoint.state.item = item = endpoint.get_resource_item(instance)
link = item.get_link()
state = endpoint.state
response = self.adaptor.serialize(content_type='text/javascript', link=link, state=state)
self.assertTrue(response.content.startswith('jscallback('))
#data = json.loads(response.content)
#assert data, str(data)
#self.assertEqual(len(json_items), 1)
| zbyte64/django-hyperadmin | hyperadmin/tests/mediatypes/test_json.py | Python | bsd-3-clause | 2,803 |
'''The pdp.portals.bc_prism module configures a raster portal to serve
the 1971-2000 and 1981-2010 climatologies and monthly climate data for
800 meter resolution PRISM dataset for BC
'''
from pdp.portals import make_raster_frontend, data_server
from pdp_util.ensemble_members import EnsembleMemberLister
__all__ = ['url_base', 'mk_frontend', 'mk_backend']
ensemble_name = 'bc_prism_monthly_and_climos'
url_base = '/bc_prism'
title = 'High-Resolution PRISM Data'
def resolution_name(time_resolution):
return time_resolution.capitalize()
class PrismEnsembleLister(EnsembleMemberLister):
def list_stuff(self, ensemble):
"""
Yield a sequence of tuples describing the files in the named ensemble.
:param ensemble: Ensemble name
:yield: sequence of same-length tuples
Called by web service endpoint; see pdp_util.ensemble_members.
Results (a sequence of tuples) are turned into a nested dict,
with the key levels, from shallowest to deepest, corresponding to each
tuple element from 0 through the second-last. The last element
is the value of the deepest key.
Existing code in pdp_util (unnecessarily) imposes the constraint that
all tuples must be of the same length. Therefore the tuples generated
for the two cases here (climatology, time series) must be the same
length.
"""
for dfv in ensemble.data_file_variables:
df = dfv.file
timeset = df.timeset
if timeset.multi_year_mean:
descriptors = (
"Climatological averages {}-{}".format(
timeset.start_date.year, timeset.end_date.year
),
"{} means".format(resolution_name(timeset.time_resolution))
)
else:
descriptors = (
"Timeseries {}-{}".format(
timeset.start_date.year, timeset.end_date.year
),
resolution_name(timeset.time_resolution)
)
stuff = (
descriptors
+ (
dfv.netcdf_variable_name,
df.unique_id.replace('+', '-')
)
)
# print "PrismEnsembleLister: yielding {}".format(stuff)
yield stuff
def mk_frontend(config):
return make_raster_frontend(
config,
ensemble_name,
url_base,
title,
PrismEnsembleLister,
[
'js/prism_demo_map.js',
'js/prism_demo_controls.js',
'js/prism_demo_app.js',
'js/prism_demo_config.js',
]
)
def mk_backend(config):
return data_server(config, ensemble_name)
| pacificclimate/pdp | pdp/portals/bc_prism.py | Python | gpl-3.0 | 2,824 |
'''
Copyright (c) 2012 Dustin Frisch <fooker@lab.sh>,
Sven Reissmann <sven@0x80.io>
This file is part of the PyTgen traffic generator.
PyTgen is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyTgen is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyTgen. If not, see <http://www.gnu.org/licenses/>.
'''
import datetime
import threading
import heapq
import random
import logging
class scheduler(threading.Thread):
class job(object):
def __init__(self, name, action, interval, start, end):
self.__name = name
self.__action = action
self.__interval = interval
self.__start = start
self.__end = end
self.__exec_time = datetime.datetime.now() + datetime.timedelta(seconds = self.__interval[1] * random.random(),
minutes = self.__interval[0] * random.random())
def __call__(self):
today = datetime.datetime.now()
start = today.replace(hour = self.__start[0],
minute = self.__start[1],
second = 0, microsecond = 0)
end = today.replace(hour = self.__end[0],
minute = self.__end[1],
second = 0, microsecond = 0)
if start <= self.__exec_time < end:
# enqueue job for "random() * 2 * interval"
# in average the job will run every interval but differing randomly
self.__exec_time += datetime.timedelta(seconds = self.__interval[1] * random.random() * 2,
minutes = self.__interval[0] * random.random() * 2)
if self.__exec_time < datetime.datetime.now():
logging.getLogger("scheduler").warning('scheduler is overloaded!')
return self.__action
else:
# enqueue the job until next start time
if self.__exec_time < start and self.__exec_time.day == start.day:
self.__exec_time = start + datetime.timedelta(seconds = 1)
else:
self.__exec_time = start + datetime.timedelta(days = 1)
logging.getLogger("scheduler").info("enqueueing %s until %s",
self.__name, self.__exec_time)
return False
def __lt__(self, other):
if type(other) == scheduler.job:
return self.__exec_time < other.__exec_time
elif type(other) == datetime.datetime:
return self.__exec_time < other
else:
raise
def __sub__(self, other):
if type(other) == scheduler.job:
return self.__exec_time - other.__exec_time
elif type(other) == datetime.datetime:
return self.__exec_time - other
else:
raise
def __init__(self, jobs, runner):
threading.Thread.__init__(self)
self.setName('scheduler');
self.__runner = runner
self.__jobs = jobs
heapq.heapify(self.__jobs)
self.__running = False
self.__signal = threading.Condition()
def run(self):
self.__running = True
while self.__running:
self.__signal.acquire()
if not self.__jobs:
self.__signal.wait()
else:
now = datetime.datetime.now()
while (self.__jobs[0] < now):
job = heapq.heappop(self.__jobs)
action = job()
if action is not False:
self.__runner(action)
heapq.heappush(self.__jobs, job)
logging.getLogger("scheduler").debug("Sleeping %s seconds", (self.__jobs[0] - now))
self.__signal.wait((self.__jobs[0] - now).total_seconds())
self.__signal.release()
def stop(self):
self.__running = False
self.__signal.acquire()
self.__signal.notify_all()
self.__signal.release()
def set_jobs(self, jobs):
self.__signal.acquire()
self.__jobs = jobs
heapq.heapify(self.__jobs)
self.__signal.notify_all()
self.__signal.release()
| reissmann/PyTgen | core/scheduler.py | Python | gpl-3.0 | 4,853 |
from api.decorators import api_view, request_data_nodc
from api.permissions import IsSuperAdmin, IsSuperAdminOrReadOnly
from api.dc.base.dc_view import DcView
from api.dc.base.dc_settings import DcSettingsView
__all__ = ('dc_list', 'dc_manage', 'dc_settings')
@api_view(('GET',))
@request_data_nodc(permissions=(IsSuperAdminOrReadOnly,))
def dc_list(request, data=None):
"""
List (:http:get:`GET </dc>`) available Datacenters.
.. http:get:: /dc
:DC-bound?:
* |dc-yes|
:Permissions:
:Asynchronous?:
* |async-no|
:arg data.full: Return list of objects with all DC details (default: false)
:type data.full: boolean
:arg data.extended: Return list of objects with extended DC details \
(default: false, requires |SuperAdmin| permission)
:type data.extended: boolean
:arg data.order_by: :ref:`Available fields for sorting <order_by>`: ``name``, ``created`` (default: ``name``)
:type data.order_by: string
:status 200: SUCCESS
:status 403: Forbidden
"""
return DcView(request, None, data).get(many=True)
@api_view(('GET', 'POST', 'PUT', 'DELETE'))
@request_data_nodc(permissions=(IsSuperAdminOrReadOnly,))
def dc_manage(request, dc, data=None):
"""
Show (:http:get:`GET </dc/(dc)>`), create (:http:post:`POST </dc/(dc)>`),
change (:http:put:`PUT </dc/(dc)>`) or delete (:http:delete:`DELETE </dc/(dc)>`) a virtual datacenter.
.. http:get:: /dc/(dc)
:DC-bound?:
* |dc-yes|
:Permissions:
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:arg data.extended: Display extended DC details (default: false, requires |SuperAdmin| permission)
:type data.extended: boolean
:status 200: SUCCESS
:status 403: Forbidden
:status 404: Datacenter not found
.. http:post:: /dc/(dc)
:DC-bound?:
* |dc-yes|
:Permissions:
* |SuperAdmin|
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:arg data.site: **required** - Hostname part of the browsing URL that determines the current working \
datacenter for an anonymous user; You will need a working DNS record with the same hostname pointing to your \
Danube Cloud management portal
:type data.site: string
:arg data.alias: Short datacenter name (default: ``name``)
:type data.alias: string
:arg data.access: Access type (1 - Public, 3 - Private) (default: 3)
:type data.access: integer
:arg data.owner: User that owns the Datacenter (default: logged in user)
:type data.owner: string
:arg data.groups: List of user groups (default: [])
:type data.groups: array
:arg data.desc: Datacenter description
:type data.desc: string
:status 201: SUCCESS
:status 400: FAILURE
:status 403: Forbidden
:status 406: Datacenter already exists
.. http:put:: /dc/(dc)
:DC-bound?:
* |dc-yes|
:Permissions:
* |SuperAdmin|
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:arg data.site: Hostname part of the browsing URL that determines the current working \
datacenter for an anonymous user; You will need a working DNS record with the same hostname pointing to your \
Danube Cloud management portal
:type data.site: string
:arg data.alias: Short datacenter name
:type data.alias: string
:arg data.access: Access type (1 - Public, 3 - Private)
:type data.access: integer
:arg data.owner: User that owns the Datacenter
:type data.owner: string
:arg data.groups: List of user groups
:type data.groups: array
:arg data.desc: Datacenter description
:type data.desc: string
:status 200: SUCCESS
:status 400: FAILURE
:status 403: Forbidden
:status 404: Datacenter not found
.. http:delete:: /dc/(dc)
:DC-bound?:
* |dc-yes|
:Permissions:
* |SuperAdmin|
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:status 200: SUCCESS
:status 400: FAILURE
:status 403: Forbidden
:status 404: Datacenter not found
:status 428: Datacenter has nodes / Datacenter has VMs / Default datacenter cannot be deleted
"""
return DcView(request, dc, data).response()
@api_view(('GET', 'PUT'))
@request_data_nodc(permissions=(IsSuperAdmin,))
def dc_settings(request, dc, data=None):
"""
Show (:http:get:`GET </dc/(dc)/settings>`) or update (:http:put:`PUT </dc/(dc)/settings>`)
settings of a virtual datacenter.
.. note:: Global settings can only be changed from the main data center.
.. http:get:: /dc/(dc)/settings
:DC-bound?:
* |dc-yes|
:Permissions:
* |SuperAdmin|
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:status 200: SUCCESS
:status 403: Forbidden
:status 404: Datacenter not found
.. http:put:: /dc/(dc)/settings
:DC-bound?:
* |dc-yes|
:Permissions:
* |SuperAdmin|
:Asynchronous?:
* |async-no|
:arg dc: **required** - Datacenter name
:type dc: string
:arg data.<setting_name>: See example below for current list of settings and \
consult the user guide for more information
:status 200: SUCCESS
:status 400: FAILURE
:status 403: Forbidden
:status 404: Datacenter not found
"""
return DcSettingsView(request, dc, data).response()
| erigones/esdc-ce | api/dc/base/views.py | Python | apache-2.0 | 5,970 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.