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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.t: D = None
        self.y: D = None
        self.q: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

h = A("h")
d = B("d")
m = C("m")
k = D("k")
e = E("e")
f = F("f")

h.p = f
h.q = m
d.z = h
d.x = e
d.w = m
m.s = d
k.s = f
e.u = m
e.x = m
e.t = k
e.y = k
e.q = h
f.u = h
assert h.q.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.t: D = None
        self.y: D = None
        self.q: A = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

h = A("h")
d = B("d")
m = C("m")
k = D("k")
e = E("e")
f = F("f")

h.p = f
h.q = m
d.z = h
d.x = e
d.w = m
m.s = d
k.s = f
e.u = m
e.x = m
e.t = k
e.y = k
e.q = h
f.u = h
assert h.q.s.w.txt == "m"