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

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

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

n = A("n")
c = B("c")
h = C("h")
e = B("e")
a = A("a")
j = A("j")
l = B("l")
d = A("d")

n.w = a
c.u = l
c.p = d
h.v = l
e.u = l
e.p = d
a.w = d
j.w = a
l.u = c
l.p = n
d.w = j
assert j.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

n = A("n")
c = B("c")
h = C("h")
e = B("e")
a = A("a")
j = A("j")
l = B("l")
d = A("d")

n.w = a
c.u = l
c.p = d
h.v = l
e.u = l
e.p = d
a.w = d
j.w = a
l.u = c
l.p = n
d.w = j
assert j.w.w.w.w.w.w.txt == "j"