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

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

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

class D:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: A = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: D = None
        self.o: A = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: A = None
        self.o: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: D = None
        self.o: A = None
        self.txt = txt

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

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

c.o = m
f.w = m
f.r = c
f.y = e
g.u = e
g.s = f
g.q = m
k.t = d
k.x = c
k.o = a
a.w = g
a.u = d
a.o = c
m.q = e
i.w = m
i.r = c
i.y = e
e.w = m
e.r = c
e.y = i
h.u = f
h.s = e
h.q = m
d.t = k
d.x = c
d.o = a
assert d.t.x.o.txt == "m"