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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: A = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: A = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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