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

i = A("i")
j = B("j")
h = C("h")
f = A("f")

i.o = h
j.v = i
h.y = f
h.q = j
f.o = h
assert h.y.o.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: 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.y: A = None
        self.q: B = None
        self.txt = txt

i = A("i")
j = B("j")
h = C("h")
f = A("f")

i.o = h
j.v = i
h.y = f
h.q = j
f.o = h
assert h.y.o.q.v.txt == "i"