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

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

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

b = A("b")
c = B("c")
h = C("h")

b.r = c
c.v = h
c.r = h
c.y = h
h.t = c
assert c.v.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
h = C("h")

b.r = c
c.v = h
c.r = h
c.y = h
h.t = c
assert c.v.t.r.txt == "h"