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

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

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

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

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

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

b = A("b")
f = B("f")
j = C("j")
n = D("n")
a = E("a")
k = F("k")

b.v = k
f.w = n
f.s = a
f.p = j
j.z = n
n.o = b
n.u = k
n.p = j
a.q = f
k.q = f
assert a.q.s.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.txt = txt

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

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

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

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

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

b = A("b")
f = B("f")
j = C("j")
n = D("n")
a = E("a")
k = F("k")

b.v = k
f.w = n
f.s = a
f.p = j
j.z = n
n.o = b
n.u = k
n.p = j
a.q = f
k.q = f
assert a.q.s.q.p.txt == "j"