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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: E = None
        self.v: B = None
        self.u: A = None
        self.txt = txt

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

a = A("a")
j = B("j")
d = C("d")
h = D("h")
f = E("f")
g = A("g")
c = A("c")

a.q = h
j.t = a
d.z = f
d.v = h
d.q = h
h.x = g
h.u = g
h.p = f
h.v = j
f.r = j
f.x = j
f.u = g
f.z = h
g.q = h
c.q = h
assert g.q.v.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: E = None
        self.v: B = None
        self.u: A = None
        self.txt = txt

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

a = A("a")
j = B("j")
d = C("d")
h = D("h")
f = E("f")
g = A("g")
c = A("c")

a.q = h
j.t = a
d.z = f
d.v = h
d.q = h
h.x = g
h.u = g
h.p = f
h.v = j
f.r = j
f.x = j
f.u = g
f.z = h
g.q = h
c.q = h
assert g.q.v.t.q.txt == "h"