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

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

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

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

l.q = a
l.z = h
j.r = l
j.y = c
j.q = i
n.s = m
n.q = b
n.u = b
b.s = f
b.q = f
b.u = a
i.r = h
i.y = j
i.q = c
m.s = a
m.q = n
m.u = n
h.q = n
h.z = l
f.s = m
f.u = m
f.q = n
c.r = l
c.y = j
c.q = j
a.s = n
a.q = n
a.u = n
assert f.q.s.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: A = None
        self.txt = txt

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

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

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

l.q = a
l.z = h
j.r = l
j.y = c
j.q = i
n.s = m
n.q = b
n.u = b
b.s = f
b.q = f
b.u = a
i.r = h
i.y = j
i.q = c
m.s = a
m.q = n
m.u = n
h.q = n
h.z = l
f.s = m
f.u = m
f.q = n
c.r = l
c.y = j
c.q = j
a.s = n
a.q = n
a.u = n
assert f.q.s.s.q.s.txt == "m"