class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

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

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

f.w = n
f.t = b
f.s = k
e.r = c
e.v = c
e.s = b
c.p = e
c.q = e
c.s = f
g.p = e
g.q = e
g.s = k
b.p = e
b.q = e
b.s = f
i.p = e
i.q = e
i.s = k
k.w = c
k.t = i
k.s = f
n.p = e
n.q = e
n.s = k
assert f.s.w.q.s.s.s.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: C = None
        self.s: A = None
        self.txt = txt

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

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

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

f.w = n
f.t = b
f.s = k
e.r = c
e.v = c
e.s = b
c.p = e
c.q = e
c.s = f
g.p = e
g.q = e
g.s = k
b.p = e
b.q = e
b.s = f
i.p = e
i.q = e
i.s = k
k.w = c
k.t = i
k.s = f
n.p = e
n.q = e
n.s = k
assert f.s.w.q.s.s.s.s.w.txt == "n"