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

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

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

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

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

c = A("c")
f = B("f")
e = C("e")
m = D("m")
b = E("b")
h = D("h")
g = A("g")
d = C("d")
k = D("k")

c.q = d
c.p = b
c.v = b
c.y = g
f.q = k
f.x = e
f.w = c
e.p = m
e.q = h
m.s = f
b.s = m
b.x = d
h.s = f
g.q = e
g.p = b
g.v = b
g.y = c
d.p = h
d.q = m
k.s = f
assert k.s.q.s.w.y.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.p: E = None
        self.v: E = None
        self.y: A = None
        self.txt = txt

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

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

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

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

c = A("c")
f = B("f")
e = C("e")
m = D("m")
b = E("b")
h = D("h")
g = A("g")
d = C("d")
k = D("k")

c.q = d
c.p = b
c.v = b
c.y = g
f.q = k
f.x = e
f.w = c
e.p = m
e.q = h
m.s = f
b.s = m
b.x = d
h.s = f
g.q = e
g.p = b
g.v = b
g.y = c
d.p = h
d.q = m
k.s = f
assert k.s.q.s.w.y.y.p.txt == "b"