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

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.s: C = None
        self.p: C = None
        self.t: E = None
        self.o: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: A = None
        self.q: E = None
        self.p: B = None
        self.y: B = None
        self.txt = txt

n = A("n")
h = B("h")
d = C("d")
a = D("a")
g = E("g")
i = F("i")
m = B("m")

n.w = a
n.p = g
n.r = i
h.y = i
h.s = d
h.p = d
h.t = g
h.o = n
d.q = n
d.y = n
d.p = g
d.t = g
a.v = n
a.p = d
g.p = i
g.r = a
i.t = n
i.u = n
i.q = g
i.p = m
i.y = m
m.y = i
m.s = d
m.p = d
m.t = g
m.o = n
assert h.y.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: E = None
        self.r: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: F = None
        self.s: C = None
        self.p: C = None
        self.t: E = None
        self.o: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.t: A = None
        self.u: A = None
        self.q: E = None
        self.p: B = None
        self.y: B = None
        self.txt = txt

n = A("n")
h = B("h")
d = C("d")
a = D("a")
g = E("g")
i = F("i")
m = B("m")

n.w = a
n.p = g
n.r = i
h.y = i
h.s = d
h.p = d
h.t = g
h.o = n
d.q = n
d.y = n
d.p = g
d.t = g
a.v = n
a.p = d
g.p = i
g.r = a
i.t = n
i.u = n
i.q = g
i.p = m
i.y = m
m.y = i
m.s = d
m.p = d
m.t = g
m.o = n
assert h.y.q.r.txt == "a"