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

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

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

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

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

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

d = A("d")
n = B("n")
g = C("g")
i = D("i")
a = E("a")
f = F("f")
b = B("b")
k = F("k")

d.v = a
n.r = k
n.v = d
g.y = k
g.z = i
g.r = i
g.x = a
i.q = g
i.w = a
a.v = b
a.q = g
a.z = g
f.r = n
f.y = k
b.r = f
b.v = d
k.r = n
k.y = f
assert f.y.y.y.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

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

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

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

d = A("d")
n = B("n")
g = C("g")
i = D("i")
a = E("a")
f = F("f")
b = B("b")
k = F("k")

d.v = a
n.r = k
n.v = d
g.y = k
g.z = i
g.r = i
g.x = a
i.q = g
i.w = a
a.v = b
a.q = g
a.z = g
f.r = n
f.y = k
b.r = f
b.v = d
k.r = n
k.y = f
assert f.y.y.y.r.r.r.txt == "n"