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

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

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

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

a = A("a")
e = B("e")
j = C("j")
l = D("l")
g = C("g")
m = C("m")
i = B("i")
d = B("d")
k = A("k")
c = B("c")

a.o = j
a.r = e
e.r = l
j.q = l
l.s = a
l.p = a
l.y = d
g.q = l
m.q = l
i.r = l
d.r = l
k.o = j
k.r = e
c.r = l
assert j.q.y.r.y.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: B = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
j = C("j")
l = D("l")
g = C("g")
m = C("m")
i = B("i")
d = B("d")
k = A("k")
c = B("c")

a.o = j
a.r = e
e.r = l
j.q = l
l.s = a
l.p = a
l.y = d
g.q = l
m.q = l
i.r = l
d.r = l
k.o = j
k.r = e
c.r = l
assert j.q.y.r.y.r.s.txt == "a"