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

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

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

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

l = A("l")
h = B("h")
m = C("m")
i = D("i")
k = C("k")
j = D("j")
n = A("n")

l.t = i
h.v = m
h.w = i
h.t = l
m.r = l
i.q = n
i.y = m
i.z = l
k.r = l
j.q = l
j.y = m
j.z = n
n.t = i
assert m.r.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
h = B("h")
m = C("m")
i = D("i")
k = C("k")
j = D("j")
n = A("n")

l.t = i
h.v = m
h.w = i
h.t = l
m.r = l
i.q = n
i.y = m
i.z = l
k.r = l
j.q = l
j.y = m
j.z = n
n.t = i
assert m.r.t.q.txt == "n"