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

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

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

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

m = A("m")
l = B("l")
i = C("i")
a = D("a")
n = B("n")

m.t = a
m.x = i
l.p = a
l.x = a
l.q = n
l.w = i
i.p = a
i.q = a
i.v = n
a.w = n
n.p = a
n.x = a
n.q = l
n.w = i
assert m.t.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: C = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
i = C("i")
a = D("a")
n = B("n")

m.t = a
m.x = i
l.p = a
l.x = a
l.q = n
l.w = i
i.p = a
i.q = a
i.v = n
a.w = n
n.p = a
n.x = a
n.q = l
n.w = i
assert m.t.w.w.txt == "i"