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

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

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

a = A("a")
k = B("k")
b = C("b")
g = B("g")
f = A("f")
c = C("c")

a.o = b
a.s = f
a.t = g
k.v = g
k.y = b
b.p = k
g.v = k
g.y = b
f.o = c
f.s = a
f.t = g
c.p = k
assert b.p.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: A = None
        self.t: B = None
        self.txt = txt

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

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

a = A("a")
k = B("k")
b = C("b")
g = B("g")
f = A("f")
c = C("c")

a.o = b
a.s = f
a.t = g
k.v = g
k.y = b
b.p = k
g.v = k
g.y = b
f.o = c
f.s = a
f.t = g
c.p = k
assert b.p.v.v.v.txt == "g"