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

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

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

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

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

e.t = j
e.z = j
e.w = c
f.r = c
c.p = j
j.p = e
j.t = c
j.v = f
j.u = f
assert j.v.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

e.t = j
e.z = j
e.w = c
f.r = c
c.p = j
j.p = e
j.t = c
j.v = f
j.u = f
assert j.v.r.p.txt == "j"