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

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: A = None
        self.s: E = None
        self.q: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: A = None
        self.s: E = None
        self.q: B = None
        self.p: D = None
        self.txt = txt

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

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

m.o = g
h.s = d
a.w = h
b.z = h
g.z = b
g.p = b
g.r = m
g.s = i
g.q = h
d.r = h
i.z = b
i.p = b
i.r = m
i.s = g
i.q = h
k.w = h
assert b.z.s.r.s.r.txt == "h"