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

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
i = C("i")
n = D("n")
d = E("d")
b = B("b")
h = E("h")
g = E("g")

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

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: B = None
        self.txt = txt

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

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

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

c = A("c")
j = B("j")
i = C("i")
n = D("n")
d = E("d")
b = B("b")
h = E("h")
g = E("g")

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