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

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

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

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

m = A("m")
n = B("n")
c = C("c")
b = D("b")
a = D("a")
i = C("i")
d = D("d")
k = B("k")

m.q = i
m.x = k
n.x = k
n.u = k
n.w = i
c.r = m
c.q = i
b.v = k
b.z = k
a.v = k
a.z = k
i.r = m
i.q = c
d.v = k
d.z = n
k.x = n
k.u = n
k.w = i
assert c.q.r.q.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.x: B = None
        self.txt = txt

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

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

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

m = A("m")
n = B("n")
c = C("c")
b = D("b")
a = D("a")
i = C("i")
d = D("d")
k = B("k")

m.q = i
m.x = k
n.x = k
n.u = k
n.w = i
c.r = m
c.q = i
b.v = k
b.z = k
a.v = k
a.z = k
i.r = m
i.q = c
d.v = k
d.z = n
k.x = n
k.u = n
k.w = i
assert c.q.r.q.r.x.txt == "k"