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

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

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

b = A("b")
i = B("i")
j = C("j")

b.q = i
i.y = b
j.v = i
assert j.v.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
j = C("j")

b.q = i
i.y = b
j.v = i
assert j.v.y.q.txt == "i"