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

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

b = A("b")
a = B("a")
e = B("e")
f = A("f")
d = B("d")
j = B("j")

b.z = a
b.o = f
a.t = b
e.t = f
f.z = e
f.o = b
d.t = f
j.t = b
assert e.t.o.z.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: A = None
        self.txt = txt

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

b = A("b")
a = B("a")
e = B("e")
f = A("f")
d = B("d")
j = B("j")

b.z = a
b.o = f
a.t = b
e.t = f
f.z = e
f.o = b
d.t = f
j.t = b
assert e.t.o.z.t.o.o.txt == "b"