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

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

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

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

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

l = A("l")
e = B("e")
a = C("a")
i = D("i")
g = E("g")
c = B("c")

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

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

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

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

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

l = A("l")
e = B("e")
a = C("a")
i = D("i")
g = E("g")
c = B("c")

l.o = i
e.p = l
e.x = l
e.r = i
a.s = l
a.v = c
a.z = i
i.r = l
i.t = l
i.v = e
i.q = g
g.x = a
c.p = l
c.x = l
c.r = i
assert g.x.z.v.p.txt == "l"