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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: F = None
        self.p: F = None
        self.s: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.v: F = None
        self.t: C = None
        self.u: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.x: F = None
        self.p: F = None
        self.s: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: F = None
        self.v: F = None
        self.t: C = None
        self.u: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

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

a.w = m
k.y = c
k.r = h
b.z = h
b.x = j
b.p = j
b.s = k
i.s = e
i.o = c
e.y = m
e.v = m
e.t = g
e.u = i
m.x = e
h.s = c
h.o = c
c.y = m
c.v = j
c.t = b
c.u = i
j.x = c
g.z = h
g.x = j
g.p = j
g.s = k
assert m.x.u.o.txt == "c"