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

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

h = A("h")
j = B("j")
b = C("b")
g = D("g")
m = B("m")
l = B("l")
k = D("k")
e = B("e")
i = A("i")

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

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

h = A("h")
j = B("j")
b = C("b")
g = D("g")
m = B("m")
l = B("l")
k = D("k")
e = B("e")
i = A("i")

h.q = i
h.w = l
j.z = l
b.z = i
b.o = h
b.q = l
b.t = j
g.u = k
g.p = k
g.r = m
g.w = m
m.z = e
l.z = j
k.u = g
k.p = g
k.r = j
k.w = e
e.z = m
i.q = h
i.w = m
assert h.q.w.z.txt == "e"