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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: A = None
        self.txt = txt

b = A("b")
k = B("k")
j = A("j")
g = A("g")
h = B("h")
c = A("c")
n = A("n")
d = A("d")
i = B("i")
l = A("l")

b.r = h
k.z = i
k.r = l
j.r = h
g.r = h
h.z = i
h.r = d
c.r = k
n.r = i
d.r = k
i.z = k
i.r = j
l.r = h
assert l.r.r.r.r.r.z.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: A = None
        self.txt = txt

b = A("b")
k = B("k")
j = A("j")
g = A("g")
h = B("h")
c = A("c")
n = A("n")
d = A("d")
i = B("i")
l = A("l")

b.r = h
k.z = i
k.r = l
j.r = h
g.r = h
h.z = i
h.r = d
c.r = k
n.r = i
d.r = k
i.z = k
i.r = j
l.r = h
assert l.r.r.r.r.r.z.r.r.txt == "h"