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.t: A = None
        self.txt = txt

n = A("n")
g = B("g")
f = B("f")
a = A("a")
c = A("c")
i = A("i")
e = B("e")

n.s = c
g.p = f
g.t = c
f.p = g
f.t = c
a.s = n
c.s = a
i.s = c
e.p = f
e.t = c
assert f.p.p.p.t.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.t: A = None
        self.txt = txt

n = A("n")
g = B("g")
f = B("f")
a = A("a")
c = A("c")
i = A("i")
e = B("e")

n.s = c
g.p = f
g.t = c
f.p = g
f.t = c
a.s = n
c.s = a
i.s = c
e.p = f
e.t = c
assert f.p.p.p.t.s.txt == "a"