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

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

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

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

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

a = A("a")
h = B("h")
f = C("f")
d = D("d")
l = E("l")
k = E("k")
c = A("c")
j = D("j")
n = C("n")
m = B("m")

a.x = l
a.y = h
a.w = d
h.u = m
f.x = l
d.t = h
l.u = k
l.r = a
l.y = h
k.u = l
k.r = a
k.y = m
c.x = l
c.y = h
c.w = d
j.t = m
n.x = k
m.u = h
assert k.r.x.u.r.y.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.y: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

a = A("a")
h = B("h")
f = C("f")
d = D("d")
l = E("l")
k = E("k")
c = A("c")
j = D("j")
n = C("n")
m = B("m")

a.x = l
a.y = h
a.w = d
h.u = m
f.x = l
d.t = h
l.u = k
l.r = a
l.y = h
k.u = l
k.r = a
k.y = m
c.x = l
c.y = h
c.w = d
j.t = m
n.x = k
m.u = h
assert k.r.x.u.r.y.u.u.u.txt == "m"