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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

c.s = i
c.t = g
f.t = c
f.u = i
f.s = a
f.z = a
f.q = k
a.o = c
a.w = g
a.x = g
a.q = i
i.x = a
k.p = h
k.o = a
g.x = f
g.y = h
g.o = c
g.z = c
h.x = f
h.y = g
h.o = c
h.z = c
assert a.q.x.q.x.txt == "a"