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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.r: A = None
        self.w: B = None
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
n = C("n")
c = D("c")
b = E("b")
h = F("h")
l = C("l")
f = A("f")

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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: A = None
        self.r: A = None
        self.w: B = None
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
n = C("n")
c = D("c")
b = E("b")
h = F("h")
l = C("l")
f = A("f")

a.z = c
a.p = g
g.w = a
n.q = a
n.v = f
n.r = f
n.w = g
n.y = l
c.q = h
b.p = c
b.u = c
b.q = a
b.w = g
b.s = g
b.y = h
h.p = g
h.u = c
h.o = f
h.r = b
l.q = a
l.v = a
l.r = a
l.w = g
l.y = n
f.z = c
f.p = g
assert h.r.q.z.q.p.w.p.w.txt == "a"