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

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

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

h = A("h")
k = B("k")
l = C("l")

h.r = k
h.q = l
k.v = h
k.u = l
l.x = k
l.u = k
l.w = h
assert k.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.q: C = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
l = C("l")

h.r = k
h.q = l
k.v = h
k.u = l
l.x = k
l.u = k
l.w = h
assert k.u.w.q.txt == "l"