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

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: B = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
c = C("c")
d = D("d")
l = E("l")
g = F("g")
m = D("m")
n = E("n")
e = A("e")

k.p = b
b.p = l
b.r = d
b.z = n
b.u = m
c.p = n
d.u = m
d.y = b
d.s = g
d.x = l
l.r = b
g.q = b
g.x = b
g.p = m
m.u = d
m.y = b
m.s = g
m.x = n
n.r = b
e.p = b
assert n.r.u.s.x.r.x.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: B = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
c = C("c")
d = D("d")
l = E("l")
g = F("g")
m = D("m")
n = E("n")
e = A("e")

k.p = b
b.p = l
b.r = d
b.z = n
b.u = m
c.p = n
d.u = m
d.y = b
d.s = g
d.x = l
l.r = b
g.q = b
g.x = b
g.p = m
m.u = d
m.y = b
m.s = g
m.x = n
n.r = b
e.p = b
assert n.r.u.s.x.r.x.r.p.r.txt == "b"