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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: D = None
        self.v: H = None
        self.w: F = None
        self.t: F = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: G = None
        self.v: B = None
        self.x: F = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.z: G = None
        self.txt = txt

c = A("c")
i = B("i")
m = C("m")
j = D("j")
g = E("g")
b = F("b")
l = G("l")
k = H("k")

c.w = i
i.q = j
i.u = j
i.v = k
i.w = b
i.t = b
i.x = m
m.p = l
m.v = i
m.x = b
j.o = g
g.o = k
b.p = j
b.w = m
l.x = i
k.z = l
assert l.x.t.w.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.u: D = None
        self.v: H = None
        self.w: F = None
        self.t: F = None
        self.x: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: G = None
        self.v: B = None
        self.x: F = None
        self.txt = txt

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

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

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

class G:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.z: G = None
        self.txt = txt

c = A("c")
i = B("i")
m = C("m")
j = D("j")
g = E("g")
b = F("b")
l = G("l")
k = H("k")

c.w = i
i.q = j
i.u = j
i.v = k
i.w = b
i.t = b
i.x = m
m.p = l
m.v = i
m.x = b
j.o = g
g.o = k
b.p = j
b.w = m
l.x = i
k.z = l
assert l.x.t.w.x.w.txt == "m"