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

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

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

d = A("d")
f = B("f")
k = C("k")
l = A("l")
b = B("b")
e = A("e")
n = C("n")
a = A("a")
c = C("c")

d.q = l
d.t = f
f.z = a
f.q = k
f.p = e
k.z = e
k.p = f
l.q = d
l.t = f
b.z = l
b.q = n
b.p = e
e.q = d
e.t = b
n.z = a
n.p = b
a.q = l
a.t = b
c.z = l
c.p = b
assert n.z.t.z.t.z.q.q.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: B = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
k = C("k")
l = A("l")
b = B("b")
e = A("e")
n = C("n")
a = A("a")
c = C("c")

d.q = l
d.t = f
f.z = a
f.q = k
f.p = e
k.z = e
k.p = f
l.q = d
l.t = f
b.z = l
b.q = n
b.p = e
e.q = d
e.t = b
n.z = a
n.p = b
a.q = l
a.t = b
c.z = l
c.p = b
assert n.z.t.z.t.z.q.q.q.t.txt == "f"