class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: G = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.z: F = None
        self.x: B = None
        self.o: A = None
        self.s: A = None
        self.v: F = None
        self.txt = txt

f = A("f")
k = B("k")
h = C("h")
m = D("m")
n = E("n")
d = F("d")
g = G("g")

f.p = m
f.u = g
k.w = n
k.v = n
k.x = f
k.r = f
h.w = g
m.q = h
m.p = k
n.o = h
d.w = n
g.z = d
g.v = d
g.x = k
g.o = f
g.s = f
assert k.w.o.w.o.p.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: G = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.z: F = None
        self.x: B = None
        self.o: A = None
        self.s: A = None
        self.v: F = None
        self.txt = txt

f = A("f")
k = B("k")
h = C("h")
m = D("m")
n = E("n")
d = F("d")
g = G("g")

f.p = m
f.u = g
k.w = n
k.v = n
k.x = f
k.r = f
h.w = g
m.q = h
m.p = k
n.o = h
d.w = n
g.z = d
g.v = d
g.x = k
g.o = f
g.s = f
assert k.w.o.w.o.p.q.w.txt == "g"