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

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

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

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

a = A("a")
l = B("l")
k = C("k")
d = D("d")
h = C("h")
f = C("f")
n = A("n")
j = A("j")

a.o = l
l.q = n
l.t = d
k.o = n
k.s = l
d.x = f
d.r = j
d.y = l
d.q = h
h.o = a
h.s = l
f.o = n
f.s = l
n.o = l
j.o = l
assert h.s.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
k = C("k")
d = D("d")
h = C("h")
f = C("f")
n = A("n")
j = A("j")

a.o = l
l.q = n
l.t = d
k.o = n
k.s = l
d.x = f
d.r = j
d.y = l
d.q = h
h.o = a
h.s = l
f.o = n
f.s = l
n.o = l
j.o = l
assert h.s.q.o.q.o.txt == "l"