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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.x: B = None
        self.z: E = None
        self.u: E = None
        self.v: A = None
        self.r: F = None
        self.txt = txt

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

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.x: B = None
        self.z: E = None
        self.u: E = None
        self.v: A = None
        self.r: F = None
        self.txt = txt

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

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

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

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

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