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

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

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

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

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

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

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

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

n.y = h
i.s = m
i.u = m
i.y = h
m.t = i
m.u = i
m.v = n
h.s = m
h.u = m
h.y = i
assert n.y.u.t.u.txt == "m"