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

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

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

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

n.y = g
g.v = b
b.w = n
b.s = g
assert g.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

n.y = g
g.v = b
b.w = n
b.s = g
assert g.v.s.v.txt == "b"