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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.w: D = None
        self.t: D = None
        self.r: C = None
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.txt = txt

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

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

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

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

b.y = n
b.r = n
a.o = n
a.w = n
a.t = n
a.r = f
a.p = h
f.r = h
f.z = h
n.w = k
n.p = h
n.y = h
h.y = f
h.q = b
h.u = m
l.q = k
k.r = h
k.z = h
m.y = n
m.r = n
assert k.z.u.y.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.w: D = None
        self.t: D = None
        self.r: C = None
        self.p: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.txt = txt

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

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

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

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

b.y = n
b.r = n
a.o = n
a.w = n
a.t = n
a.r = f
a.p = h
f.r = h
f.z = h
n.w = k
n.p = h
n.y = h
h.y = f
h.q = b
h.u = m
l.q = k
k.r = h
k.z = h
m.y = n
m.r = n
assert k.z.u.y.p.y.txt == "f"