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

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

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

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

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

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

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

a.q = g
a.v = g
a.r = k
k.y = m
k.u = a
m.v = a
m.t = g
j.o = f
f.v = a
f.o = a
f.q = j
g.o = m
assert m.t.o.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.r: B = None
        self.v: F = None
        self.txt = txt

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

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

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

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

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

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

a.q = g
a.v = g
a.r = k
k.y = m
k.u = a
m.v = a
m.t = g
j.o = f
f.v = a
f.o = a
f.q = j
g.o = m
assert m.t.o.v.q.txt == "g"