class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: A = None
        self.o: D = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
n = C("n")
i = D("i")
b = E("b")
j = F("j")
a = D("a")
d = F("d")

m.o = b
g.x = b
g.y = b
g.u = b
n.x = m
n.s = m
i.p = n
i.w = m
i.o = a
b.s = i
j.q = b
j.o = a
a.p = n
a.w = m
a.o = i
d.q = b
d.o = i
assert b.s.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.w: A = None
        self.o: D = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
n = C("n")
i = D("i")
b = E("b")
j = F("j")
a = D("a")
d = F("d")

m.o = b
g.x = b
g.y = b
g.u = b
n.x = m
n.s = m
i.p = n
i.w = m
i.o = a
b.s = i
j.q = b
j.o = a
a.p = n
a.w = m
a.o = i
d.q = b
d.o = i
assert b.s.w.o.txt == "b"