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

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: C = 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: B = None
        self.r: D = None
        self.txt = txt

d = A("d")
a = B("a")
n = C("n")
h = D("h")
e = E("e")
c = D("c")
b = C("b")
f = A("f")
m = A("m")

d.y = m
d.u = a
a.r = e
a.w = e
a.x = h
n.v = b
n.r = b
h.t = a
e.u = a
e.r = c
c.t = a
b.v = n
b.r = n
f.y = d
f.u = a
m.y = d
m.u = a
assert a.x.t.x.t.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: C = 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: B = None
        self.r: D = None
        self.txt = txt

d = A("d")
a = B("a")
n = C("n")
h = D("h")
e = E("e")
c = D("c")
b = C("b")
f = A("f")
m = A("m")

d.y = m
d.u = a
a.r = e
a.w = e
a.x = h
n.v = b
n.r = b
h.t = a
e.u = a
e.r = c
c.t = a
b.v = n
b.r = n
f.y = d
f.u = a
m.y = d
m.u = a
assert a.x.t.x.t.r.u.txt == "a"