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

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

d = A("d")
e = B("e")
l = A("l")
n = B("n")
c = A("c")
m = B("m")
g = B("g")
h = A("h")
b = B("b")
i = B("i")

d.o = c
e.z = b
l.o = h
n.z = e
c.o = l
m.z = n
g.z = i
h.o = l
b.z = i
i.z = n
assert m.z.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

d = A("d")
e = B("e")
l = A("l")
n = B("n")
c = A("c")
m = B("m")
g = B("g")
h = A("h")
b = B("b")
i = B("i")

d.o = c
e.z = b
l.o = h
n.z = e
c.o = l
m.z = n
g.z = i
h.o = l
b.z = i
i.z = n
assert m.z.z.z.z.z.z.z.z.txt == "i"