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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: B = None
        self.w: C = None
        self.t: A = None
        self.o: A = None
        self.v: C = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.r: B = None
        self.w: C = None
        self.t: A = None
        self.o: A = None
        self.v: C = None
        self.y: C = None
        self.txt = txt

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

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

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

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

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

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

g.r = d
a.q = k
a.r = h
a.w = d
a.v = d
a.y = d
a.t = g
a.o = g
d.o = h
d.z = m
d.w = m
b.t = n
b.v = g
b.p = d
k.s = n
m.s = g
n.t = b
h.q = k
h.r = a
h.w = d
h.v = d
h.y = d
h.t = g
h.o = g
assert a.o.r.w.s.r.z.txt == "m"