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

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

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

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

a = A("a")
n = B("n")
f = C("f")
c = D("c")
b = C("b")

a.t = n
n.x = a
f.s = c
c.z = n
c.t = f
b.s = c
assert n.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
f = C("f")
c = D("c")
b = C("b")

a.t = n
n.x = a
f.s = c
c.z = n
c.t = f
b.s = c
assert n.x.t.x.txt == "a"