class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: A = None
        self.txt = txt

j = A("j")
b = B("b")
m = B("m")
g = A("g")
e = B("e")
l = B("l")
f = B("f")
c = A("c")
h = A("h")

j.q = c
j.y = c
b.u = g
b.x = j
m.u = g
m.x = g
g.q = j
g.y = h
e.u = g
e.x = c
l.u = j
l.x = c
f.u = h
f.x = c
c.q = g
c.y = h
h.q = j
h.y = g
assert c.y.q.q.y.y.q.y.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: A = None
        self.txt = txt

j = A("j")
b = B("b")
m = B("m")
g = A("g")
e = B("e")
l = B("l")
f = B("f")
c = A("c")
h = A("h")

j.q = c
j.y = c
b.u = g
b.x = j
m.u = g
m.x = g
g.q = j
g.y = h
e.u = g
e.x = c
l.u = j
l.x = c
f.u = h
f.x = c
c.q = g
c.y = h
h.q = j
h.y = g
assert c.y.q.q.y.y.q.y.q.y.txt == "h"