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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.s: C = None
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: B = None
        self.x: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

h = A("h")
i = B("i")
g = C("g")
j = D("j")
k = E("k")
n = F("n")

h.u = g
h.q = g
h.z = i
i.x = j
i.v = j
i.u = g
i.s = g
g.u = h
g.v = j
g.s = j
j.t = i
j.u = i
j.x = n
k.p = n
n.w = h
assert j.t.v.x.w.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: C = None
        self.z: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.s: C = None
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: B = None
        self.x: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

h = A("h")
i = B("i")
g = C("g")
j = D("j")
k = E("k")
n = F("n")

h.u = g
h.q = g
h.z = i
i.x = j
i.v = j
i.u = g
i.s = g
g.u = h
g.v = j
g.s = j
j.t = i
j.u = i
j.x = n
k.p = n
n.w = h
assert j.t.v.x.w.u.u.txt == "h"