class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: E = None
        self.q: H = None
        self.r: E = None
        self.x: B = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: C = None
        self.v: F = None
        self.w: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: D = None
        self.y: F = None
        self.q: F = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
m = C("m")
k = D("k")
f = E("f")
i = F("i")
a = G("a")
b = H("b")

n.w = k
n.s = f
n.r = f
n.y = f
n.q = b
n.x = c
c.x = i
c.v = i
c.r = m
c.w = k
m.t = c
k.q = c
k.p = i
k.w = a
f.u = c
f.w = k
f.y = i
f.q = i
i.q = f
a.q = m
a.r = c
a.s = i
b.o = c
assert m.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: E = None
        self.q: H = None
        self.r: E = None
        self.x: B = None
        self.y: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: C = None
        self.v: F = None
        self.w: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: D = None
        self.y: F = None
        self.q: F = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
m = C("m")
k = D("k")
f = E("f")
i = F("i")
a = G("a")
b = H("b")

n.w = k
n.s = f
n.r = f
n.y = f
n.q = b
n.x = c
c.x = i
c.v = i
c.r = m
c.w = k
m.t = c
k.q = c
k.p = i
k.w = a
f.u = c
f.w = k
f.y = i
f.q = i
i.q = f
a.q = m
a.r = c
a.s = i
b.o = c
assert m.t.r.t.r.txt == "m"