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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: A = None
        self.r: B = None
        self.t: C = None
        self.txt = txt

k = A("k")
b = B("b")
g = C("g")
n = D("n")
d = E("d")
h = A("h")

k.p = h
b.v = d
b.t = d
b.w = h
g.r = b
g.z = b
g.w = d
n.p = g
n.w = b
n.q = d
n.r = k
d.w = h
d.x = k
d.r = b
d.t = g
h.p = k
assert d.x.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.x: A = None
        self.r: B = None
        self.t: C = None
        self.txt = txt

k = A("k")
b = B("b")
g = C("g")
n = D("n")
d = E("d")
h = A("h")

k.p = h
b.v = d
b.t = d
b.w = h
g.r = b
g.z = b
g.w = d
n.p = g
n.w = b
n.q = d
n.r = k
d.w = h
d.x = k
d.r = b
d.t = g
h.p = k
assert d.x.p.p.p.txt == "h"