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

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

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

k = A("k")
f = B("f")
g = C("g")
b = C("b")
j = C("j")
c = B("c")
i = B("i")
d = A("d")
l = B("l")
n = B("n")

k.q = d
f.z = l
f.p = i
f.w = d
g.v = b
g.p = d
b.v = j
b.p = d
j.v = g
j.p = d
c.z = l
c.p = n
c.w = d
i.z = l
i.p = f
i.w = d
d.q = k
l.z = n
l.p = n
l.w = d
n.z = f
n.p = l
n.w = k
assert n.w.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
g = C("g")
b = C("b")
j = C("j")
c = B("c")
i = B("i")
d = A("d")
l = B("l")
n = B("n")

k.q = d
f.z = l
f.p = i
f.w = d
g.v = b
g.p = d
b.v = j
b.p = d
j.v = g
j.p = d
c.z = l
c.p = n
c.w = d
i.z = l
i.p = f
i.w = d
d.q = k
l.z = n
l.p = n
l.w = d
n.z = f
n.p = l
n.w = k
assert n.w.q.q.q.q.q.q.txt == "k"