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

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

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

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

m.y = h
c.v = m
h.r = c
j.v = m
assert m.y.r.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

m.y = h
c.v = m
h.r = c
j.v = m
assert m.y.r.v.y.txt == "h"