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

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

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

l = A("l")
b = B("b")
d = C("d")

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

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

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

l = A("l")
b = B("b")
d = C("d")

l.u = b
l.v = d
b.q = l
d.o = b
d.r = b
assert d.r.q.v.txt == "d"