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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

m = A("m")
l = B("l")
g = C("g")
b = D("b")
i = E("i")
a = D("a")
f = A("f")
j = E("j")

m.v = l
m.y = l
m.p = l
m.r = b
l.p = g
g.y = a
b.p = g
i.x = a
i.q = b
a.p = g
f.v = l
f.y = l
f.p = l
f.r = b
j.x = a
j.q = a
assert f.p.p.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: B = None
        self.r: D = None
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

m = A("m")
l = B("l")
g = C("g")
b = D("b")
i = E("i")
a = D("a")
f = A("f")
j = E("j")

m.v = l
m.y = l
m.p = l
m.r = b
l.p = g
g.y = a
b.p = g
i.x = a
i.q = b
a.p = g
f.v = l
f.y = l
f.p = l
f.r = b
j.x = a
j.q = a
assert f.p.p.y.p.y.txt == "a"