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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: D = None
        self.x: E = None
        self.s: A = None
        self.txt = txt

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

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

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

d.p = g
g.r = b
g.p = d
g.s = h
k.q = h
k.y = h
k.x = b
k.s = d
h.u = g
h.r = b
h.v = b
h.q = k
h.o = d
b.r = k
b.t = d
b.v = d
b.x = d
b.s = d
assert k.y.v.t.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.y: D = None
        self.x: E = None
        self.s: A = None
        self.txt = txt

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

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

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

d.p = g
g.r = b
g.p = d
g.s = h
k.q = h
k.y = h
k.x = b
k.s = d
h.u = g
h.r = b
h.v = b
h.q = k
h.o = d
b.r = k
b.t = d
b.v = d
b.x = d
b.s = d
assert k.y.v.t.p.s.txt == "h"