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

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: B = None
        self.p: A = None
        self.t: D = None
        self.u: D = None
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
n = C("n")
m = D("m")
e = E("e")
j = F("j")
h = C("h")

a.o = m
d.p = e
d.v = a
d.s = j
n.w = a
m.t = j
m.q = e
m.u = a
e.o = m
e.t = m
e.u = m
e.y = m
e.x = d
e.p = a
j.t = n
h.w = a
assert e.y.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.o: D = None
        self.x: B = None
        self.p: A = None
        self.t: D = None
        self.u: D = None
        self.y: D = None
        self.txt = txt

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

a = A("a")
d = B("d")
n = C("n")
m = D("m")
e = E("e")
j = F("j")
h = C("h")

a.o = m
d.p = e
d.v = a
d.s = j
n.w = a
m.t = j
m.q = e
m.u = a
e.o = m
e.t = m
e.u = m
e.y = m
e.x = d
e.p = a
j.t = n
h.w = a
assert e.y.u.o.txt == "m"