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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.y: D = None
        self.v: D = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
l = C("l")
h = D("h")
k = E("k")
i = A("i")
g = D("g")

d.y = k
d.s = c
c.r = k
l.s = k
l.o = i
l.y = g
l.v = h
h.p = c
k.q = l
i.y = k
i.s = c
g.p = c
assert c.r.q.o.s.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.s: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.y: D = None
        self.v: D = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
l = C("l")
h = D("h")
k = E("k")
i = A("i")
g = D("g")

d.y = k
d.s = c
c.r = k
l.s = k
l.o = i
l.y = g
l.v = h
h.p = c
k.q = l
i.y = k
i.s = c
g.p = c
assert c.r.q.o.s.r.q.txt == "l"