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

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

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

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

k.y = e
e.x = a
e.y = a
a.v = k
assert e.x.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

k.y = e
e.x = a
e.y = a
a.v = k
assert e.x.v.y.txt == "e"