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

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

d = A("d")
i = B("i")
a = C("a")
l = D("l")
g = E("g")
k = B("k")
f = B("f")

d.x = l
i.o = d
i.r = a
i.p = g
a.x = g
a.z = l
l.q = k
g.v = d
k.o = d
k.r = a
k.p = g
f.o = d
f.r = a
f.p = g
assert d.x.q.r.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

d = A("d")
i = B("i")
a = C("a")
l = D("l")
g = E("g")
k = B("k")
f = B("f")

d.x = l
i.o = d
i.r = a
i.p = g
a.x = g
a.z = l
l.q = k
g.v = d
k.o = d
k.r = a
k.p = g
f.o = d
f.r = a
f.p = g
assert d.x.q.r.z.q.txt == "k"