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

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

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

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

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

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

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

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

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