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

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

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

l = A("l")
i = B("i")
f = C("f")
n = B("n")
g = A("g")
c = C("c")

l.s = n
l.o = g
i.v = c
i.p = f
f.p = g
f.t = i
n.v = c
n.p = f
g.s = i
g.o = l
c.p = l
c.t = i
assert f.t.p.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: A = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
f = C("f")
n = B("n")
g = A("g")
c = C("c")

l.s = n
l.o = g
i.v = c
i.p = f
f.p = g
f.t = i
n.v = c
n.p = f
g.s = i
g.o = l
c.p = l
c.t = i
assert f.t.p.p.o.o.txt == "g"