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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: A = None
        self.txt = txt

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

n = A("n")
c = B("c")
d = C("d")
j = D("j")
i = E("i")
f = B("f")
h = E("h")
l = E("l")
m = A("m")

n.p = i
c.y = j
c.s = j
c.t = m
d.r = j
j.t = h
j.v = m
i.p = d
i.q = f
f.y = j
f.s = j
f.t = n
h.p = d
h.q = f
l.p = d
l.q = c
m.p = l
assert f.y.v.p.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.v: A = None
        self.txt = txt

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

n = A("n")
c = B("c")
d = C("d")
j = D("j")
i = E("i")
f = B("f")
h = E("h")
l = E("l")
m = A("m")

n.p = i
c.y = j
c.s = j
c.t = m
d.r = j
j.t = h
j.v = m
i.p = d
i.q = f
f.y = j
f.s = j
f.t = n
h.p = d
h.q = f
l.p = d
l.q = c
m.p = l
assert f.y.v.p.p.r.txt == "j"