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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
l = C("l")
j = D("j")
g = B("g")
k = B("k")
m = A("m")

e.u = j
e.p = m
c.t = j
l.q = c
l.r = e
j.w = c
j.o = e
g.t = j
k.t = j
m.u = j
m.p = e
assert j.w.t.w.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
l = C("l")
j = D("j")
g = B("g")
k = B("k")
m = A("m")

e.u = j
e.p = m
c.t = j
l.q = c
l.r = e
j.w = c
j.o = e
g.t = j
k.t = j
m.u = j
m.p = e
assert j.w.t.w.t.w.t.w.txt == "c"