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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: D = None
        self.r: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: E = None
        self.w: A = None
        self.z: B = None
        self.q: A = None
        self.txt = txt

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

n = A("n")
g = B("g")
k = C("k")
h = D("h")
l = E("l")
c = B("c")
j = C("j")

n.r = h
n.q = h
g.z = h
g.v = h
k.o = l
k.x = h
k.r = j
h.s = g
h.r = l
h.w = n
h.q = n
h.z = c
l.q = j
l.w = n
l.x = h
c.z = h
c.v = h
j.o = l
j.x = h
j.r = k
assert h.r.w.q.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: D = None
        self.r: C = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: E = None
        self.w: A = None
        self.z: B = None
        self.q: A = None
        self.txt = txt

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

n = A("n")
g = B("g")
k = C("k")
h = D("h")
l = E("l")
c = B("c")
j = C("j")

n.r = h
n.q = h
g.z = h
g.v = h
k.o = l
k.x = h
k.r = j
h.s = g
h.r = l
h.w = n
h.q = n
h.z = c
l.q = j
l.w = n
l.x = h
c.z = h
c.v = h
j.o = l
j.x = h
j.r = k
assert h.r.w.q.r.w.txt == "n"