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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

e = A("e")
c = B("c")
h = C("h")
j = D("j")

e.t = j
e.v = c
c.x = j
h.w = c
h.y = c
j.z = h
j.q = h
j.w = e
assert c.x.w.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.v: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.txt = txt

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

e = A("e")
c = B("c")
h = C("h")
j = D("j")

e.t = j
e.v = c
c.x = j
h.w = c
h.y = c
j.z = h
j.q = h
j.w = e
assert c.x.w.v.x.txt == "j"