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

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

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

class D:
    def __init__(self, txt: str):
        self.z: F = None
        self.r: E = None
        self.x: F = None
        self.y: B = None
        self.p: A = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

j = A("j")
g = B("g")
n = C("n")
k = D("k")
l = E("l")
m = F("m")
c = G("c")
a = E("a")

j.y = g
j.x = k
g.r = j
n.s = k
n.r = m
k.z = m
k.x = m
k.r = l
k.y = g
k.p = j
l.x = g
l.p = j
l.t = m
l.z = m
l.s = k
m.t = g
m.x = j
m.q = k
c.s = m
a.x = g
a.p = j
a.t = m
a.z = m
a.s = k
assert c.s.x.y.r.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: F = None
        self.r: E = None
        self.x: F = None
        self.y: B = None
        self.p: A = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

j = A("j")
g = B("g")
n = C("n")
k = D("k")
l = E("l")
m = F("m")
c = G("c")
a = E("a")

j.y = g
j.x = k
g.r = j
n.s = k
n.r = m
k.z = m
k.x = m
k.r = l
k.y = g
k.p = j
l.x = g
l.p = j
l.t = m
l.z = m
l.s = k
m.t = g
m.x = j
m.q = k
c.s = m
a.x = g
a.p = j
a.t = m
a.z = m
a.s = k
assert c.s.x.y.r.x.z.x.txt == "j"