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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

h.q = i
k.z = m
k.v = i
k.q = d
i.o = k
j.s = g
b.x = i
b.s = j
b.z = h
b.t = d
d.w = h
d.p = b
g.v = b
m.q = i
assert i.o.z.q.o.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

h.q = i
k.z = m
k.v = i
k.q = d
i.o = k
j.s = g
b.x = i
b.s = j
b.z = h
b.t = d
d.w = h
d.p = b
g.v = b
m.q = i
assert i.o.z.q.o.q.p.txt == "b"