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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: B = None
        self.txt = txt

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

d.p = g
d.u = g
g.u = e
g.w = c
e.w = d
e.r = n
e.p = i
e.s = h
n.r = i
n.s = b
i.y = j
i.s = j
i.p = g
i.v = e
i.x = e
c.y = e
c.r = b
h.r = i
h.s = b
j.p = b
j.u = b
b.u = e
b.w = a
a.y = e
a.r = g
assert n.r.p.w.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: B = None
        self.txt = txt

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

d.p = g
d.u = g
g.u = e
g.w = c
e.w = d
e.r = n
e.p = i
e.s = h
n.r = i
n.s = b
i.y = j
i.s = j
i.p = g
i.v = e
i.x = e
c.y = e
c.r = b
h.r = i
h.s = b
j.p = b
j.u = b
b.u = e
b.w = a
a.y = e
a.r = g
assert n.r.p.w.y.w.txt == "d"