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

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

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

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

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

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

d.o = n
g.t = i
g.z = m
l.o = j
n.o = d
h.o = n
m.t = j
m.z = k
k.t = i
k.z = g
j.o = d
i.o = n
assert g.z.z.z.t.o.o.txt == "d"