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

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

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

m = A("m")
k = B("k")
e = C("e")

m.u = e
k.y = m
e.x = k
assert m.u.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
e = C("e")

m.u = e
k.y = m
e.x = k
assert m.u.x.y.txt == "m"