class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: 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.p: B = None
        self.txt = txt

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

j = A("j")
m = B("m")
f = C("f")
c = D("c")
i = A("i")
l = D("l")
n = A("n")
e = B("e")
a = C("a")
k = D("k")

j.s = a
j.t = f
m.q = e
f.p = e
c.z = m
i.s = a
i.t = a
l.z = e
n.s = a
n.t = f
e.q = m
a.p = e
k.z = e
assert m.q.q.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: 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.p: B = None
        self.txt = txt

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

j = A("j")
m = B("m")
f = C("f")
c = D("c")
i = A("i")
l = D("l")
n = A("n")
e = B("e")
a = C("a")
k = D("k")

j.s = a
j.t = f
m.q = e
f.p = e
c.z = m
i.s = a
i.t = a
l.z = e
n.s = a
n.t = f
e.q = m
a.p = e
k.z = e
assert m.q.q.q.q.q.q.q.q.q.q.txt == "m"