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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
d = C("d")
e = D("e")

c.t = a
a.z = c
a.w = c
d.q = c
d.v = e
e.r = d
assert e.r.v.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: D = None
        self.txt = txt

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

c = A("c")
a = B("a")
d = C("d")
e = D("e")

c.t = a
a.z = c
a.w = c
d.q = c
d.v = e
e.r = d
assert e.r.v.r.v.txt == "e"