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

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

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

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

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

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

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

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

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

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

l.r = h
l.t = h
i.r = h
i.p = h
i.w = m
i.q = n
n.q = l
n.z = h
n.v = i
n.t = i
h.x = l
h.u = n
m.q = l
m.z = h
m.v = i
m.t = i
assert m.q.t.u.t.txt == "i"