class A:
    def __init__(self, txt: str):
        self.r: 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.o: A = None
        self.r: B = None
        self.s: B = None
        self.txt = txt

i = A("i")
h = B("h")
b = C("b")
a = A("a")

i.r = b
h.v = b
b.o = i
b.r = h
b.s = h
a.r = b
assert a.r.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: 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.o: A = None
        self.r: B = None
        self.s: B = None
        self.txt = txt

i = A("i")
h = B("h")
b = C("b")
a = A("a")

i.r = b
h.v = b
b.o = i
b.r = h
b.s = h
a.r = b
assert a.r.o.r.o.txt == "i"