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

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

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

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

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

i.p = a
m.v = i
m.p = i
k.q = i
k.s = n
a.u = i
a.t = m
n.v = i
n.p = i
assert m.v.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

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

i.p = a
m.v = i
m.p = i
k.q = i
k.s = n
a.u = i
a.t = m
n.v = i
n.p = i
assert m.v.p.t.txt == "m"