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

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

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.x: B = None
        self.u: F = None
        self.v: E = None
        self.q: F = None
        self.y: E = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
b = C("b")
m = D("m")
f = E("f")
e = F("e")
n = C("n")
d = F("d")

h.w = g
g.x = d
g.p = h
b.w = f
b.u = f
b.x = g
b.y = d
m.w = e
m.u = e
m.x = g
m.v = f
m.y = f
m.q = d
f.s = h
f.p = m
f.y = e
e.q = n
e.s = b
n.w = f
n.u = f
n.x = g
n.y = e
d.q = n
d.s = b
assert b.x.p.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.w: F = None
        self.x: B = None
        self.u: F = None
        self.v: E = None
        self.q: F = None
        self.y: E = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
b = C("b")
m = D("m")
f = E("f")
e = F("e")
n = C("n")
d = F("d")

h.w = g
g.x = d
g.p = h
b.w = f
b.u = f
b.x = g
b.y = d
m.w = e
m.u = e
m.x = g
m.v = f
m.y = f
m.q = d
f.s = h
f.p = m
f.y = e
e.q = n
e.s = b
n.w = f
n.u = f
n.x = g
n.y = e
d.q = n
d.s = b
assert b.x.p.w.x.txt == "d"