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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: A = None
        self.z: D = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.y: A = None
        self.z: D = None
        self.txt = txt

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

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

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

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

b.q = h
b.o = c
h.u = c
h.z = c
h.y = b
g.p = c
c.z = g
c.x = d
c.q = h
c.t = j
l.w = g
l.o = g
n.w = g
n.o = g
j.q = h
j.o = d
d.z = g
d.x = c
d.q = h
d.t = b
assert h.z.t.q.z.t.o.x.txt == "c"