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

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: D = None
        self.t: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: D = None
        self.u: D = None
        self.txt = txt

b = A("b")
g = B("g")
d = C("d")
f = D("f")
h = C("h")
k = A("k")
a = D("a")
m = C("m")

b.y = f
b.o = m
b.w = m
b.z = a
g.y = a
g.r = a
g.z = b
d.y = m
d.z = f
d.t = b
f.o = g
f.q = a
f.u = a
h.y = m
h.z = f
h.t = k
k.y = a
k.o = d
k.w = d
k.z = f
a.o = g
a.q = f
a.u = f
m.y = h
m.z = a
m.t = b
assert h.z.o.r.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: C = None
        self.w: C = None
        self.z: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: D = None
        self.t: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: D = None
        self.u: D = None
        self.txt = txt

b = A("b")
g = B("g")
d = C("d")
f = D("f")
h = C("h")
k = A("k")
a = D("a")
m = C("m")

b.y = f
b.o = m
b.w = m
b.z = a
g.y = a
g.r = a
g.z = b
d.y = m
d.z = f
d.t = b
f.o = g
f.q = a
f.u = a
h.y = m
h.z = f
h.t = k
k.y = a
k.o = d
k.w = d
k.z = f
a.o = g
a.q = f
a.u = f
m.y = h
m.z = a
m.t = b
assert h.z.o.r.u.q.txt == "a"