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

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

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

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

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

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

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

n.o = i
j.w = h
j.y = n
d.w = c
d.v = i
m.o = i
m.v = n
h.o = i
h.t = a
c.t = n
i.w = c
i.v = d
a.o = i
a.v = n
l.w = b
l.y = n
b.o = d
b.t = a
assert h.t.o.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

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

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

n.o = i
j.w = h
j.y = n
d.w = c
d.v = i
m.o = i
m.v = n
h.o = i
h.t = a
c.t = n
i.w = c
i.v = d
a.o = i
a.v = n
l.w = b
l.y = n
b.o = d
b.t = a
assert h.t.o.v.v.v.v.txt == "i"