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

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

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

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

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

e.u = a
e.v = c
d.v = a
c.q = d
c.x = a
c.r = e
c.z = h
a.v = e
i.q = d
i.x = a
i.r = e
i.z = c
g.q = d
g.x = l
g.r = e
g.z = c
h.q = d
h.x = a
h.r = e
h.z = c
l.v = e
assert i.r.u.v.v.z.x.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.v: C = None
        self.txt = txt

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

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

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

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

e.u = a
e.v = c
d.v = a
c.q = d
c.x = a
c.r = e
c.z = h
a.v = e
i.q = d
i.x = a
i.r = e
i.z = c
g.q = d
g.x = l
g.r = e
g.z = c
h.q = d
h.x = a
h.r = e
h.z = c
l.v = e
assert i.r.u.v.v.z.x.v.u.txt == "a"