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

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

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

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

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

g = A("g")
j = B("j")
d = C("d")
i = D("i")
a = E("a")
c = B("c")

g.v = i
j.r = c
j.p = a
j.v = d
d.s = j
d.r = i
i.r = d
i.q = g
a.v = i
a.u = g
c.r = j
c.p = a
c.v = d
assert c.p.u.v.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

g = A("g")
j = B("j")
d = C("d")
i = D("i")
a = E("a")
c = B("c")

g.v = i
j.r = c
j.p = a
j.v = d
d.s = j
d.r = i
i.r = d
i.q = g
a.v = i
a.u = g
c.r = j
c.p = a
c.v = d
assert c.p.u.v.r.r.r.txt == "d"