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

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

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

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

a = A("a")
i = B("i")
j = C("j")
e = D("e")

a.r = i
a.t = i
i.w = j
j.u = e
j.q = e
j.y = a
j.v = i
e.y = i
assert i.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
j = C("j")
e = D("e")

a.r = i
a.t = i
i.w = j
j.u = e
j.q = e
j.y = a
j.v = i
e.y = i
assert i.w.v.w.txt == "j"