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

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

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

h.z = j
d.y = l
d.v = m
f.z = g
c.z = l
b.z = l
i.z = f
m.y = j
m.v = d
j.z = i
g.z = c
l.z = j
assert j.z.z.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

h.z = j
d.y = l
d.v = m
f.z = g
c.z = l
b.z = l
i.z = f
m.y = j
m.v = d
j.z = i
g.z = c
l.z = j
assert j.z.z.z.z.z.z.z.z.z.txt == "g"