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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.r: B = None
        self.v: B = None
        self.u: E = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
m = C("m")
n = D("n")
l = E("l")
g = F("g")
j = F("j")

f.v = n
f.p = n
f.z = g
c.w = l
c.t = g
m.t = f
m.r = c
m.v = c
m.u = l
n.y = f
n.s = l
n.r = l
n.t = l
l.o = m
g.p = c
j.p = c
assert n.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: F = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.r: B = None
        self.v: B = None
        self.u: E = None
        self.txt = txt

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

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

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

f = A("f")
c = B("c")
m = C("m")
n = D("n")
l = E("l")
g = F("g")
j = F("j")

f.v = n
f.p = n
f.z = g
c.w = l
c.t = g
m.t = f
m.r = c
m.v = c
m.u = l
n.y = f
n.s = l
n.r = l
n.t = l
l.o = m
g.p = c
j.p = c
assert n.t.o.t.txt == "f"