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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.u: B = None
        self.t: B = None
        self.z: D = None
        self.v: D = None
        self.txt = txt

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

g.q = k
n.w = j
n.v = g
k.o = a
e.y = n
e.w = g
e.q = g
j.y = e
a.s = j
a.u = n
a.t = n
a.z = e
a.v = e
assert k.o.s.y.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.u: B = None
        self.t: B = None
        self.z: D = None
        self.v: D = None
        self.txt = txt

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

g.q = k
n.w = j
n.v = g
k.o = a
e.y = n
e.w = g
e.q = g
j.y = e
a.s = j
a.u = n
a.t = n
a.z = e
a.v = e
assert k.o.s.y.y.w.y.txt == "e"