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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: C = None
        self.v: B = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.w: D = None
        self.txt = txt

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

j.u = l
l.y = j
l.u = j
l.q = h
h.v = n
a.q = n
a.r = h
a.s = h
a.v = l
n.v = h
n.q = h
n.w = a
assert h.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: C = None
        self.v: B = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.q: C = None
        self.w: D = None
        self.txt = txt

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

j.u = l
l.y = j
l.u = j
l.q = h
h.v = n
a.q = n
a.r = h
a.s = h
a.v = l
n.v = h
n.q = h
n.w = a
assert h.v.v.v.v.txt == "h"