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

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

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

i = A("i")
k = B("k")
b = C("b")
l = C("l")

i.r = k
k.w = l
b.q = k
b.y = i
l.q = k
l.y = i
assert k.w.q.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

i = A("i")
k = B("k")
b = C("b")
l = C("l")

i.r = k
k.w = l
b.q = k
b.y = i
l.q = k
l.y = i
assert k.w.q.w.q.txt == "k"