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

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

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

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

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

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

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

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

j.u = h
h.u = m
h.y = n
h.s = j
m.s = j
n.s = j
assert h.u.s.u.txt == "h"