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

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: A = None
        self.r: E = None
        self.txt = txt

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

b = A("b")
m = B("m")
d = C("d")
g = D("g")
h = E("h")
n = D("n")
a = E("a")
l = B("l")
j = C("j")

b.r = g
m.o = j
m.y = j
m.q = l
m.r = d
m.x = b
d.r = b
g.p = d
g.y = b
g.r = h
h.w = a
n.p = j
n.y = b
n.r = h
a.w = h
l.o = j
l.q = m
l.r = d
l.y = d
l.x = b
j.r = b
assert d.r.r.r.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: A = None
        self.r: E = None
        self.txt = txt

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

b = A("b")
m = B("m")
d = C("d")
g = D("g")
h = E("h")
n = D("n")
a = E("a")
l = B("l")
j = C("j")

b.r = g
m.o = j
m.y = j
m.q = l
m.r = d
m.x = b
d.r = b
g.p = d
g.y = b
g.r = h
h.w = a
n.p = j
n.y = b
n.r = h
a.w = h
l.o = j
l.q = m
l.r = d
l.y = d
l.x = b
j.r = b
assert d.r.r.r.w.w.w.txt == "a"