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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: A = None
        self.txt = txt

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

m.u = b
m.w = c
c.u = b
c.y = f
c.w = m
f.r = e
f.x = b
e.x = b
b.o = e
b.w = n
d.s = f
d.y = n
h.s = f
h.y = m
n.u = b
n.w = c
assert e.x.o.x.w.w.y.x.txt == "b"