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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.x: C = None
        self.txt = txt

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

i = A("i")
g = B("g")
j = C("j")
a = D("a")
n = E("n")
e = F("e")
k = E("k")
d = D("d")

i.u = n
i.w = j
g.q = a
j.t = a
j.y = a
j.q = d
j.z = i
j.x = k
a.x = i
n.p = g
n.t = g
n.x = j
e.p = i
e.q = i
e.y = j
k.p = g
k.t = g
k.x = j
d.x = i
assert g.q.x.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.w: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.x: C = None
        self.txt = txt

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

i = A("i")
g = B("g")
j = C("j")
a = D("a")
n = E("n")
e = F("e")
k = E("k")
d = D("d")

i.u = n
i.w = j
g.q = a
j.t = a
j.y = a
j.q = d
j.z = i
j.x = k
a.x = i
n.p = g
n.t = g
n.x = j
e.p = i
e.q = i
e.y = j
k.p = g
k.t = g
k.x = j
d.x = i
assert g.q.x.w.q.txt == "d"