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

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: B = None
        self.u: A = None
        self.t: D = None
        self.txt = txt

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

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

m.o = j
b.o = i
b.y = f
b.p = h
f.p = m
f.q = l
f.u = j
f.t = g
k.z = m
k.s = m
k.p = f
h.o = l
h.y = f
h.p = b
g.z = m
g.p = f
g.s = j
j.o = m
d.o = h
d.y = f
d.p = b
l.o = d
l.p = d
l.y = f
i.o = b
i.y = f
i.p = l
assert h.o.o.o.o.y.u.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: B = None
        self.u: A = None
        self.t: D = None
        self.txt = txt

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

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

m.o = j
b.o = i
b.y = f
b.p = h
f.p = m
f.q = l
f.u = j
f.t = g
k.z = m
k.s = m
k.p = f
h.o = l
h.y = f
h.p = b
g.z = m
g.p = f
g.s = j
j.o = m
d.o = h
d.y = f
d.p = b
l.o = d
l.p = d
l.y = f
i.o = b
i.y = f
i.p = l
assert h.o.o.o.o.y.u.o.o.txt == "j"