class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: C = 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: B = None
        self.v: B = None
        self.txt = txt

m = A("m")
c = B("c")
j = C("j")

m.y = c
m.v = j
c.v = j
j.w = c
j.v = c
assert m.y.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: C = 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: B = None
        self.v: B = None
        self.txt = txt

m = A("m")
c = B("c")
j = C("j")

m.y = c
m.v = j
c.v = j
j.w = c
j.v = c
assert m.y.v.v.txt == "c"