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

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: F = None
        self.s: F = None
        self.v: E = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
m = C("m")
f = D("f")
n = E("n")
j = F("j")
b = C("b")
i = F("i")
k = C("k")
c = D("c")

a.y = n
d.p = a
d.u = f
d.z = f
d.v = n
m.w = k
m.r = c
f.z = d
f.u = i
f.s = j
f.v = n
n.w = a
j.p = f
j.u = c
b.w = m
b.r = c
i.p = f
i.u = f
k.w = m
k.r = c
c.z = d
c.u = i
c.s = i
c.v = n
assert b.w.w.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.u: F = None
        self.s: F = None
        self.v: E = None
        self.txt = txt

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

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

a = A("a")
d = B("d")
m = C("m")
f = D("f")
n = E("n")
j = F("j")
b = C("b")
i = F("i")
k = C("k")
c = D("c")

a.y = n
d.p = a
d.u = f
d.z = f
d.v = n
m.w = k
m.r = c
f.z = d
f.u = i
f.s = j
f.v = n
n.w = a
j.p = f
j.u = c
b.w = m
b.r = c
i.p = f
i.u = f
k.w = m
k.r = c
c.z = d
c.u = i
c.s = i
c.v = n
assert b.w.w.r.z.txt == "d"