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

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

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

class D:
    def __init__(self, txt: str):
        self.o: F = None
        self.p: G = None
        self.r: A = None
        self.q: A = None
        self.y: B = None
        self.w: F = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.o: F = None
        self.p: G = None
        self.r: A = None
        self.q: A = None
        self.y: B = None
        self.w: F = None
        self.x: F = None
        self.txt = txt

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

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

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

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

b.r = d
h.w = n
d.r = m
f.o = k
f.x = k
f.p = j
f.r = b
f.q = b
f.y = a
f.w = m
n.q = a
k.z = n
j.o = b
j.v = a
m.z = n
a.w = n
assert n.q.w.q.w.q.w.txt == "n"