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

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

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

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

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

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

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

k.v = m
j.p = k
j.q = b
m.u = j
m.o = j
d.z = l
e.q = d
l.y = d
l.z = j
l.s = j
l.p = e
l.r = m
f.u = j
f.o = j
b.u = j
b.o = j
assert k.v.o.q.u.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

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

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

k.v = m
j.p = k
j.q = b
m.u = j
m.o = j
d.z = l
e.q = d
l.y = d
l.z = j
l.s = j
l.p = e
l.r = m
f.u = j
f.o = j
b.u = j
b.o = j
assert k.v.o.q.u.p.v.txt == "m"