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

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

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

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

a = A("a")
c = B("c")
n = C("n")
j = D("j")
d = A("d")

a.q = c
a.r = c
a.v = j
c.w = j
c.x = j
c.s = n
n.q = a
j.u = n
j.p = n
j.t = n
j.q = d
d.q = c
d.r = c
d.v = j
assert c.w.q.v.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: D = None
        self.r: B = None
        self.txt = txt

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

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

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

a = A("a")
c = B("c")
n = C("n")
j = D("j")
d = A("d")

a.q = c
a.r = c
a.v = j
c.w = j
c.x = j
c.s = n
n.q = a
j.u = n
j.p = n
j.t = n
j.q = d
d.q = c
d.r = c
d.v = j
assert c.w.q.v.u.q.txt == "a"