class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: C = None
        self.w: G = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

k = A("k")
n = B("n")
l = C("l")
a = D("a")
b = E("b")
e = F("e")
f = G("f")

k.s = n
k.x = a
n.x = k
n.q = l
n.w = f
n.r = a
l.s = n
l.q = e
l.p = a
a.s = n
a.y = k
b.t = a
e.w = l
f.r = k
assert e.w.s.q.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: C = None
        self.w: G = None
        self.r: D = None
        self.txt = txt

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

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

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

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

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

k = A("k")
n = B("n")
l = C("l")
a = D("a")
b = E("b")
e = F("e")
f = G("f")

k.s = n
k.x = a
n.x = k
n.q = l
n.w = f
n.r = a
l.s = n
l.q = e
l.p = a
a.s = n
a.y = k
b.t = a
e.w = l
f.r = k
assert e.w.s.q.s.txt == "n"