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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

c = A("c")
g = B("g")
l = C("l")

c.r = g
c.q = l
c.v = l
g.o = c
l.x = c
assert g.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

c = A("c")
g = B("g")
l = C("l")

c.r = g
c.q = l
c.v = l
g.o = c
l.x = c
assert g.o.r.o.txt == "c"