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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: B = None
        self.s: D = None
        self.txt = txt

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

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

b.w = g
j.x = d
a.v = j
a.w = k
n.q = d
n.y = d
n.t = a
n.s = a
n.w = j
d.v = n
d.s = n
d.y = j
k.p = b
k.z = j
g.w = b
assert d.v.q.v.q.s.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: B = None
        self.s: D = None
        self.txt = txt

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

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

b.w = g
j.x = d
a.v = j
a.w = k
n.q = d
n.y = d
n.t = a
n.s = a
n.w = j
d.v = n
d.s = n
d.y = j
k.p = b
k.z = j
g.w = b
assert d.v.q.v.q.s.y.v.txt == "n"