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

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: F = None
        self.s: D = None
        self.w: D = None
        self.p: A = None
        self.txt = txt

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

j = A("j")
i = B("i")
h = C("h")
g = D("g")
l = E("l")
c = F("c")
m = D("m")
f = F("f")

j.t = h
i.q = f
i.y = g
h.o = i
h.x = i
g.o = m
g.u = i
l.y = h
l.x = c
l.s = m
l.w = m
l.p = j
c.w = m
m.o = g
m.u = i
f.w = g
assert m.o.u.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: F = None
        self.s: D = None
        self.w: D = None
        self.p: A = None
        self.txt = txt

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

j = A("j")
i = B("i")
h = C("h")
g = D("g")
l = E("l")
c = F("c")
m = D("m")
f = F("f")

j.t = h
i.q = f
i.y = g
h.o = i
h.x = i
g.o = m
g.u = i
l.y = h
l.x = c
l.s = m
l.w = m
l.p = j
c.w = m
m.o = g
m.u = i
f.w = g
assert m.o.u.y.o.txt == "m"