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

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

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

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

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

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

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

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

b.y = k
b.p = n
b.z = c
a.p = n
a.y = m
a.q = c
e.q = i
c.p = b
c.y = a
c.q = a
i.q = e
n.y = b
n.p = b
n.z = m
m.p = b
m.y = c
m.q = a
f.y = b
f.p = b
f.z = c
k.y = b
k.p = n
k.z = a
assert e.q.q.q.q.q.q.q.q.txt == "e"