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

class B:
    def __init__(self, txt: str):
        self.o: C = 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.o: D = None
        self.v: C = None
        self.txt = txt

h = A("h")
d = B("d")
n = C("n")
f = D("f")
e = D("e")
c = C("c")
g = D("g")
j = C("j")

h.y = d
d.o = c
n.q = g
f.o = g
f.v = n
e.o = g
e.v = n
c.q = g
g.o = e
g.v = j
j.q = e
assert f.o.v.q.o.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = 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.o: D = None
        self.v: C = None
        self.txt = txt

h = A("h")
d = B("d")
n = C("n")
f = D("f")
e = D("e")
c = C("c")
g = D("g")
j = C("j")

h.y = d
d.o = c
n.q = g
f.o = g
f.v = n
e.o = g
e.v = n
c.q = g
g.o = e
g.v = j
j.q = e
assert f.o.v.q.o.v.q.txt == "e"