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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: F = None
        self.y: G = None
        self.o: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: F = None
        self.y: G = None
        self.o: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: F = None
        self.txt = txt

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

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