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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.v: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.y: A = None
        self.v: C = None
        self.o: E = None
        self.txt = txt

i = A("i")
m = B("m")
j = C("j")
f = D("f")
g = E("g")
k = F("k")

i.z = k
i.p = f
m.v = i
j.w = m
j.x = f
j.v = g
f.z = g
f.o = m
f.r = m
f.s = j
g.p = j
k.w = g
k.o = g
k.y = i
k.v = j
assert i.p.o.v.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: F = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.v: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.y: A = None
        self.v: C = None
        self.o: E = None
        self.txt = txt

i = A("i")
m = B("m")
j = C("j")
f = D("f")
g = E("g")
k = F("k")

i.z = k
i.p = f
m.v = i
j.w = m
j.x = f
j.v = g
f.z = g
f.o = m
f.r = m
f.s = j
g.p = j
k.w = g
k.o = g
k.y = i
k.v = j
assert i.p.o.v.p.z.p.txt == "j"