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

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

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

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

b.p = e
b.u = i
c.v = e
c.s = i
g.w = b
g.p = b
i.w = b
i.p = b
k.v = c
k.s = i
e.v = k
e.s = g
assert c.v.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: C = None
        self.txt = txt

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

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

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

b.p = e
b.u = i
c.v = e
c.s = i
g.w = b
g.p = b
i.w = b
i.p = b
k.v = c
k.s = i
e.v = k
e.s = g
assert c.v.v.s.txt == "i"