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

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

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

g = A("g")
e = B("e")
c = C("c")

g.v = e
g.t = c
e.v = g
e.y = g
e.x = c
c.p = g
c.v = e
assert c.p.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.t: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
c = C("c")

g.v = e
g.t = c
e.v = g
e.y = g
e.x = c
c.p = g
c.v = e
assert c.p.v.x.txt == "c"