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

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

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

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

c.q = j
c.u = f
c.p = e
n.z = k
n.r = f
n.q = i
f.o = k
f.z = e
f.r = j
k.z = n
k.r = f
k.q = d
e.q = j
e.u = a
e.p = m
m.q = i
m.u = f
m.p = e
j.z = k
j.r = a
j.q = d
d.z = k
d.r = a
d.q = j
a.o = d
a.z = e
a.r = j
i.z = k
i.q = k
i.r = f
assert n.q.q.z.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.p: A = None
        self.txt = txt

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

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

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

c.q = j
c.u = f
c.p = e
n.z = k
n.r = f
n.q = i
f.o = k
f.z = e
f.r = j
k.z = n
k.r = f
k.q = d
e.q = j
e.u = a
e.p = m
m.q = i
m.u = f
m.p = e
j.z = k
j.r = a
j.q = d
d.z = k
d.r = a
d.q = j
a.o = d
a.z = e
a.r = j
i.z = k
i.q = k
i.r = f
assert n.q.q.z.q.z.txt == "k"