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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: E = None
        self.z: D = None
        self.o: D = None
        self.v: C = None
        self.x: D = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: D = None
        self.u: B = None
        self.q: B = None
        self.x: A = None
        self.txt = txt

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

n.w = d
g.z = h
g.q = f
h.s = g
h.o = l
h.p = m
d.p = h
m.y = l
m.z = i
m.o = i
m.x = i
m.v = h
m.w = h
f.r = n
f.x = n
f.s = b
f.u = g
f.q = g
i.p = h
l.y = m
l.z = d
l.o = d
l.v = h
l.w = h
l.x = i
b.p = h
assert f.x.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: E = None
        self.z: D = None
        self.o: D = None
        self.v: C = None
        self.x: D = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: D = None
        self.u: B = None
        self.q: B = None
        self.x: A = None
        self.txt = txt

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

n.w = d
g.z = h
g.q = f
h.s = g
h.o = l
h.p = m
d.p = h
m.y = l
m.z = i
m.o = i
m.x = i
m.v = h
m.w = h
f.r = n
f.x = n
f.s = b
f.u = g
f.q = g
i.p = h
l.y = m
l.z = d
l.o = d
l.v = h
l.w = h
l.x = i
b.p = h
assert f.x.w.p.txt == "h"