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

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: D = None
        self.q: A = None
        self.o: E = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
h = C("h")
e = D("e")
m = E("m")
g = F("g")

f.y = g
f.z = m
b.t = g
b.q = g
b.s = g
h.x = b
h.s = e
h.q = f
h.o = m
e.s = m
e.y = m
m.s = b
m.r = b
m.q = g
g.w = h
g.z = h
g.t = f
g.o = f
assert h.q.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.s: D = None
        self.q: A = None
        self.o: E = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
h = C("h")
e = D("e")
m = E("m")
g = F("g")

f.y = g
f.z = m
b.t = g
b.q = g
b.s = g
h.x = b
h.s = e
h.q = f
h.o = m
e.s = m
e.y = m
m.s = b
m.r = b
m.q = g
g.w = h
g.z = h
g.t = f
g.o = f
assert h.q.z.q.txt == "g"