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.txt = txt

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

h = A("h")
k = B("k")
a = C("a")
n = C("n")
b = A("b")
m = A("m")

h.y = k
k.u = n
a.v = m
a.p = n
a.x = k
n.v = b
n.p = a
n.x = k
b.y = k
m.y = k
assert b.y.u.p.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.txt = txt

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

h = A("h")
k = B("k")
a = C("a")
n = C("n")
b = A("b")
m = A("m")

h.y = k
k.u = n
a.v = m
a.p = n
a.x = k
n.v = b
n.p = a
n.x = k
b.y = k
m.y = k
assert b.y.u.p.x.u.txt == "n"