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

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: E = None
        self.x: C = None
        self.o: E = None
        self.p: B = None
        self.txt = txt

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

g = A("g")
l = B("l")
m = C("m")
a = D("a")
d = E("d")
c = C("c")
f = D("f")
b = E("b")

g.p = a
l.r = c
m.p = d
m.r = c
a.w = b
a.q = b
a.o = b
a.x = m
a.p = l
d.r = b
d.z = f
d.s = a
c.p = b
c.r = m
f.w = b
f.q = b
f.o = b
f.x = c
f.p = l
b.r = d
b.z = a
b.s = a
assert g.p.p.r.r.p.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: E = None
        self.q: E = None
        self.x: C = None
        self.o: E = None
        self.p: B = None
        self.txt = txt

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

g = A("g")
l = B("l")
m = C("m")
a = D("a")
d = E("d")
c = C("c")
f = D("f")
b = E("b")

g.p = a
l.r = c
m.p = d
m.r = c
a.w = b
a.q = b
a.o = b
a.x = m
a.p = l
d.r = b
d.z = f
d.s = a
c.p = b
c.r = m
f.w = b
f.q = b
f.o = b
f.x = c
f.p = l
b.r = d
b.z = a
b.s = a
assert g.p.p.r.r.p.z.w.txt == "b"