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

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

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

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

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

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

l = A("l")
f = B("f")
a = C("a")
e = D("e")
i = E("i")
b = F("b")
m = B("m")

l.s = e
l.y = e
l.x = e
l.r = b
l.w = m
f.p = l
a.p = b
a.s = b
e.r = l
e.w = b
i.w = e
i.s = l
i.p = m
b.s = l
b.x = e
b.z = i
m.p = l
assert b.x.w.x.w.x.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: D = None
        self.r: F = None
        self.w: B = None
        self.x: D = None
        self.txt = txt

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

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

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

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

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

l = A("l")
f = B("f")
a = C("a")
e = D("e")
i = E("i")
b = F("b")
m = B("m")

l.s = e
l.y = e
l.x = e
l.r = b
l.w = m
f.p = l
a.p = b
a.s = b
e.r = l
e.w = b
i.w = e
i.s = l
i.p = m
b.s = l
b.x = e
b.z = i
m.p = l
assert b.x.w.x.w.x.w.x.txt == "e"