class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: B = None
        self.q: C = None
        self.p: C = 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.t: D = None
        self.r: B = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: A = None
        self.y: A = None
        self.x: A = None
        self.txt = txt

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

e.v = j
e.q = j
e.p = j
e.w = m
m.x = a
j.t = a
j.r = m
j.z = m
a.r = e
a.q = e
a.y = e
a.x = e
assert m.x.q.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: B = None
        self.q: C = None
        self.p: C = 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.t: D = None
        self.r: B = None
        self.z: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.q: A = None
        self.y: A = None
        self.x: A = None
        self.txt = txt

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

e.v = j
e.q = j
e.p = j
e.w = m
m.x = a
j.t = a
j.r = m
j.z = m
a.r = e
a.q = e
a.y = e
a.x = e
assert m.x.q.w.x.txt == "a"