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

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

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

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

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

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

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

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

j.x = m
h.y = k
e.u = h
e.w = k
k.y = h
m.x = j
assert e.u.y.y.txt == "h"