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

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

h = A("h")
j = B("j")
c = C("c")
n = D("n")
l = E("l")
a = D("a")
i = B("i")
m = C("m")

h.u = c
j.y = c
c.v = h
c.s = a
n.u = l
l.s = a
a.u = l
i.y = m
m.v = h
m.s = a
assert j.y.s.u.s.u.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

h = A("h")
j = B("j")
c = C("c")
n = D("n")
l = E("l")
a = D("a")
i = B("i")
m = C("m")

h.u = c
j.y = c
c.v = h
c.s = a
n.u = l
l.s = a
a.u = l
i.y = m
m.v = h
m.s = a
assert j.y.s.u.s.u.s.u.s.txt == "a"