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

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

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

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

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

h.s = g
c.q = i
k.v = l
n.z = k
n.p = i
m.z = g
m.p = i
l.v = k
g.v = k
i.q = c
assert l.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

h.s = g
c.q = i
k.v = l
n.z = k
n.p = i
m.z = g
m.p = i
l.v = k
g.v = k
i.q = c
assert l.v.v.v.v.v.v.txt == "l"