class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.s: E = None
        self.q: E = None
        self.txt = txt

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

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

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

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

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

l.p = d
l.w = d
l.s = e
l.q = e
h.w = l
h.v = e
h.r = d
h.z = d
h.x = g
d.q = h
g.x = c
e.x = c
c.w = l
c.v = e
c.r = d
c.z = d
c.x = g
assert c.v.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: C = None
        self.s: E = None
        self.q: E = None
        self.txt = txt

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

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

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

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

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

l.p = d
l.w = d
l.s = e
l.q = e
h.w = l
h.v = e
h.r = d
h.z = d
h.x = g
d.q = h
g.x = c
e.x = c
c.w = l
c.v = e
c.r = d
c.z = d
c.x = g
assert c.v.x.x.x.x.x.txt == "c"