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

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

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

j = A("j")
m = B("m")
n = C("n")
i = C("i")

j.y = m
m.u = i
m.s = j
m.o = j
n.u = j
n.p = j
n.x = i
i.u = j
i.p = j
i.x = n
assert n.x.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

j = A("j")
m = B("m")
n = C("n")
i = C("i")

j.y = m
m.u = i
m.s = j
m.o = j
n.u = j
n.p = j
n.x = i
i.u = j
i.p = j
i.x = n
assert n.x.x.u.txt == "j"