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

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

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

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

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

h = A("h")
f = B("f")
b = C("b")
d = D("d")
g = E("g")
i = C("i")
n = B("n")

h.s = d
h.w = i
h.v = b
h.p = g
f.u = n
f.s = g
b.s = h
b.w = i
b.q = i
d.u = i
d.q = i
g.w = f
g.q = i
g.r = h
i.s = h
i.w = b
i.q = b
n.u = f
n.s = g
assert d.q.q.s.p.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.w: C = None
        self.v: C = None
        self.p: E = None
        self.txt = txt

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

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

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

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

h = A("h")
f = B("f")
b = C("b")
d = D("d")
g = E("g")
i = C("i")
n = B("n")

h.s = d
h.w = i
h.v = b
h.p = g
f.u = n
f.s = g
b.s = h
b.w = i
b.q = i
d.u = i
d.q = i
g.w = f
g.q = i
g.r = h
i.s = h
i.w = b
i.q = b
n.u = f
n.s = g
assert d.q.q.s.p.q.q.txt == "b"