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

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: C = None
        self.p: B = None
        self.y: C = None
        self.txt = txt

j = A("j")
e = B("e")
f = C("f")
m = D("m")
i = B("i")

j.o = f
j.s = f
e.t = m
e.v = m
e.u = i
f.t = m
f.x = j
f.y = j
m.t = j
m.s = f
m.y = f
m.p = i
i.t = m
i.v = m
i.u = e
assert j.s.x.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: C = None
        self.p: B = None
        self.y: C = None
        self.txt = txt

j = A("j")
e = B("e")
f = C("f")
m = D("m")
i = B("i")

j.o = f
j.s = f
e.t = m
e.v = m
e.u = i
f.t = m
f.x = j
f.y = j
m.t = j
m.s = f
m.y = f
m.p = i
i.t = m
i.v = m
i.u = e
assert j.s.x.o.t.txt == "m"