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

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

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

b = A("b")
a = B("a")
i = C("i")
n = B("n")
c = B("c")
g = A("g")
j = A("j")
l = A("l")
f = C("f")
e = B("e")

b.s = g
a.p = e
a.z = e
i.p = g
i.v = f
n.p = e
n.z = e
c.p = a
c.z = n
g.s = b
j.s = b
l.s = g
f.p = g
f.v = i
e.p = n
e.z = a
assert f.p.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
i = C("i")
n = B("n")
c = B("c")
g = A("g")
j = A("j")
l = A("l")
f = C("f")
e = B("e")

b.s = g
a.p = e
a.z = e
i.p = g
i.v = f
n.p = e
n.z = e
c.p = a
c.z = n
g.s = b
j.s = b
l.s = g
f.p = g
f.v = i
e.p = n
e.z = a
assert f.p.s.s.s.txt == "b"