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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: A = None
        self.y: C = None
        self.txt = txt

f = A("f")
c = B("c")
e = C("e")
n = D("n")
j = E("j")
m = A("m")
g = C("g")
l = D("l")

f.p = n
f.s = n
f.x = c
c.x = e
c.u = j
e.u = g
n.u = j
n.x = l
n.r = f
j.u = f
j.t = f
j.y = g
m.p = l
m.s = n
m.x = c
g.u = e
l.u = j
l.x = n
l.r = m
assert l.r.p.r.s.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.s: D = None
        self.x: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: A = None
        self.y: C = None
        self.txt = txt

f = A("f")
c = B("c")
e = C("e")
n = D("n")
j = E("j")
m = A("m")
g = C("g")
l = D("l")

f.p = n
f.s = n
f.x = c
c.x = e
c.u = j
e.u = g
n.u = j
n.x = l
n.r = f
j.u = f
j.t = f
j.y = g
m.p = l
m.s = n
m.x = c
g.u = e
l.u = j
l.x = n
l.r = m
assert l.r.p.r.s.r.p.txt == "n"