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

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

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

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

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

k.t = f
i.q = c
i.y = a
l.q = c
f.q = m
c.q = l
n.q = l
n.y = f
j.q = c
j.y = f
a.q = n
b.q = c
b.y = a
m.q = c
m.y = a
assert c.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

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

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

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

k.t = f
i.q = c
i.y = a
l.q = c
f.q = m
c.q = l
n.q = l
n.y = f
j.q = c
j.y = f
a.q = n
b.q = c
b.y = a
m.q = c
m.y = a
assert c.q.q.q.q.q.q.txt == "c"