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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

a = A("a")
k = B("k")
d = C("d")
i = B("i")

a.q = i
a.r = d
a.v = d
k.r = d
d.o = k
d.u = a
i.r = d
assert a.r.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: C = None
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

a = A("a")
k = B("k")
d = C("d")
i = B("i")

a.q = i
a.r = d
a.v = d
k.r = d
d.o = k
d.u = a
i.r = d
assert a.r.o.r.o.txt == "k"