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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: F = None
        self.s: D = None
        self.o: F = None
        self.p: D = None
        self.txt = txt

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

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

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

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

a = A("a")
g = B("g")
h = C("h")
m = D("m")
k = E("k")
f = F("f")

a.s = h
a.z = h
a.w = f
a.r = m
a.u = m
g.t = m
g.s = m
g.p = m
g.z = f
g.o = f
h.w = a
h.s = a
h.y = g
m.w = g
k.r = g
f.p = g
f.r = m
assert m.w.t.w.z.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: F = None
        self.r: D = None
        self.z: C = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: F = None
        self.s: D = None
        self.o: F = None
        self.p: D = None
        self.txt = txt

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

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

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

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

a = A("a")
g = B("g")
h = C("h")
m = D("m")
k = E("k")
f = F("f")

a.s = h
a.z = h
a.w = f
a.r = m
a.u = m
g.t = m
g.s = m
g.p = m
g.z = f
g.o = f
h.w = a
h.s = a
h.y = g
m.w = g
k.r = g
f.p = g
f.r = m
assert m.w.t.w.z.p.t.txt == "m"