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

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

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

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

b = A("b")
a = B("a")
n = C("n")
j = D("j")

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

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

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

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

b = A("b")
a = B("a")
n = C("n")
j = D("j")

b.z = a
b.t = a
a.z = b
n.o = j
j.o = n
assert a.z.t.z.t.txt == "a"