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

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

d = A("d")
a = B("a")
h = A("h")
g = A("g")
n = B("n")
e = B("e")

d.z = h
d.t = e
a.o = n
h.z = g
h.t = a
g.z = d
g.t = e
n.o = a
e.o = a
assert e.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: B = None
        self.txt = txt

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

d = A("d")
a = B("a")
h = A("h")
g = A("g")
n = B("n")
e = B("e")

d.z = h
d.t = e
a.o = n
h.z = g
h.t = a
g.z = d
g.t = e
n.o = a
e.o = a
assert e.o.o.o.o.txt == "n"