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

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: D = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

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

j = A("j")
i = B("i")
k = C("k")
l = D("l")
h = B("h")
m = B("m")
c = A("c")
d = C("d")

j.y = c
j.o = h
i.o = l
i.r = c
k.x = j
k.q = j
k.u = l
k.s = c
l.r = c
h.o = l
h.r = c
m.o = l
m.r = c
c.y = j
c.o = m
d.x = c
d.u = l
d.q = j
d.s = j
assert d.x.o.r.y.o.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: D = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

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

j = A("j")
i = B("i")
k = C("k")
l = D("l")
h = B("h")
m = B("m")
c = A("c")
d = C("d")

j.y = c
j.o = h
i.o = l
i.r = c
k.x = j
k.q = j
k.u = l
k.s = c
l.r = c
h.o = l
h.r = c
m.o = l
m.r = c
c.y = j
c.o = m
d.x = c
d.u = l
d.q = j
d.s = j
assert d.x.o.r.y.o.o.r.o.txt == "m"