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

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

k = A("k")
a = B("a")
j = B("j")
d = B("d")
n = A("n")
e = B("e")
g = A("g")
l = B("l")
h = A("h")
c = B("c")

k.y = c
k.w = h
a.u = e
j.u = c
d.u = j
n.y = c
n.w = h
e.u = l
g.y = j
g.w = h
l.u = c
h.y = a
h.w = k
c.u = j
assert c.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.w: A = None
        self.txt = txt

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

k = A("k")
a = B("a")
j = B("j")
d = B("d")
n = A("n")
e = B("e")
g = A("g")
l = B("l")
h = A("h")
c = B("c")

k.y = c
k.w = h
a.u = e
j.u = c
d.u = j
n.y = c
n.w = h
e.u = l
g.y = j
g.w = h
l.u = c
h.y = a
h.w = k
c.u = j
assert c.u.u.u.u.u.u.u.u.txt == "c"