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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: B = None
        self.o: F = None
        self.r: D = None
        self.txt = txt

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

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

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

h = A("h")
d = B("d")
k = C("k")
i = D("i")
g = E("g")
a = F("a")

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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: B = None
        self.o: F = None
        self.r: D = None
        self.txt = txt

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

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

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

h = A("h")
d = B("d")
k = C("k")
i = D("i")
g = E("g")
a = F("a")

h.o = a
h.q = k
d.z = a
d.y = h
d.p = g
d.s = i
k.q = g
k.w = d
k.o = a
k.r = i
i.o = a
g.t = d
g.z = d
g.o = k
g.s = k
g.q = a
a.u = k
a.p = k
assert g.o.r.o.txt == "a"