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

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

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

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

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

l = A("l")
g = B("g")
e = C("e")
n = D("n")
m = E("m")
k = B("k")
h = D("h")
a = A("a")
i = A("i")

l.r = k
l.t = k
g.r = m
e.w = m
e.p = l
e.r = i
e.t = g
n.p = k
n.v = g
n.u = e
m.x = k
k.r = m
h.p = g
h.v = k
h.u = e
a.r = k
a.t = g
i.r = g
i.t = g
assert m.x.r.x.r.x.r.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

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

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

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

l = A("l")
g = B("g")
e = C("e")
n = D("n")
m = E("m")
k = B("k")
h = D("h")
a = A("a")
i = A("i")

l.r = k
l.t = k
g.r = m
e.w = m
e.p = l
e.r = i
e.t = g
n.p = k
n.v = g
n.u = e
m.x = k
k.r = m
h.p = g
h.v = k
h.u = e
a.r = k
a.t = g
i.r = g
i.t = g
assert m.x.r.x.r.x.r.x.r.x.txt == "k"