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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.q: B = None
        self.u: C = None
        self.w: B = None
        self.p: B = None
        self.txt = txt

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

m.x = b
m.q = h
k.p = n
n.z = k
b.o = m
h.s = m
g.s = k
g.q = k
g.w = k
g.p = k
g.o = b
g.u = n
e.s = m
assert e.s.x.o.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: E = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: D = None
        self.q: B = None
        self.u: C = None
        self.w: B = None
        self.p: B = None
        self.txt = txt

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

m.x = b
m.q = h
k.p = n
n.z = k
b.o = m
h.s = m
g.s = k
g.q = k
g.w = k
g.p = k
g.o = b
g.u = n
e.s = m
assert e.s.x.o.x.o.x.o.txt == "m"