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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.s: A = None
        self.q: F = None
        self.t: E = None
        self.r: D = None
        self.u: F = None
        self.txt = txt

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

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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.s: A = None
        self.q: F = None
        self.t: E = None
        self.r: D = None
        self.u: F = None
        self.txt = txt

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

a.p = b
b.t = n
k.z = b
k.q = a
j.t = g
j.v = a
n.u = b
n.w = k
n.q = k
n.y = k
i.p = b
g.p = b
g.v = b
g.s = a
g.q = i
g.u = i
g.t = n
g.r = j
assert j.v.p.t.u.txt == "b"