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

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

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

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

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

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

n = A("n")
m = B("m")
d = C("d")
l = D("l")
k = E("k")
j = F("j")
f = B("f")

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

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

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

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

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

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

n = A("n")
m = B("m")
d = C("d")
l = D("l")
k = E("k")
j = F("j")
f = B("f")

n.o = k
n.x = k
n.y = j
n.r = j
m.x = j
m.y = f
d.z = n
l.y = m
k.q = j
k.u = l
k.w = n
k.z = d
k.p = d
j.v = f
f.x = j
f.y = m
assert d.z.x.q.v.x.txt == "j"