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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: B = None
        self.r: B = None
        self.v: D = None
        self.txt = txt

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

n.q = g
n.p = g
e.y = f
e.q = k
e.v = g
j.z = g
g.y = n
g.t = f
h.y = g
h.v = g
h.w = f
h.r = e
f.y = e
f.q = h
f.v = g
k.y = g
k.v = g
k.w = f
k.r = e
d.z = g
c.q = g
c.p = g
assert h.w.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.p: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.w: B = None
        self.r: B = None
        self.v: D = None
        self.txt = txt

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

n.q = g
n.p = g
e.y = f
e.q = k
e.v = g
j.z = g
g.y = n
g.t = f
h.y = g
h.v = g
h.w = f
h.r = e
f.y = e
f.q = h
f.v = g
k.y = g
k.v = g
k.w = f
k.r = e
d.z = g
c.q = g
c.p = g
assert h.w.q.y.txt == "g"