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

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

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

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

b = A("b")
a = B("a")
c = C("c")
l = D("l")
i = D("i")
m = C("m")
f = B("f")
k = A("k")

b.o = c
b.w = c
b.p = i
b.x = l
a.w = f
c.p = k
l.t = i
i.t = l
m.p = k
f.w = a
k.o = m
k.p = l
k.x = l
k.w = c
assert i.t.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: D = None
        self.w: C = None
        self.x: D = None
        self.txt = txt

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

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

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

b = A("b")
a = B("a")
c = C("c")
l = D("l")
i = D("i")
m = C("m")
f = B("f")
k = A("k")

b.o = c
b.w = c
b.p = i
b.x = l
a.w = f
c.p = k
l.t = i
i.t = l
m.p = k
f.w = a
k.o = m
k.p = l
k.x = l
k.w = c
assert i.t.t.t.t.t.t.t.t.txt == "i"