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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: C = None
        self.w: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: D = None
        self.v: B = 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.r: C = None
        self.v: D = None
        self.p: E = None
        self.txt = txt

b = A("b")
k = B("k")
i = C("i")
h = D("h")
a = E("a")
m = E("m")
c = A("c")
l = A("l")

b.q = l
b.x = h
k.x = h
k.r = i
k.w = c
i.r = a
i.q = h
i.v = k
h.u = m
a.r = i
a.v = h
a.p = m
m.r = i
m.v = h
m.p = a
c.q = l
c.x = h
l.q = b
l.x = h
assert a.p.p.p.r.r.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.r: C = None
        self.w: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: D = None
        self.v: B = 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.r: C = None
        self.v: D = None
        self.p: E = None
        self.txt = txt

b = A("b")
k = B("k")
i = C("i")
h = D("h")
a = E("a")
m = E("m")
c = A("c")
l = A("l")

b.q = l
b.x = h
k.x = h
k.r = i
k.w = c
i.r = a
i.q = h
i.v = k
h.u = m
a.r = i
a.v = h
a.p = m
m.r = i
m.v = h
m.p = a
c.q = l
c.x = h
l.q = b
l.x = h
assert a.p.p.p.r.r.v.u.txt == "m"