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

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

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

n = A("n")
h = B("h")
l = C("l")
e = C("e")
f = B("f")
d = A("d")

n.x = d
n.s = d
h.p = n
h.x = f
h.u = f
l.t = e
l.x = e
e.t = l
e.x = l
f.p = d
f.x = h
f.u = h
d.x = n
d.s = n
assert n.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: A = None
        self.txt = txt

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

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

n = A("n")
h = B("h")
l = C("l")
e = C("e")
f = B("f")
d = A("d")

n.x = d
n.s = d
h.p = n
h.x = f
h.u = f
l.t = e
l.x = e
e.t = l
e.x = l
f.p = d
f.x = h
f.u = h
d.x = n
d.s = n
assert n.s.s.s.s.txt == "n"