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

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.x: C = None
        self.w: D = None
        self.txt = txt

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

j = A("j")
f = B("f")
m = C("m")
a = D("a")
i = C("i")
d = D("d")
n = B("n")
h = A("h")

j.o = i
f.s = n
f.w = n
f.r = m
m.u = h
m.o = f
m.x = i
m.w = d
a.o = n
a.w = d
a.u = j
i.u = j
i.o = f
i.x = m
i.w = d
d.o = f
d.w = a
d.u = j
n.s = f
n.w = f
n.r = i
h.o = m
assert j.o.o.s.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: B = None
        self.x: C = None
        self.w: D = None
        self.txt = txt

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

j = A("j")
f = B("f")
m = C("m")
a = D("a")
i = C("i")
d = D("d")
n = B("n")
h = A("h")

j.o = i
f.s = n
f.w = n
f.r = m
m.u = h
m.o = f
m.x = i
m.w = d
a.o = n
a.w = d
a.u = j
i.u = j
i.o = f
i.x = m
i.w = d
d.o = f
d.w = a
d.u = j
n.s = f
n.w = f
n.r = i
h.o = m
assert j.o.o.s.r.u.txt == "j"