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

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

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

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

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

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

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

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

c.w = n
n.r = b
n.v = b
b.y = c
g.w = n
m.r = b
m.v = b
assert g.w.r.y.w.txt == "n"