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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.t: D = None
        self.q: D = None
        self.w: D = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
h = C("h")
i = D("i")
g = E("g")
b = B("b")
a = D("a")
e = C("e")

j.p = h
j.z = i
j.x = g
c.p = g
c.u = g
c.v = j
h.r = b
h.s = a
h.w = a
h.t = i
h.q = i
i.r = e
i.s = g
g.p = b
b.p = g
b.u = g
b.v = j
a.r = h
a.s = g
e.r = b
e.s = i
e.w = i
e.t = a
e.q = a
assert i.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: D = None
        self.x: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.t: D = None
        self.q: D = None
        self.w: D = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
h = C("h")
i = D("i")
g = E("g")
b = B("b")
a = D("a")
e = C("e")

j.p = h
j.z = i
j.x = g
c.p = g
c.u = g
c.v = j
h.r = b
h.s = a
h.w = a
h.t = i
h.q = i
i.r = e
i.s = g
g.p = b
b.p = g
b.u = g
b.v = j
a.r = h
a.s = g
e.r = b
e.s = i
e.w = i
e.t = a
e.q = a
assert i.s.p.p.txt == "g"