@@ 0,0 1,21 @@
+local function dig(ans, x, y, dir, len)
+ if dir == 3 then y = y - len
+ elseif dir == 1 then y = y + len
+ elseif dir == 2 then x, ans = x - len, ans + 2 * y * len
+ else assert(dir == 0) x, ans = x + len, ans - 2 * y * len
+ end
+ return ans + len, x, y
+end
+
+local dircode = {R=0, D=1, L=2, U=3}
+local ans1, x1, y1, ans2, x2, y2 = 0, 0, 0, 0, 0, 0
+io.input(arg[1])
+for line in io.lines() do
+ local dir1, len1, dirlen2 = line:match('([UDLR]) (%d+) %(#(%x+)%)')
+ dir1, dirlen2 = dircode[dir1], tonumber(dirlen2, 16)
+ local dir2, len2 = dirlen2 & 0xf, dirlen2 >> 4
+ ans1, x1, y1 = dig(ans1, x1, y1, dir1, len1)
+ ans2, x2, y2 = dig(ans2, x2, y2, dir2, len2)
+end
+ans1, ans2 = ans1 // 2 + 1, ans2 // 2 + 1
+print(ans1, ans2)
@@ 0,0 1,648 @@
+R 8 (#594dc2)
+U 3 (#7deda3)
+R 9 (#594dc0)
+U 5 (#4ce433)
+R 3 (#5bbe72)
+U 7 (#474513)
+R 10 (#379002)
+U 5 (#16bae3)
+L 4 (#4514d0)
+U 4 (#8d5633)
+L 10 (#4e39a0)
+U 2 (#1e0d03)
+L 3 (#9e5f62)
+U 2 (#88aef3)
+L 5 (#42f282)
+U 8 (#308253)
+R 6 (#9ae4f2)
+U 4 (#909ef3)
+R 4 (#46c432)
+U 6 (#7f4ee3)
+R 6 (#276242)
+U 5 (#028b71)
+R 7 (#23cbc2)
+U 8 (#44cef1)
+R 3 (#a89092)
+U 5 (#37f481)
+R 10 (#3b1392)
+U 2 (#5fe4a3)
+R 3 (#10f772)
+U 5 (#0adbe1)
+R 4 (#5c0012)
+U 10 (#3e7871)
+R 6 (#419562)
+U 4 (#68a091)
+R 7 (#9d9570)
+U 5 (#25eba1)
+R 8 (#2a78f2)
+U 7 (#013481)
+R 6 (#5b7540)
+U 4 (#70f5c1)
+R 6 (#742a00)
+U 3 (#3dbc91)
+R 6 (#553232)
+U 6 (#047c81)
+L 6 (#7a3c42)
+U 4 (#047c83)
+L 8 (#0030d2)
+U 7 (#21ed81)
+R 4 (#008dc2)
+U 4 (#424e83)
+R 10 (#283622)
+U 4 (#4a3091)
+R 10 (#ac29f2)
+U 5 (#4a3093)
+R 5 (#579402)
+U 4 (#424e81)
+R 7 (#18ce22)
+U 8 (#7bd643)
+L 7 (#057922)
+U 7 (#bd2693)
+R 10 (#48a832)
+D 6 (#0e2e53)
+R 2 (#6ed792)
+D 13 (#46fb43)
+R 3 (#10e1f2)
+U 9 (#02f941)
+R 3 (#4e2f92)
+U 8 (#1a45c1)
+R 9 (#496e00)
+U 4 (#9bda91)
+R 6 (#496e02)
+U 9 (#17ee31)
+R 2 (#376d02)
+U 3 (#209761)
+R 4 (#859c90)
+U 6 (#744071)
+R 4 (#35b882)
+U 9 (#501e21)
+L 4 (#b782a2)
+D 4 (#432aa1)
+L 10 (#838742)
+U 4 (#05f943)
+L 5 (#28dac2)
+U 4 (#0691c3)
+R 5 (#5f8942)
+U 4 (#6902f1)
+R 9 (#337982)
+D 4 (#6902f3)
+R 5 (#3c1c32)
+U 8 (#515c63)
+R 9 (#a81340)
+U 6 (#7a3e33)
+R 8 (#4fa8a0)
+U 4 (#bc6d03)
+R 3 (#003dd0)
+U 7 (#6495c3)
+R 3 (#59b7e2)
+U 2 (#ca3aa3)
+R 7 (#16a490)
+U 3 (#725193)
+R 2 (#01a6c0)
+U 7 (#619bd1)
+R 4 (#007350)
+D 12 (#53fbf1)
+R 4 (#2d4100)
+D 11 (#315ef3)
+L 6 (#76c240)
+D 5 (#8438d3)
+L 6 (#9526b0)
+D 5 (#357fd1)
+L 3 (#00f410)
+D 2 (#822331)
+L 10 (#81a430)
+D 5 (#822333)
+L 9 (#565f30)
+D 2 (#357fd3)
+L 2 (#693cb0)
+D 7 (#725191)
+R 8 (#043860)
+U 5 (#150223)
+R 2 (#1ef3d0)
+D 5 (#8fd253)
+R 9 (#1ef3d2)
+D 4 (#54d603)
+L 15 (#2df370)
+D 2 (#0d49d1)
+L 4 (#a5e730)
+D 4 (#7c9891)
+R 11 (#70d860)
+D 8 (#2545e1)
+L 4 (#9074a2)
+D 7 (#0076c1)
+L 3 (#74e662)
+D 7 (#644ef1)
+L 5 (#116492)
+D 5 (#233b41)
+L 6 (#9838d0)
+D 13 (#695343)
+R 6 (#8a0fe0)
+D 4 (#41e803)
+L 14 (#52f300)
+D 3 (#240f93)
+L 3 (#b59430)
+D 6 (#65e2a3)
+R 8 (#b59432)
+D 6 (#7608a3)
+R 8 (#3ebc00)
+D 6 (#43d143)
+R 7 (#4516d2)
+D 3 (#0c0a21)
+R 6 (#12b922)
+D 7 (#c37ef1)
+L 9 (#5076e2)
+D 2 (#7b48b3)
+R 9 (#3f58b2)
+D 7 (#544063)
+R 8 (#11d6a2)
+U 9 (#295c83)
+L 5 (#2248c2)
+U 8 (#106cb3)
+R 5 (#3d2e90)
+U 8 (#62a1b3)
+R 5 (#86e910)
+D 4 (#0d82d3)
+R 8 (#714042)
+D 11 (#259d63)
+R 4 (#52d762)
+D 11 (#4ebaf3)
+L 5 (#394030)
+D 11 (#284363)
+R 5 (#7f7a40)
+D 3 (#4db0a1)
+L 4 (#76cb90)
+D 4 (#65d251)
+L 5 (#a0d6c0)
+D 9 (#80f381)
+L 3 (#0dd8a0)
+D 4 (#974581)
+R 5 (#462960)
+D 9 (#829951)
+R 3 (#0e4bd0)
+D 3 (#564a81)
+R 6 (#39ebb0)
+D 4 (#4e35e1)
+R 8 (#564090)
+D 3 (#381e31)
+R 2 (#6f1f90)
+D 7 (#0a9ce1)
+L 10 (#66e1e0)
+D 4 (#83e3a3)
+L 9 (#0386c2)
+U 10 (#975db3)
+L 5 (#0386c0)
+D 10 (#1be7e3)
+L 6 (#1388f0)
+D 4 (#02a033)
+R 9 (#6f9410)
+D 6 (#55cb11)
+R 3 (#59bcf0)
+D 5 (#56d341)
+R 8 (#7cd270)
+D 9 (#8fe951)
+R 3 (#7a5590)
+D 7 (#5e1b43)
+R 7 (#0b4340)
+D 9 (#4c8f73)
+R 10 (#0b4342)
+D 2 (#91dcf3)
+R 4 (#46e650)
+D 7 (#82c663)
+L 6 (#15c010)
+D 2 (#918233)
+L 6 (#6c4110)
+D 6 (#226eb3)
+R 9 (#4eb1e2)
+D 7 (#a00fb3)
+R 3 (#4eb1e0)
+D 10 (#7ceac3)
+R 4 (#af5400)
+U 5 (#0c1943)
+R 7 (#0be800)
+U 9 (#7416e1)
+R 3 (#03ebe0)
+U 9 (#667aa1)
+R 5 (#03ebe2)
+U 9 (#70f0e1)
+R 7 (#40adf0)
+U 3 (#7abe73)
+R 4 (#816d40)
+U 7 (#573993)
+R 9 (#1dfb62)
+U 3 (#1c9ea3)
+R 5 (#862582)
+U 4 (#8da203)
+R 7 (#595ba2)
+U 2 (#5f5163)
+R 3 (#4b4b02)
+U 6 (#3e7753)
+R 5 (#1be5f0)
+U 6 (#117af1)
+R 3 (#96d390)
+D 12 (#117af3)
+R 6 (#63a6d0)
+D 5 (#0864c3)
+L 12 (#326730)
+D 5 (#a46933)
+L 2 (#83cc60)
+D 3 (#6619b1)
+L 4 (#3d6740)
+D 9 (#7da681)
+L 8 (#7adab0)
+D 2 (#52ec81)
+R 8 (#c8b640)
+D 9 (#52ec83)
+R 4 (#9c24d0)
+D 4 (#7f0da1)
+R 7 (#3c72c0)
+D 2 (#4b8811)
+R 7 (#5f81c2)
+D 7 (#36afe3)
+R 5 (#90ca52)
+D 5 (#36afe1)
+R 12 (#5c9362)
+D 4 (#597741)
+R 3 (#21f722)
+D 5 (#5b6911)
+R 7 (#b44bf2)
+D 8 (#4bd781)
+R 8 (#048d52)
+D 6 (#7cf731)
+R 3 (#31dff2)
+D 6 (#229871)
+R 7 (#2fdb10)
+D 11 (#7aa251)
+R 3 (#8d42b0)
+U 5 (#3ddbf3)
+R 5 (#97ec50)
+U 10 (#945873)
+L 5 (#7a6f30)
+U 5 (#5dae33)
+R 4 (#8c8910)
+U 4 (#4d9a43)
+R 7 (#2d9e30)
+U 7 (#039b93)
+R 3 (#5e1e10)
+D 4 (#59f743)
+R 7 (#710a60)
+D 6 (#825003)
+L 7 (#63ba50)
+D 9 (#48a773)
+R 7 (#290ce2)
+D 8 (#2449c1)
+R 3 (#938682)
+D 4 (#2449c3)
+R 11 (#183152)
+D 3 (#14f843)
+R 11 (#a7d150)
+D 8 (#0114e3)
+R 4 (#65d042)
+D 5 (#bf14e3)
+R 3 (#443a52)
+D 2 (#bf14e1)
+R 5 (#5be4d2)
+D 3 (#187923)
+L 2 (#2d9e32)
+D 11 (#191863)
+L 4 (#74efe2)
+D 4 (#66f453)
+L 2 (#6f8c82)
+D 10 (#01da41)
+L 4 (#72fcb2)
+D 2 (#74f501)
+L 4 (#210be2)
+D 8 (#3898a1)
+L 5 (#1c3382)
+D 6 (#af67e3)
+L 5 (#0a2c22)
+D 6 (#53a953)
+R 10 (#1db900)
+D 2 (#795d43)
+R 5 (#7c8060)
+D 7 (#935b73)
+L 12 (#137770)
+D 6 (#1603f3)
+L 3 (#12d9f0)
+D 7 (#622d41)
+L 6 (#0a5e80)
+U 5 (#653773)
+L 3 (#641c70)
+U 2 (#653771)
+L 6 (#63f570)
+U 7 (#69d881)
+L 2 (#3881c2)
+U 6 (#17cc91)
+L 5 (#6bc442)
+U 6 (#17cc93)
+L 7 (#2e2a62)
+U 8 (#1a3171)
+L 2 (#68ec50)
+U 7 (#3c8571)
+R 9 (#4015d0)
+U 8 (#1b48b3)
+L 6 (#a22d90)
+U 9 (#35a193)
+L 7 (#78a320)
+D 8 (#35a191)
+L 7 (#2d6e50)
+D 11 (#7319d1)
+L 4 (#aaee40)
+D 7 (#035af3)
+L 9 (#2dc2c0)
+U 7 (#035af1)
+L 5 (#a3f400)
+U 4 (#5f9c61)
+L 6 (#129ac0)
+U 6 (#954131)
+L 10 (#4d4e40)
+D 8 (#a11d91)
+L 4 (#8bf900)
+D 11 (#a11d93)
+L 6 (#89c6f0)
+U 3 (#4825d1)
+L 3 (#13e6f0)
+U 7 (#67db31)
+L 10 (#4a4de2)
+U 3 (#865ca1)
+R 10 (#49db32)
+U 6 (#3146e1)
+L 6 (#4073d2)
+U 6 (#07a3c1)
+R 11 (#701312)
+U 2 (#07dab3)
+R 7 (#2d5082)
+U 5 (#96ca13)
+R 11 (#9589f2)
+U 7 (#3db203)
+L 11 (#4bea62)
+U 3 (#3db201)
+L 4 (#4dc4f2)
+U 5 (#9ea4c1)
+L 6 (#64fb32)
+D 5 (#09fa31)
+L 7 (#5e78a0)
+D 5 (#24c511)
+L 3 (#794240)
+D 9 (#bd8d21)
+L 4 (#3be3a0)
+U 5 (#a3be21)
+L 4 (#059772)
+U 5 (#2c1081)
+L 8 (#1ab9b2)
+D 4 (#3f7321)
+L 2 (#8187a2)
+D 6 (#88b701)
+L 5 (#270232)
+D 8 (#25b031)
+L 10 (#2d6db2)
+D 6 (#67f511)
+L 6 (#3f0812)
+D 7 (#419593)
+L 10 (#87e622)
+D 5 (#419591)
+L 7 (#21c4e2)
+D 3 (#14b251)
+L 9 (#457152)
+D 7 (#536ee1)
+L 9 (#157d12)
+D 5 (#9a8b51)
+L 2 (#5db272)
+D 5 (#55fa61)
+L 2 (#7c00e0)
+D 7 (#5bb7a1)
+L 7 (#0ed480)
+D 3 (#16ab71)
+L 10 (#5be3f0)
+D 7 (#7fcd71)
+L 3 (#75a4c0)
+D 8 (#522c31)
+R 2 (#1e9120)
+D 6 (#535fa1)
+R 4 (#09afb0)
+D 4 (#11cfb3)
+L 14 (#405a60)
+D 5 (#11e361)
+L 4 (#453f60)
+D 7 (#11e363)
+R 11 (#6dd3d0)
+D 6 (#11cfb1)
+R 7 (#1f9010)
+D 3 (#2dcb51)
+L 6 (#6fa672)
+D 8 (#2cc821)
+L 10 (#c78522)
+D 7 (#0e0ca1)
+L 3 (#390302)
+D 7 (#bcbc73)
+L 8 (#74a632)
+D 4 (#bcbc71)
+L 3 (#517c02)
+D 2 (#0e0ca3)
+L 11 (#156562)
+U 5 (#2cc823)
+L 5 (#6d4c52)
+U 6 (#747d21)
+L 2 (#4e3512)
+U 3 (#4288d1)
+L 12 (#491d20)
+U 7 (#655861)
+L 6 (#27f5b0)
+U 3 (#56b851)
+L 9 (#5db0a0)
+D 10 (#00fa03)
+L 3 (#aa9580)
+U 8 (#31f603)
+L 2 (#795580)
+U 7 (#3c2d43)
+L 2 (#9c0332)
+U 7 (#47eda3)
+R 2 (#9c0330)
+U 5 (#51b393)
+R 2 (#4fbf90)
+U 10 (#0f4123)
+R 3 (#6886a0)
+D 5 (#930b11)
+R 2 (#238c20)
+D 9 (#84f481)
+R 7 (#350920)
+D 4 (#4c1351)
+R 13 (#68e890)
+D 3 (#75e891)
+R 4 (#589192)
+U 9 (#8aa761)
+L 9 (#29d772)
+U 9 (#383641)
+R 9 (#9c0072)
+U 3 (#474a61)
+R 3 (#3042f2)
+U 5 (#6ca7b3)
+L 12 (#64d070)
+U 5 (#5402c3)
+L 6 (#64d072)
+U 5 (#497d93)
+L 6 (#553402)
+U 8 (#669b61)
+L 3 (#242e22)
+D 4 (#2f29c1)
+L 7 (#2f8332)
+D 6 (#7a62a1)
+L 5 (#92a3b2)
+D 8 (#64da21)
+L 7 (#62aa72)
+D 12 (#bf3b51)
+L 6 (#712a52)
+D 6 (#bf3b53)
+L 6 (#0e6852)
+U 8 (#61c6c1)
+L 8 (#625f22)
+U 2 (#1b6273)
+L 5 (#82b9a2)
+U 8 (#53af03)
+R 6 (#2ab050)
+U 9 (#767c13)
+R 4 (#8a69c0)
+U 6 (#767c11)
+R 12 (#1b59d0)
+U 4 (#583af3)
+L 6 (#18f400)
+U 7 (#2874c3)
+L 12 (#bf2752)
+U 4 (#0ca213)
+L 4 (#2a4092)
+U 8 (#7f1033)
+L 10 (#5f6142)
+U 7 (#0cda71)
+R 5 (#02c002)
+U 4 (#76a9e1)
+R 4 (#992e12)
+U 5 (#4e1111)
+R 5 (#7617b0)
+U 2 (#540a41)
+R 8 (#25d660)
+U 6 (#55d3c1)
+R 3 (#48e382)
+D 6 (#524913)
+R 4 (#028612)
+D 7 (#222cc1)
+R 5 (#9bba12)
+D 4 (#222cc3)
+R 3 (#507172)
+U 13 (#320b13)
+R 6 (#2738c2)
+U 4 (#436e03)
+R 6 (#9e9f02)
+U 9 (#5bdf03)
+L 3 (#6d4482)
+U 2 (#5ab0b3)
+L 6 (#168e40)
+D 7 (#483cb3)
+L 5 (#c2c970)
+U 7 (#483cb1)
+L 3 (#084f70)
+U 5 (#3d7573)
+L 3 (#16ebc0)
+D 9 (#be97b3)
+L 5 (#4a29c2)
+D 3 (#76e293)
+L 7 (#4b57e2)
+U 7 (#612c13)
+L 6 (#631142)
+U 2 (#4b5d63)
+L 5 (#90a012)
+U 11 (#246691)
+L 6 (#bf2f62)
+U 10 (#5e6ce1)
+L 8 (#089422)
+U 3 (#4a7871)
+L 5 (#5c1272)
+U 2 (#5becf1)
+L 7 (#924700)
+U 9 (#429751)
+L 4 (#4eade0)
+U 9 (#4e0f91)
+L 9 (#cb3210)
+U 3 (#4ec191)
+L 3 (#1e0bd2)
+U 7 (#41b9a1)
+L 3 (#77ddc2)
+U 7 (#61f901)
+L 6 (#1a1652)
+U 5 (#680581)
+L 7 (#6b0782)
+U 3 (#6471e3)
+L 9 (#4af792)
+U 9 (#a74643)
+L 9 (#462802)
+U 2 (#5ac0e1)
+L 5 (#28aa90)
+U 10 (#17be41)
+L 3 (#28aa92)
+D 3 (#5c9271)
+L 9 (#5c1270)
+D 9 (#73cf11)
+L 6 (#89c7b2)
+D 9 (#168723)
+R 4 (#2d5692)
+D 3 (#2ecbe3)
+R 5 (#1e0902)
+D 3 (#1c5523)
+R 6 (#054080)
+D 7 (#a23633)
+L 7 (#054082)
+U 2 (#0e5de3)
+L 9 (#1e0900)
+U 3 (#1b3423)
+L 4 (#693a72)
+U 4 (#1288d3)
+L 5 (#194c40)
+U 5 (#20e633)
+L 6 (#7d44c0)
+U 9 (#945dd3)
+L 3 (#2561f2)
+U 4 (#bb76d3)
+R 14 (#07f4b2)
+U 3 (#918121)
+L 4 (#2a5b92)
+U 4 (#464a51)
+L 12 (#2a5b90)
+U 3 (#698c81)
+R 5 (#3439b2)
+U 2 (#095ff1)
+R 10 (#4164b2)
+U 5 (#7e0df3)
+R 5 (#1ff532)
+U 3 (#2105c3)
+R 7 (#1f49a2)
+U 4 (#872be1)
+R 10 (#5d2d22)
+U 7 (#872be3)
+R 6 (#5937d2)
+U 5 (#474fe3)
+L 6 (#0a8bb2)
+U 11 (#645453)
+R 6 (#341552)
+D 7 (#32f483)
+R 8 (#025770)
+D 6 (#38d4d3)
+R 5 (#1d6710)
+D 5 (#0fb741)
+R 6 (#6d8f10)
+D 7 (#1b07a1)
+R 9 (#2c38a0)
+D 2 (#ae4871)
+R 3 (#2d1ba0)
+D 3 (#7b2cb3)
+R 7 (#231460)
+D 7 (#58fa43)
+R 4 (#7f8860)
+U 8 (#04e063)
+R 5 (#283330)
+U 4 (#38d4d1)
+R 4 (#006610)
+U 9 (#59cbc3)
+L 8 (#48c4d2)
+U 4 (#2bbeb3)
+L 4 (#48c4d0)
+U 5 (#505f33)
+L 14 (#4f1c22)
+U 4 (#0913c3)