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

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

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

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

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

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

h = A("h")
m = B("m")
n = C("n")
a = D("a")
l = E("l")
b = F("b")

h.p = b
h.y = b
h.w = b
m.s = l
m.y = b
n.w = m
n.s = h
n.t = b
a.y = m
l.z = m
l.w = m
b.y = m
b.s = h
assert l.w.y.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.y: F = None
        self.w: F = None
        self.txt = txt

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

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

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

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

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

h = A("h")
m = B("m")
n = C("n")
a = D("a")
l = E("l")
b = F("b")

h.p = b
h.y = b
h.w = b
m.s = l
m.y = b
n.w = m
n.s = h
n.t = b
a.y = m
l.z = m
l.w = m
b.y = m
b.s = h
assert l.w.y.s.w.txt == "b"