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

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.u: A = None
        self.w: F = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

a.v = g
g.p = l
g.r = l
g.u = a
g.w = c
g.v = f
f.q = c
l.o = c
l.t = f
j.q = a
j.y = l
c.s = a
assert f.q.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: D = None
        self.r: D = None
        self.u: A = None
        self.w: F = None
        self.v: C = None
        self.txt = txt

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

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

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

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

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

a.v = g
g.p = l
g.r = l
g.u = a
g.w = c
g.v = f
f.q = c
l.o = c
l.t = f
j.q = a
j.y = l
c.s = a
assert f.q.s.v.txt == "g"