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

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

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

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

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

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

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

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

g.v = e
g.p = e
g.s = n
n.r = g
n.t = e
e.s = n
e.x = n
e.w = g
assert e.w.s.r.txt == "g"