#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char letter[ 256 ] ;
struct T {
struct T * next[ 26 ] ;
int end;
} ;
struct V {
char pbuf[ 80 ] ;
char kbuf[ 80 ] ;
char cbuf[ 80 ] ;
int n;
} ;
void tadd( struct T ** t, const char * str)
{
int s = * str++;
int c = letter[ ( unsigned char ) s] ;
if ( s && c < 0 ) return ;
if ( * t == NULL) {
}
if ( s == 0 ) {
( * t) -> end = 1 ;
} else {
tadd( & ( * t) -> next[ c] , str) ;
}
}
void tdestroy( struct T * t)
{
if ( t) {
for ( int i = 0 ; i < 26 ; i++ ) {
tdestroy( t-> next[ i] ) ;
}
}
}
void tprint( struct T * t, char * buf, int n)
{
if ( t) {
if ( t
-> end
) printf ( "%.*s\n " , n
, buf
) ;
for ( int i = 0 ; i < 26 ; i++ ) {
if ( t-> next[ i] ) {
buf[ n] = 'a' + i;
tprint( t-> next[ i] , buf, n + 1 ) ;
}
}
}
}
void fill( char grid[ 3 ] [ 5 ] , struct T * a[ ] , struct T * d[ ] , int n) ;
void filld( char grid[ 3 ] [ 5 ] , struct T * a[ ] , struct T * d[ ] , int n, int k)
{
if ( k == 5 ) {
fill( grid, a, d, n + 1 ) ;
} else {
int c;
for ( c = 0 ; c < 26 ; c++ ) {
if ( d[ n] -> next[ c] && a[ k] -> next[ c] ) {
struct T * dd = d[ n] ;
struct T * aa = a[ k] ;
d[ n] = d[ n] -> next[ c] ;
a[ k] = a[ k] -> next[ c] ;
grid[ n] [ k] = 'A' + c;
filld( grid, a, d, n, k + 1 ) ;
d[ n] = dd;
a[ k] = aa;
}
}
}
}
void print5( const char * s)
{
int n = 5 ;
while ( n-- ) {
}
}
void fill( char grid[ 3 ] [ 5 ] , struct T * a[ ] , struct T * d[ ] , int n)
{
if ( n == 3 ) {
print5( grid[ 0 ] ) ;
print5( grid[ 1 ] ) ;
print5( grid[ 2 ] ) ;
} else {
filld( grid, a, d, n, 0 ) ;
}
}
// Source: 5-letter words from Scowl's 10-percentile English words
const char * d5[ ] = {
"about" , "above" , "abuse" , "acted" , "added" , "admit" , "adopt" , "after" ,
"again" , "agree" , "ahead" , "aimed" , "alarm" , "album" , "alias" , "alive" ,
"allow" , "alone" , "along" , "alter" , "amuse" , "angle" , "angry" , "annoy" ,
"apart" , "apple" , "apply" , "areas" , "argue" , "arise" , "aside" , "asked" ,
"avoid" , "awake" , "award" , "aware" , "awful" , "backs" , "badly" , "based" ,
"bases" , "basic" , "basis" , "bears" , "began" , "begin" , "begun" , "being" ,
"below" , "binds" , "bites" , "black" , "blame" , "blank" , "block" , "board" ,
"books" , "borne" , "bound" , "boxes" , "brand" , "break" , "brief" , "bring" ,
"broke" , "brown" , "build" , "built" , "bytes" , "calls" , "cards" , "cares" ,
"carry" , "cases" , "catch" , "cause" , "cease" , "chain" , "chair" , "chaos" ,
"chars" , "cheap" , "check" , "child" , "chips" , "chose" , "claim" , "class" ,
"clean" , "clear" , "clock" , "close" , "coded" , "codes" , "comes" , "costs" ,
"could" , "count" , "court" , "cover" , "crash" , "crazy" , "crisp" , "cross" ,
"cycle" , "daily" , "dated" , "dates" , "datum" , "deals" , "dealt" , "death" ,
"deems" , "delay" , "depth" , "digit" , "dirty" , "discs" , "ditto" , "doing" ,
"doors" , "doubt" , "dozen" , "drawn" , "draws" , "dream" , "drink" , "drive" ,
"drops" , "drove" , "dying" , "early" , "earth" , "eaten" , "edits" , "eight" ,
"elect" , "empty" , "ended" , "enemy" , "enjoy" , "enter" , "entry" , "equal" ,
"error" , "evens" , "event" , "every" , "exact" , "exist" , "extra" , "facts" ,
"fails" , "faith" , "falls" , "false" , "fancy" , "fatal" , "fault" , "feeds" ,
"feels" , "fewer" , "field" , "fight" , "filed" , "files" , "fills" , "final" ,
"finds" , "first" , "fixed" , "fixes" , "flash" , "flied" , "flies" , "float" ,
"floor" , "flown" , "folks" , "force" , "forms" , "forth" , "found" , "frame" ,
"fresh" , "fries" , "front" , "fully" , "funds" , "funny" , "gains" , "games" ,
"given" , "gives" , "glass" , "going" , "goods" , "grand" , "grant" , "graph" ,
"grave" , "great" , "green" , "grind" , "gross" , "group" , "grown" , "grows" ,
"guard" , "guess" , "guide" , "habit" , "hands" , "handy" , "hangs" , "happy" ,
"heads" , "heard" , "hears" , "heart" , "heavy" , "hello" , "helps" , "hence" ,
"hides" , "hints" , "holds" , "holes" , "hoped" , "hopes" , "horse" , "hotel" ,
"hours" , "house" , "human" , "hurry" , "ideal" , "ideas" , "image" , "imply" ,
"index" , "inner" , "input" , "issue" , "items" , "joins" , "joint" , "judge" ,
"jumps" , "keeps" , "kills" , "kinds" , "knock" , "known" , "knows" , "label" ,
"lacks" , "lands" , "large" , "lasts" , "later" , "leach" , "leads" , "learn" ,
"least" , "leave" , "legal" , "level" , "light" , "liked" , "likes" , "limit" ,
"lines" , "links" , "lists" , "lived" , "lives" , "loads" , "local" , "locks" ,
"logic" , "looks" , "loose" , "lorry" , "loses" , "lower" , "lucky" , "lunch" ,
"lying" , "magic" , "major" , "makes" , "march" , "marks" , "marry" , "match" ,
"maybe" , "means" , "meant" , "media" , "meets" , "merit" , "messy" , "metal" ,
"might" , "miles" , "minds" , "minor" , "mixed" , "mixes" , "model" , "money" ,
"month" , "moral" , "mouth" , "moved" , "moves" , "movie" , "music" , "naive" ,
"named" , "names" , "nasty" , "needs" , "never" , "nicer" , "night" , "noise" ,
"noisy" , "north" , "noted" , "notes" , "novel" , "occur" , "offer" , "often" ,
"older" , "omits" , "opens" , "order" , "other" , "ought" , "outer" , "owing" ,
"owner" , "pages" , "pairs" , "paper" , "parts" , "party" , "patch" , "pause" ,
"payed" , "peace" , "phase" , "phone" , "picks" , "piece" , "place" , "plain" ,
"plane" , "plans" , "plant" , "plays" , "plots" , "point" , "posts" , "pound" ,
"power" , "press" , "price" , "prime" , "print" , "prior" , "prone" , "proof" ,
"prove" , "pulls" , "putts" , "queue" , "quick" , "quiet" , "quite" , "quits" ,
"quote" , "radio" , "raise" , "range" , "rapid" , "rates" , "reach" , "react" ,
"reads" , "ready" , "refer" , "reply" , "right" , "river" , "rooms" , "rough" ,
"round" , "route" , "rules" , "sadly" , "safer" , "saint" , "sales" , "saved" ,
"saves" , "scale" , "scene" , "score" , "scrap" , "seeks" , "seems" , "sells" ,
"sends" , "sense" , "serve" , "seven" , "shall" , "shame" , "shape" , "share" ,
"sharp" , "sheet" , "shelf" , "shell" , "shift" , "shoot" , "shops" , "short" ,
"shown" , "shows" , "shuts" , "sides" , "sight" , "signs" , "silly" , "since" ,
"sites" , "sizes" , "skill" , "sleep" , "small" , "smile" , "solid" , "solve" ,
"sorry" , "sorts" , "sound" , "south" , "space" , "spare" , "speak" , "speed" ,
"spell" , "spend" , "spent" , "spite" , "split" , "spoke" , "spots" , "staff" ,
"stage" , "stand" , "start" , "state" , "stays" , "steal" , "stick" , "still" ,
"stock" , "stone" , "stood" , "stops" , "store" , "story" , "stuck" , "study" ,
"stuff" , "style" , "sugar" , "suits" , "table" , "taken" , "takes" , "talks" ,
"tanks" , "tapes" , "tasks" , "taste" , "teach" , "teeth" , "tells" , "tends" ,
"terms" , "tests" , "thank" , "their" , "there" , "these" , "thing" , "think" ,
"third" , "those" , "three" , "threw" , "throw" , "tight" , "timed" , "times" ,
"title" , "today" , "token" , "tooth" , "topic" , "total" , "touch" , "trace" ,
"track" , "train" , "traps" , "trash" , "treat" , "trees" , "trial" , "trick" ,
"tried" , "tries" , "truck" , "truly" , "trunk" , "trust" , "truth" , "turns" ,
"twice" , "tying" , "typed" , "types" , "under" , "unite" , "units" , "until" ,
"upper" , "upset" , "usage" , "users" , "using" , "usual" , "vague" , "valid" ,
"value" , "video" , "views" , "visit" , "vital" , "voice" , "votes" , "waits" ,
"walks" , "walls" , "wants" , "warns" , "waste" , "watch" , "water" , "wears" ,
"weeks" , "weird" , "wheel" , "where" , "which" , "while" , "white" , "whole" ,
"whose" , "wider" , "wills" , "woman" , "words" , "works" , "world" , "worry" ,
"worse" , "worst" , "worth" , "would" , "write" , "wrong" , "wrote" , "years" ,
"young" , "yours" , NULL
} ;
// Source: 3-letter words from Scowl's 20-percentile English words
const char * d3[ ] = {
"ace" , "act" , "add" , "age" , "ago" , "aid" , "aim" , "air" , "all" , "and" , "any" ,
"apt" , "arc" , "are" , "arm" , "art" , "ash" , "ask" , "ate" , "bad" , "bag" , "ban" ,
"bar" , "bat" , "bay" , "bed" , "beg" , "bet" , "bid" , "big" , "bin" , "bit" , "bob" ,
"bog" , "bow" , "box" , "boy" , "bug" , "bus" , "but" , "buy" , "bye" , "cam" , "can" ,
"cap" , "car" , "cat" , "con" , "cow" , "cry" , "cue" , "cup" , "cut" , "day" , "did" ,
"die" , "dig" , "dim" , "dip" , "doe" , "dog" , "don" , "dot" , "dry" , "due" , "dug" ,
"ear" , "eat" , "egg" , "ego" , "end" , "era" , "err" , "eye" , "fan" , "far" , "fat" ,
"fed" , "fee" , "few" , "fit" , "fix" , "fly" , "fog" , "for" , "fry" , "fun" , "fur" ,
"gap" , "gas" , "gay" , "get" , "gig" , "gin" , "god" , "got" , "gum" , "gun" , "gut" ,
"guy" , "had" , "ham" , "has" , "hat" , "hay" , "her" , "hid" , "him" , "hip" , "his" ,
"hit" , "hog" , "hot" , "how" , "huh" , "hum" , "hut" , "ice" , "ill" , "ink" , "ion" ,
"its" , "jam" , "jet" , "job" , "joy" , "ken" , "key" , "kid" , "kit" , "lab" , "lad" ,
"lag" , "law" , "lay" , "led" , "leg" , "let" , "lid" , "lie" , "lip" , "lit" , "log" ,
"lot" , "low" , "mad" , "man" , "map" , "may" , "men" , "met" , "mix" , "mob" , "mod" ,
"mud" , "mug" , "mum" , "nay" , "net" , "new" , "nil" , "nor" , "not" , "now" , "nun" ,
"nut" , "oar" , "odd" , "off" , "oil" , "old" , "one" , "opt" , "our" , "out" , "owe" ,
"own" , "pad" , "pan" , "par" , "pat" , "pay" , "pen" , "per" , "pet" , "pie" , "pig" ,
"pin" , "pit" , "pop" , "pot" , "pro" , "pub" , "pun" , "put" , "rag" , "ram" , "ran" ,
"rat" , "raw" , "ray" , "red" , "rid" , "rip" , "rod" , "rot" , "row" , "rub" , "run" ,
"sad" , "sat" , "saw" , "say" , "sea" , "see" , "set" , "sex" , "she" , "shy" , "sic" ,
"sin" , "sir" , "sit" , "six" , "sky" , "sod" , "son" , "spy" , "sue" , "sum" , "sun" ,
"tab" , "tag" , "tap" , "tax" , "tea" , "ten" , "the" , "tie" , "tin" , "tip" , "toe" ,
"ton" , "too" , "top" , "toy" , "try" , "two" , "use" , "van" , "vat" , "vet" , "via" ,
"war" , "was" , "way" , "wed" , "wee" , "wet" , "who" , "why" , "win" , "wit" , "won" ,
"yes" , "yet" , "you" , NULL
} ;
int main( )
{
struct T * w3 = NULL;
struct T * w5 = NULL;
const char ** p;
int i;
memset ( letter
, - 1 , sizeof ( letter
) ) ;
for ( i = 0 ; i < 26 ; i++ ) {
letter[ 'a' + i] = i;
letter[ 'A' + i] = i;
}
p = d3;
while ( * p) tadd( & w3, * p++ ) ;
p = d5;
while ( * p) tadd( & w5, * p++ ) ;
if ( 1 ) {
char grid[ 3 ] [ 5 ] ;
struct T * a[ 5 ] = { w3, w3, w3, w3, w3} ;
struct T * d[ 3 ] = { w5, w5, w5} ;
fill( grid, a, d, 0 ) ;
}
tdestroy( w3) ;
tdestroy( w5) ;
return 0 ;
}
CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmNoYXIgbGV0dGVyWzI1Nl07CgpzdHJ1Y3QgVCB7CiAgICBzdHJ1Y3QgVCAqbmV4dFsyNl07CiAgICBpbnQgZW5kOwp9OwoKc3RydWN0IFYgewogICAgY2hhciBwYnVmWzgwXTsKICAgIGNoYXIga2J1Zls4MF07CiAgICBjaGFyIGNidWZbODBdOwogICAgaW50IG47Cn07Cgp2b2lkIHRhZGQoc3RydWN0IFQgKip0LCBjb25zdCBjaGFyICpzdHIpCnsKICAgIGludCBzID0gKnN0cisrOwogICAgaW50IGMgPSBsZXR0ZXJbKHVuc2lnbmVkIGNoYXIpIHNdOwoKICAgIGlmIChzICYmIGMgPCAwKSByZXR1cm47CgogICAgaWYgKCp0ID09IE5VTEwpIHsKICAgICAgICAqdCA9IGNhbGxvYygxLCBzaXplb2YoKip0KSk7ICAgICAgICAgICAgCiAgICB9CgogICAgaWYgKHMgPT0gMCkgewogICAgICAgICgqdCktPmVuZCA9IDE7CiAgICB9IGVsc2UgewogICAgICAgIHRhZGQoJigqdCktPm5leHRbY10sIHN0cik7CiAgICB9Cn0KCnZvaWQgdGRlc3Ryb3koc3RydWN0IFQgKnQpCnsKICAgIGlmICh0KSB7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKSB7CiAgICAgICAgICAgIHRkZXN0cm95KHQtPm5leHRbaV0pOwogICAgICAgIH0KICAgICAgICAKICAgICAgICBmcmVlKHQpOwogICAgfQp9Cgp2b2lkIHRwcmludChzdHJ1Y3QgVCAqdCwgY2hhciAqYnVmLCBpbnQgbikKewogICAgaWYgKHQpIHsKICAgICAgICBpZiAodC0+ZW5kKSBwcmludGYoIiUuKnNcbiIsIG4sIGJ1Zik7CiAgICAgICAgCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCAyNjsgaSsrKSB7CiAgICAgICAgICAgIGlmICh0LT5uZXh0W2ldKSB7CiAgICAgICAgICAgICAgICBidWZbbl0gPSAnYScgKyBpOwogICAgICAgICAgICAgICAgdHByaW50KHQtPm5leHRbaV0sIGJ1ZiwgbiArIDEpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIGZpbGwoY2hhciBncmlkWzNdWzVdLCBzdHJ1Y3QgVCAqYVtdLCBzdHJ1Y3QgVCAqZFtdLCBpbnQgbik7Cgp2b2lkIGZpbGxkKGNoYXIgZ3JpZFszXVs1XSwgc3RydWN0IFQgKmFbXSwgc3RydWN0IFQgKmRbXSwgaW50IG4sIGludCBrKQp7CiAgICBpZiAoayA9PSA1KSB7CiAgICAgICAgZmlsbChncmlkLCBhLCBkLCBuICsgMSk7CiAgICB9IGVsc2UgewogICAgICAgIGludCBjOwogICAgICAgIAogICAgICAgIGZvciAoYyA9IDA7IGMgPCAyNjsgYysrKSB7CiAgICAgICAgICAgIGlmIChkW25dLT5uZXh0W2NdICYmIGFba10tPm5leHRbY10pIHsKICAgICAgICAgICAgICAgIHN0cnVjdCBUICpkZCA9IGRbbl07CiAgICAgICAgICAgICAgICBzdHJ1Y3QgVCAqYWEgPSBhW2tdOwogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICBkW25dID0gZFtuXS0+bmV4dFtjXTsKICAgICAgICAgICAgICAgIGFba10gPSBhW2tdLT5uZXh0W2NdOwogICAgICAgICAgICAgICAgZ3JpZFtuXVtrXSA9ICdBJyArIGM7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIGZpbGxkKGdyaWQsIGEsIGQsIG4sIGsgKyAxKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgZFtuXSA9IGRkOwogICAgICAgICAgICAgICAgYVtrXSA9IGFhOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIHByaW50NShjb25zdCBjaGFyICpzKQp7CiAgICBpbnQgbiA9IDU7CiAgICAKICAgIHdoaWxlIChuLS0pIHsKICAgICAgICBwdXRjaGFyKCcgJyk7CiAgICAgICAgcHV0Y2hhcigqcysrKTsKICAgIH0KICAgIAogICAgcHV0Y2hhcignXG4nKTsKfQoKdm9pZCBmaWxsKGNoYXIgZ3JpZFszXVs1XSwgc3RydWN0IFQgKmFbXSwgc3RydWN0IFQgKmRbXSwgaW50IG4pCnsKICAgIGlmIChuID09IDMpIHsKICAgICAgICBwcmludDUoZ3JpZFswXSk7CiAgICAgICAgcHJpbnQ1KGdyaWRbMV0pOwogICAgICAgIHByaW50NShncmlkWzJdKTsKICAgICAgICBwdXRjaGFyKCdcbicpOwogICAgfSBlbHNlIHsKICAgICAgICBmaWxsZChncmlkLCB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z2h0IiwgIm91dGVyIiwgIm93aW5nIiwKICAgICJvd25lciIsICJwYWdlcyIsICJwYWlycyIsICJwYXBlciIsICJwYXJ0cyIsICJwYXJ0eSIsICJwYXRjaCIsICJwYXVzZSIsCiAgICAicGF5ZWQiLCAicGVhY2UiLCAicGhhc2UiLCAicGhvbmUiLCAicGlja3MiLCAicGllY2UiLCAicGxhY2UiLCAicGxhaW4iLAogICAgInBsYW5lIiwgInBsYW5zIiwgInBsYW50IiwgInBsYXlzIiwgInBsb3RzIiwgInBvaW50IiwgInBvc3RzIiwgInBvdW5kIiwKICAgICJwb3dlciIsICJwcmVzcyIsICJwcmljZSIsICJwcmltZSIsICJwcmludCIsICJwcmlvciIsICJwcm9uZSIsICJwcm9vZiIsCiAgICAicHJvdmUiLCAicHVsbHMiLCAicHV0dHMiLCAicXVldWUiLCAicXVpY2siLCAicXVpZXQiLCAicXVpdGUiLCAicXVpdHMiLAogICAgInF1b3RlIiwgInJhZGlvIiwgInJhaXNlIiwgInJhbmdlIiwgInJhcGlkIiwgInJhdGVzIiwgInJlYWNoIiwgInJlYWN0IiwKICAgICJyZWFkcyIsICJyZWFkeSIsICJyZWZlciIsICJyZXBseSIsICJyaWdodCIsICJyaXZlciIsICJyb29tcyIsICJyb3VnaCIsCiAgICAicm91bmQiLCAicm91dGUiLCAicnVsZXMiLCAic2FkbHkiLCAic2FmZXIiLCAic2FpbnQiLCAic2FsZXMiLCAic2F2ZWQiLAogICAgInNhdmVzIiwgInNjYWxlIiwgInNjZW5lIiwgInNjb3JlIiwgInNjcmFwIiwgInNlZWtzIiwgInNlZW1zIiwgInNlbGxzIiwKICAgICJzZW5kcyIsICJzZW5zZSIsICJzZXJ2ZSIsICJzZXZlbiIsICJzaGFsbCIsICJzaGFtZSIsICJzaGFwZSIsICJzaGFyZSIsCiAgICAic2hhcnAiLCAic2hlZXQiLCAic2hlbGYiLCAic2hlbGwiLCAic2hpZnQiLCAic2hvb3QiLCAic2hvcHMiLCAic2hvcnQiLAogICAgInNob3duIiwgInNob3dzIiwgInNodXRzIiwgInNpZGVzIiwgInNpZ2h0IiwgInNpZ25zIiwgInNpbGx5IiwgInNpbmNlIiwKICAgICJzaXRlcyIsICJzaXplcyIsICJza2lsbCIsICJzbGVlcCIsICJzbWFsbCIsICJzbWlsZSIsICJzb2xpZCIsICJzb2x2ZSIsCiAgICAic29ycnkiLCAic29ydHMiLCAic291bmQiLCAic291dGgiLCAic3BhY2UiLCAic3BhcmUiLCAic3BlYWsiLCAic3BlZWQiLAogICAgInNwZWxsIiwgInNwZW5kIiwgInNwZW50IiwgInNwaXRlIiwgInNwbGl0IiwgInNwb2tlIiwgInNwb3RzIiwgInN0YWZmIiwKICAgICJzdGFnZSIsICJzdGFuZCIsICJzdGFydCIsICJzdGF0ZSIsICJzdGF5cyIsICJzdGVhbCIsICJzdGljayIsICJzdGlsbCIsCiAgICAic3RvY2siLCAic3RvbmUiLCAic3Rvb2QiLCAic3RvcHMiLCAic3RvcmUiLCAic3RvcnkiLCAic3R1Y2siLCAic3R1ZHkiLAogICAgInN0dWZmIiwgInN0eWxlIiwgInN1Z2FyIiwgInN1aXRzIiwgInRhYmxlIiwgInRha2VuIiwgInRha2VzIiwgInRhbGtzIiwKICAgICJ0YW5rcyIsICJ0YXBlcyIsICJ0YXNrcyIsICJ0YXN0ZSIsICJ0ZWFjaCIsICJ0ZWV0aCIsICJ0ZWxscyIsICJ0ZW5kcyIsCiAgICAidGVybXMiLCAidGVzdHMiLCAidGhhbmsiLCAidGhlaXIiLCAidGhlcmUiLCAidGhlc2UiLCAidGhpbmciLCAidGhpbmsiLAogICAgInRoaXJkIiwgInRob3NlIiwgInRocmVlIiwgInRocmV3IiwgInRocm93IiwgInRpZ2h0IiwgInRpbWVkIiwgInRpbWVzIiwKICAgICJ0aXRsZSIsICJ0b2RheSIsICJ0b2tlbiIsICJ0b290aCIsICJ0b3BpYyIsICJ0b3RhbCIsICJ0b3VjaCIsICJ0cmFjZSIsCiAgICAidHJhY2siL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5rIiwgImlvbiIsCiAgICAiaXRzIiwgImphbSIsICJqZXQiLCAiam9iIiwgImpveSIsICJrZW4iLCAia2V5IiwgImtpZCIsICJraXQiLCAibGFiIiwgImxhZCIsCiAgICAibGFnIiwgImxhdyIsICJsYXkiLCAibGVkIiwgImxlZyIsICJsZXQiLCAibGlkIiwgImxpZSIsICJsaXAiLCAibGl0IiwgImxvZyIsCiAgICAibG90IiwgImxvdyIsICJtYWQiLCAibWFuIiwgIm1hcCIsICJtYXkiLCAibWVuIiwgIm1ldCIsICJtaXgiLCAibW9iIiwgIm1vZCIsCiAgICAibXVkIiwgIm11ZyIsICJtdW0iLCAibmF5IiwgIm5ldCIsICJuZXciLCAibmlsIiwgIm5vciIsICJub3QiLCAibm93IiwgIm51biIsCiAgICAibnV0IiwgIm9hciIsICJvZGQiLCAib2ZmIiwgIm9pbCIsICJvbGQiLCAib25lIiwgIm9wdCIsICJvdXIiLCAib3V0IiwgIm93ZSIsCiAgICAib3duIiwgInBhZCIsICJwYW4iLCAicGFyIiwgInBhdCIsICJwYXkiLCAicGVuIiwgInBlciIsICJwZXQiLCAicGllIiwgInBpZyIsCiAgICAicGluIiwgInBpdCIsICJwb3AiLCAicG90IiwgInBybyIsICJwdWIiLCAicHVuIiwgInB1dCIsICJyYWciLCAicmFtIiwgInJhbiIsCiAgICAicmF0IiwgInJhdyIsICJyYXkiLCAicmVkIiwgInJpZCIsICJyaXAiLCAicm9kIiwgInJvdCIsICJyb3ciLCAicnViIiwgInJ1biIsCiAgICAic2FkIiwgInNhdCIsICJzYXciLCAic2F5IiwgInNlYSIsICJzZWUiLCAic2V0IiwgInNleCIsICJzaGUiLCAic2h5IiwgInNpYyIsCiAgICAic2luIiwgInNpciIsICJzaXQiLCAic2l4IiwgInNreSIsICJzb2QiLCAic29uIiwgInNweSIsICJzdWUiLCAic3VtIiwgInN1biIsCiAgICAidGFiIiwgInRhZyIsICJ0YXAiLCAidGF4IiwgInRlYSIsICJ0ZW4iLCAidGhlIiwgInRpZSIsICJ0aW4iLCAidGlwIiwgInRvZSIsCiAgICAidG9uIiwgInRvbyIsICJ0b3AiLCAidG95IiwgInRyeSIsICJ0d28iLCAidXNlIiwgInZhbiIsICJ2YXQiLCAidmV0IiwgInZpYSIsCiAgICAid2FyIiwgIndhcyIsICJ3YXkiLCAid2VkIiwgIndlZSIsICJ3ZXQiLCAid2hvIiwgIndoeSIsICJ3aW4iLCAid2l0IiwgIndvbiIsCiAgICAieWVzIiwgInlldCIsICJ5b3UiLCBOVUxMCn07CgppbnQgbWFpbigpCnsKICAgIHN0cnVjdCBUICp3MyA9IE5VTEw7CiAgICBzdHJ1Y3QgVCAqdzUgPSBOVUxMOwogICAgY29uc3QgY2hhciAqKnA7CiAgICBpbnQgaTsKICAgIAogICAgbWVtc2V0KGxldHRlciwgLTEsIHNpemVvZihsZXR0ZXIpKTsKCiAgICBmb3IgKGkgPSAwOyBpIDwgMjY7IGkrKykgewogICAgICAgIGxldHRlclsnYScgKyBpXSA9IGk7CiAgICAgICAgbGV0dGVyWydBJyArIGldID0gaTsKICAgIH0KICAgIAogICAgcCA9IGQzOwogICAgd2hpbGUgKCpwKSB0YWRkKCZ3MywgKnArKyk7CiAgICAKICAgIHAgPSBkNTsKICAgIHdoaWxlICgqcCkgdGFkZCgmdzUsICpwKyspOwogICAgCiAgICBpZiAoMSkgewogICAgICAgIGNoYXIgZ3JpZFszXVs1XTsKICAgICAgICBzdHJ1Y3QgVCAqYVs1XSA9IHt3MywgdzMsIHczLCB3MywgdzN9OwogICAgICAgIHN0cnVjdCBUICpkWzNdID0ge3c1LCB3NSwgdzV9OwogICAgCiAgICAgICAgZmlsbChncmlkLCBhLCBkLCAwKTsKICAgIH0KCiAgICB0ZGVzdHJveSh3Myk7CiAgICB0ZGVzdHJveSh3NSk7CiAgICAKICAgIHJldHVybiAwOwp9Cg==