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

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

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

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

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

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

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

k = A("k")
c = B("c")
e = C("e")
b = D("b")
j = E("j")
d = F("d")
g = G("g")
h = D("h")

k.w = e
k.u = c
c.z = d
c.r = b
c.u = e
e.s = g
e.v = c
e.p = d
e.q = k
b.r = k
b.q = d
j.x = c
j.p = e
d.p = j
g.r = h
g.u = c
g.w = j
g.v = k
h.r = k
h.q = d
assert j.x.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.u: B = None
        self.txt = txt

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

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

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

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

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

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

k = A("k")
c = B("c")
e = C("e")
b = D("b")
j = E("j")
d = F("d")
g = G("g")
h = D("h")

k.w = e
k.u = c
c.z = d
c.r = b
c.u = e
e.s = g
e.v = c
e.p = d
e.q = k
b.r = k
b.q = d
j.x = c
j.p = e
d.p = j
g.r = h
g.u = c
g.w = j
g.v = k
h.r = k
h.q = d
assert j.x.r.q.txt == "d"